|
@@ -1,161 +0,0 @@
|
|
-////
|
|
|
|
-//// Source code recreated from a .class file by IntelliJ IDEA
|
|
|
|
-//// (powered by Fernflower decompiler)
|
|
|
|
-////
|
|
|
|
-//
|
|
|
|
-//package com.huimv.farm.musk.common.utils;
|
|
|
|
-//
|
|
|
|
-//import org.apache.commons.io.IOUtils;
|
|
|
|
-//import org.apache.http.HttpResponse;
|
|
|
|
-//import org.apache.http.client.HttpClient;
|
|
|
|
-//import org.apache.http.client.config.RequestConfig;
|
|
|
|
-//import org.apache.http.client.config.RequestConfig.Builder;
|
|
|
|
-//import org.apache.http.client.methods.HttpGet;
|
|
|
|
-//import org.apache.http.client.methods.HttpPost;
|
|
|
|
-//import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
|
|
|
-//import org.apache.http.conn.ssl.TrustStrategy;
|
|
|
|
-//import org.apache.http.entity.ContentType;
|
|
|
|
-//import org.apache.http.entity.StringEntity;
|
|
|
|
-//import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
-//import org.apache.http.impl.client.HttpClients;
|
|
|
|
-//import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
|
|
|
-//import org.apache.http.ssl.SSLContextBuilder;
|
|
|
|
-//
|
|
|
|
-//import javax.net.ssl.HostnameVerifier;
|
|
|
|
-//import javax.net.ssl.SSLContext;
|
|
|
|
-//import javax.net.ssl.SSLSession;
|
|
|
|
-//import java.security.GeneralSecurityException;
|
|
|
|
-//import java.security.KeyStore;
|
|
|
|
-//import java.security.cert.CertificateException;
|
|
|
|
-//import java.security.cert.X509Certificate;
|
|
|
|
-//
|
|
|
|
-//public class HttpClientSSLUtils {
|
|
|
|
-// private static HttpClient client = null;
|
|
|
|
-// protected static final Integer DEFAULT_CONNECTION_TIME_OUT = 100000;
|
|
|
|
-// protected static final Integer DEFAULT_SOCKET_TIME_OUT = 200000;
|
|
|
|
-// protected static final String DEFAULT_CHAR_SET = "UTF-8";
|
|
|
|
-//
|
|
|
|
-// public HttpClientSSLUtils() {
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// public static String doPost(String url, String jsonText) throws Exception {
|
|
|
|
-// HttpClient client = null;
|
|
|
|
-// HttpPost post = new HttpPost(url);
|
|
|
|
-//
|
|
|
|
-// String var6;
|
|
|
|
-// try {
|
|
|
|
-// if (jsonText != null && !jsonText.isEmpty()) {
|
|
|
|
-// StringEntity entity = new StringEntity(jsonText, ContentType.APPLICATION_JSON);
|
|
|
|
-// post.setEntity(entity);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// Builder customReqConf = RequestConfig.custom();
|
|
|
|
-// customReqConf.setConnectTimeout(DEFAULT_CONNECTION_TIME_OUT);
|
|
|
|
-// customReqConf.setSocketTimeout(DEFAULT_CONNECTION_TIME_OUT);
|
|
|
|
-// post.setConfig(customReqConf.build());
|
|
|
|
-// HttpResponse res = null;
|
|
|
|
-// if (url.startsWith("https")) {
|
|
|
|
-// client = createSSLInsecureClient();
|
|
|
|
-// res = ((HttpClient)client).execute(post);
|
|
|
|
-// } else {
|
|
|
|
-// client = HttpClientSSLUtils.client;
|
|
|
|
-// res = ((HttpClient)client).execute(post);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// var6 = IOUtils.toString(res.getEntity().getContent(), "UTF-8");
|
|
|
|
-// } finally {
|
|
|
|
-// post.releaseConnection();
|
|
|
|
-// if (url.startsWith("https") && client != null && client instanceof CloseableHttpClient) {
|
|
|
|
-// ((CloseableHttpClient)client).close();
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// return var6;
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// public static String doGet(String url) throws Exception {
|
|
|
|
-// HttpClient client = null;
|
|
|
|
-// HttpGet get = new HttpGet(url);
|
|
|
|
-// String result = "";
|
|
|
|
-//
|
|
|
|
-// try {
|
|
|
|
-// Builder customReqConf = RequestConfig.custom();
|
|
|
|
-// customReqConf.setConnectTimeout(DEFAULT_CONNECTION_TIME_OUT);
|
|
|
|
-// customReqConf.setSocketTimeout(DEFAULT_CONNECTION_TIME_OUT);
|
|
|
|
-// get.setConfig(customReqConf.build());
|
|
|
|
-// HttpResponse res = null;
|
|
|
|
-// if (url.startsWith("https")) {
|
|
|
|
-// client = createSSLInsecureClient();
|
|
|
|
-// res = ((HttpClient)client).execute(get);
|
|
|
|
-// } else {
|
|
|
|
-// client = HttpClientSSLUtils.client;
|
|
|
|
-// res = ((HttpClient)client).execute(get);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// result = IOUtils.toString(res.getEntity().getContent(), "UTF-8");
|
|
|
|
-// } finally {
|
|
|
|
-// get.releaseConnection();
|
|
|
|
-// if (url.startsWith("https") && client != null && client instanceof CloseableHttpClient) {
|
|
|
|
-// ((CloseableHttpClient)client).close();
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// return result;
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// private static CloseableHttpClient createSSLInsecureClient() throws GeneralSecurityException {
|
|
|
|
-// try {
|
|
|
|
-// SSLContext sslContext = (new SSLContextBuilder()).loadTrustMaterial((KeyStore)null, new TrustStrategy() {
|
|
|
|
-// public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
|
|
|
-// return true;
|
|
|
|
-// }
|
|
|
|
-// }).build();
|
|
|
|
-// SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new HostnameVerifier() {
|
|
|
|
-// public boolean verify(String hostname, SSLSession session) {
|
|
|
|
-// return true;
|
|
|
|
-// }
|
|
|
|
-// });
|
|
|
|
-// return HttpClients.custom().setSSLSocketFactory(sslsf).build();
|
|
|
|
-// } catch (GeneralSecurityException var2) {
|
|
|
|
-// throw var2;
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-//// public static void main(String[] args) {
|
|
|
|
-//// String url = "https://10.33.39.8/webapi/service/base/getPlatAuthSubSystemList";
|
|
|
|
-//// String params = "appkey=f8524632&time=" + System.currentTimeMillis() + "&pageNo=1&pageSize=10";
|
|
|
|
-//// String urlString = url + "?" + params + "&token=" + Digests.buildToken(url + "?" + params, (String)null, "0a5a6558a06546088da645b5f9248a3a");
|
|
|
|
-////
|
|
|
|
-//// try {
|
|
|
|
-//// String output = new String(doGet(urlString));
|
|
|
|
-//// System.out.println(output);
|
|
|
|
-//// } catch (Exception var7) {
|
|
|
|
-//// var7.printStackTrace();
|
|
|
|
-//// }
|
|
|
|
-////
|
|
|
|
-//// url = "https://10.20.134.21/webapi/service/base/addPlatCard";
|
|
|
|
-//// Map<String, Object> map = new HashMap();
|
|
|
|
-//// map.put("appkey", "f8524632");
|
|
|
|
-//// map.put("time", System.currentTimeMillis());
|
|
|
|
-//// map.put("startCardNo", "16000");
|
|
|
|
-//// map.put("endCardNo", "16010");
|
|
|
|
-////// params = JsonUtils.object2Json(map);
|
|
|
|
-//// url = url + "?token=" + Digests.buildToken(url + "?" + params, (String)null, "0a5a6558a06546088da645b5f9248a3a");
|
|
|
|
-////
|
|
|
|
-//// try {
|
|
|
|
-//// System.out.println(doPost(url, params));
|
|
|
|
-//// } catch (Exception var6) {
|
|
|
|
-//// var6.printStackTrace();
|
|
|
|
-//// }
|
|
|
|
-////
|
|
|
|
-//// }
|
|
|
|
-//
|
|
|
|
-// static {
|
|
|
|
-// PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
|
|
|
|
-// cm.setMaxTotal(128);
|
|
|
|
-// cm.setDefaultMaxPerRoute(128);
|
|
|
|
-// client = HttpClients.custom().setConnectionManager(cm).build();
|
|
|
|
-// }
|
|
|
|
-//}
|
|
|