Compare commits
No commits in common. "375e2bc40b74c7e8bf6a8021cb005b1bdbccc07e" and "3da66744c24fd24e69aebb0e6a0e3a0d16135a30" have entirely different histories.
375e2bc40b
...
3da66744c2
|
@ -2,20 +2,13 @@ package com.bocloud.cop.service.internal;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.megatron.common.encrypt.AESEncryptor;
|
import com.megatron.common.encrypt.AESEncryptor;
|
||||||
import com.megatron.common.http.ConnectionManagerHolder;
|
|
||||||
import com.megatron.common.http.HttpClient;
|
import com.megatron.common.http.HttpClient;
|
||||||
import com.megatron.common.model.GeneralResult;
|
import com.megatron.common.model.GeneralResult;
|
||||||
import com.megatron.common.model.Param;
|
import com.megatron.common.model.Param;
|
||||||
import com.megatron.common.model.Sign;
|
import com.megatron.common.model.Sign;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.http.client.config.RequestConfig;
|
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
|
||||||
import org.apache.http.impl.client.HttpClients;
|
|
||||||
import org.apache.http.ssl.SSLContextBuilder;
|
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -24,9 +17,6 @@ import org.springframework.util.Assert;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.KeyManagementException;
|
|
||||||
import java.security.KeyStoreException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -52,7 +42,7 @@ public class CmpInternetService {
|
||||||
"?page=1" +
|
"?page=1" +
|
||||||
"&rows="+Integer.MAX_VALUE +
|
"&rows="+Integer.MAX_VALUE +
|
||||||
"¶ms="+ URLEncoder.encode(JSON.toJSONString(httpParams), StandardCharsets.UTF_8);
|
"¶ms="+ URLEncoder.encode(JSON.toJSONString(httpParams), StandardCharsets.UTF_8);
|
||||||
HttpClient httpClient = new IgnoreVerifyHttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
HttpGet httpGet = new HttpGet(httpUrl);
|
HttpGet httpGet = new HttpGet(httpUrl);
|
||||||
httpGet.addHeader("bsm-token", this.getToken());
|
httpGet.addHeader("bsm-token", this.getToken());
|
||||||
CloseableHttpResponse httpResponse = httpClient.getHttpClient().execute(httpGet);
|
CloseableHttpResponse httpResponse = httpClient.getHttpClient().execute(httpGet);
|
||||||
|
@ -61,7 +51,6 @@ public class CmpInternetService {
|
||||||
Assert.isTrue(httpCode == 200, httpBody);
|
Assert.isTrue(httpCode == 200, httpBody);
|
||||||
return JSON.parseObject(httpBody, GeneralResult.class);
|
return JSON.parseObject(httpBody, GeneralResult.class);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
return new GeneralResult<>(false, e.getMessage());
|
return new GeneralResult<>(false, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +64,7 @@ public class CmpInternetService {
|
||||||
"?page=1" +
|
"?page=1" +
|
||||||
"&rows="+Integer.MAX_VALUE +
|
"&rows="+Integer.MAX_VALUE +
|
||||||
"¶ms="+ URLEncoder.encode(JSON.toJSONString(httpParams), StandardCharsets.UTF_8);
|
"¶ms="+ URLEncoder.encode(JSON.toJSONString(httpParams), StandardCharsets.UTF_8);
|
||||||
HttpClient httpClient = new IgnoreVerifyHttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
HttpGet httpGet = new HttpGet(httpUrl);
|
HttpGet httpGet = new HttpGet(httpUrl);
|
||||||
httpGet.addHeader("bsm-token", this.getToken());
|
httpGet.addHeader("bsm-token", this.getToken());
|
||||||
CloseableHttpResponse httpResponse = httpClient.getHttpClient().execute(httpGet);
|
CloseableHttpResponse httpResponse = httpClient.getHttpClient().execute(httpGet);
|
||||||
|
@ -84,7 +73,6 @@ public class CmpInternetService {
|
||||||
Assert.isTrue(httpCode == 200, httpBody);
|
Assert.isTrue(httpCode == 200, httpBody);
|
||||||
return JSON.parseObject(httpBody, GeneralResult.class);
|
return JSON.parseObject(httpBody, GeneralResult.class);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
return new GeneralResult<>(false, e.getMessage());
|
return new GeneralResult<>(false, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +86,7 @@ public class CmpInternetService {
|
||||||
"?page=1" +
|
"?page=1" +
|
||||||
"&rows="+Integer.MAX_VALUE +
|
"&rows="+Integer.MAX_VALUE +
|
||||||
"¶ms="+ URLEncoder.encode(JSON.toJSONString(httpParams), StandardCharsets.UTF_8);
|
"¶ms="+ URLEncoder.encode(JSON.toJSONString(httpParams), StandardCharsets.UTF_8);
|
||||||
HttpClient httpClient = new IgnoreVerifyHttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
HttpGet httpGet = new HttpGet(httpUrl);
|
HttpGet httpGet = new HttpGet(httpUrl);
|
||||||
httpGet.addHeader("bsm-token", this.getToken());
|
httpGet.addHeader("bsm-token", this.getToken());
|
||||||
CloseableHttpResponse httpResponse = httpClient.getHttpClient().execute(httpGet);
|
CloseableHttpResponse httpResponse = httpClient.getHttpClient().execute(httpGet);
|
||||||
|
@ -107,7 +95,6 @@ public class CmpInternetService {
|
||||||
Assert.isTrue(httpCode == 200, httpBody);
|
Assert.isTrue(httpCode == 200, httpBody);
|
||||||
return JSON.parseObject(httpBody, GeneralResult.class);
|
return JSON.parseObject(httpBody, GeneralResult.class);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
return new GeneralResult<>(false, e.getMessage());
|
return new GeneralResult<>(false, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.bocloud.cop.service.internal;
|
|
||||||
|
|
||||||
import com.megatron.common.http.ConnectionManagerHolder;
|
|
||||||
import com.megatron.common.http.HttpClient;
|
|
||||||
import org.apache.http.client.config.RequestConfig;
|
|
||||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
|
||||||
import org.apache.http.ssl.SSLContextBuilder;
|
|
||||||
|
|
||||||
public class IgnoreVerifyHttpClient extends HttpClient {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void init() {
|
|
||||||
try {
|
|
||||||
this.config = RequestConfig.custom().setSocketTimeout(getTimeout()).setConnectTimeout(getTimeout()).setProxy(this.proxy).setCookieSpec("standard-strict").build();
|
|
||||||
this.httpClient = HttpClientBuilder.create()
|
|
||||||
.setSSLContext(new SSLContextBuilder().loadTrustMaterial((chain, authType) -> true).build())
|
|
||||||
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
|
|
||||||
.setConnectionManager(ConnectionManagerHolder.getConnectionManager())
|
|
||||||
.setConnectionManagerShared(true)
|
|
||||||
.setDefaultRequestConfig(this.config).build();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("IgnoreVerifyHttpClient init error", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue