Skip to content

Commit

Permalink
(jcabi#178) Fix indentation & extract inner class
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoss committed Jun 26, 2020
1 parent ec5d25b commit 339096b
Showing 1 changed file with 37 additions and 25 deletions.
62 changes: 37 additions & 25 deletions src/main/java/com/jcabi/http/wire/TrustedWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,7 @@ public final class TrustedWire implements Wire {
/**
* Trust manager.
*/
private static final TrustManager MANAGER = new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}

@Override
public void checkClientTrusted(final X509Certificate[] certs,
final String type) {
// nothing to check here
}

@Override
public void checkServerTrusted(final X509Certificate[] certs,
final String types) {
// nothing to check here
}
};
private static final TrustManager MANAGER = new WireX509TrustManager();

/**
* Original wire.
Expand All @@ -103,21 +86,23 @@ public TrustedWire(final Wire wire) {

// @checkstyle ParameterNumber (13 lines)
@Override
public Response send(final Request req, final String home,
public Response send(
final Request req, final String home,
final String method,
final Collection<Map.Entry<String, String>> headers,
final InputStream content,
final int connect, final int read,
final SSLContext context) throws IOException {
final SSLContext resolvedContext;
final SSLContext context
) throws IOException {
final SSLContext ctx;
if (context == null) {
resolvedContext = context();
ctx = TrustedWire.context();
} else {
resolvedContext = context;
ctx = context;
}
return this.origin.send(
req, home, method, headers, content,
connect, read, resolvedContext
req, home, method, headers, content,
connect, read, ctx
);
}

Expand All @@ -139,4 +124,31 @@ private static SSLContext context() {
}
}

/**
* Trust manager for the Wire.
*
* @since 1.17.3
*/
static final class WireX509TrustManager implements X509TrustManager {
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}

@Override
public void checkClientTrusted(
final X509Certificate[] certs,
final String type
) {
// nothing to check here
}

@Override
public void checkServerTrusted(
final X509Certificate[] certs,
final String types
) {
// nothing to check here
}
}
}

0 comments on commit 339096b

Please sign in to comment.