Skip to content

Commit

Permalink
coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
shzcore committed Jun 8, 2020
1 parent 9fc4cc4 commit c294456
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions src/main/java/com/baidu/hugegraph/rest/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,8 @@

package com.baidu.hugegraph.rest;

import static org.glassfish.jersey.apache.connector.ApacheClientProperties.CONNECTION_MANAGER;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Variant;

import com.baidu.hugegraph.util.ExecutorUtil;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.pool.PoolStats;
Expand All @@ -50,17 +34,26 @@
import org.glassfish.jersey.message.GZipEncoder;
import org.glassfish.jersey.uri.UriComponent;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.*;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Variant;
import java.security.KeyManagementException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.baidu.hugegraph.util.ExecutorUtil;
import com.google.common.collect.ImmutableMap;
import static org.glassfish.jersey.apache.connector.ApacheClientProperties.CONNECTION_MANAGER;



Expand Down Expand Up @@ -138,8 +131,10 @@ public X509Certificate[] getAcceptedIssuers() {
private Client wrapTrustConfig(String url, ClientConfig config) {
Client client = null;
SslConfigurator sslConfig = SslConfigurator.newInstance();
sslConfig.trustStoreFile(config.getProperties().get("trustStoreFile").toString())
.trustStorePassword(config.getProperties().get("trustStorePassword").toString());
String trustStoreFile = config.getProperty("trustStoreFile").toString();
String trustStorePassword = config.getProperty("trustStorePassword").toString();
sslConfig.trustStoreFile(trustStoreFile)
.trustStorePassword(trustStorePassword);
sslConfig.securityProtocol("SSL");
SSLContext sc = sslConfig.createSSLContext();
TrustManager[] trustAllCerts = NoCheckTrustManager();
Expand All @@ -157,7 +152,7 @@ private Client wrapTrustConfig(String url, ClientConfig config) {

public RestClient(String url, ClientConfig config) {
Client client = null;
Object protocol = config.getProperties().get("protocol");
Object protocol = config.getProperty("protocol");
if (protocol != null && protocol.equals("https")) {
client = wrapTrustConfig(url, config);
} else {
Expand Down
Binary file added src/test/resources/hugegraph-evaluation.license
Binary file not shown.

0 comments on commit c294456

Please sign in to comment.