Skip to content

Commit

Permalink
coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
shzcore committed Jun 9, 2020
1 parent 87ed884 commit b4d1134
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/com/baidu/hugegraph/rest/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
Expand Down Expand Up @@ -107,15 +108,16 @@ public RestClient(String url, String user, String password, int timeout,
this(url, new ConfigBuilder().config(timeout)
.config(user, password)
.config(maxTotal, maxPerRoute)
.config(protocol, trustStoreFile, trustStorePassword)
.config(protocol, trustStoreFile,
trustStorePassword)
.build());
}

private TrustManager[] NoCheckTrustManager() {
return new TrustManager[]{new X509TrustManager()};
private TrustManager[] createNoCheckTrustManager() {
return new TrustManager[]{new NoCheckTrustManager()};
}

private static class X509TrustManager implements javax.net.ssl.X509TrustManager {
private static class NoCheckTrustManager implements X509TrustManager {

@Override
public void checkClientTrusted(X509Certificate[] chain, String authType)
Expand All @@ -142,7 +144,7 @@ private Client wrapTrustConfig(String url, ClientConfig config) {
.trustStorePassword(trustStorePassword);
sslConfig.securityProtocol("SSL");
SSLContext sc = sslConfig.createSSLContext();
TrustManager[] trustAllCerts = NoCheckTrustManager();
TrustManager[] trustAllCerts = createNoCheckTrustManager();
try {
sc.init(null, trustAllCerts, new SecureRandom());
} catch (KeyManagementException e) {
Expand Down

0 comments on commit b4d1134

Please sign in to comment.