|
@@ -104,10 +104,10 @@ public class FileSECUtils {
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
- logger.info("SEC附件 ERR content1: " + e.getMessage());
|
|
|
+ logger.info("SEC附件检查是否明文 ERR content1: " + e.getMessage());
|
|
|
} catch (Exception e1){
|
|
|
e1.printStackTrace();
|
|
|
- logger.info("SEC附件 ERR content2: " + e1.getMessage());
|
|
|
+ logger.info("SEC附件检查是否明文 ERR content2: " + e1.getMessage());
|
|
|
}
|
|
|
return -1;
|
|
|
}
|
|
@@ -137,16 +137,15 @@ public class FileSECUtils {
|
|
|
post.setEntity(entity);
|
|
|
|
|
|
httpclient = buildSSLCloseableHttpClient();
|
|
|
+ logger.info("--------------SEC附件 httpclient.execute(post) ----------------");
|
|
|
CloseableHttpResponse response = httpclient.execute(post);
|
|
|
String result = response.getFirstHeader("data~returnFlag").getValue();
|
|
|
-
|
|
|
+ logger.info("--------------SEC附件检查文件返回 "+result+" ----------------");
|
|
|
// 获取响应状态码
|
|
|
if("0".equals(result)){//1表示秘文
|
|
|
InputStream ins = response.getEntity().getContent();
|
|
|
- logger.info("SEC附件加密成功: " + result);
|
|
|
return ins;
|
|
|
}else{
|
|
|
- logger.debug("SEC附件加密失败: " + result);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -183,16 +182,15 @@ public class FileSECUtils {
|
|
|
post.setEntity(entity);
|
|
|
|
|
|
httpclient = buildSSLCloseableHttpClient();
|
|
|
+ logger.info("--------------SEC附件 httpclient.execute(post) ----------------");
|
|
|
CloseableHttpResponse response = httpclient.execute(post);
|
|
|
String result = response.getFirstHeader("data~returnFlag").getValue();
|
|
|
-
|
|
|
+ logger.info("--------------SEC附件解密返回 "+result+" ----------------");
|
|
|
// 获取响应状态码
|
|
|
if("0".equals(result)){//1表示秘文
|
|
|
InputStream ins = response.getEntity().getContent();
|
|
|
- logger.info("SEC附件解密成功: " + result);
|
|
|
return ins;
|
|
|
}else{
|
|
|
- logger.info("SEC附件解密失败: " + result);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -207,15 +205,18 @@ public class FileSECUtils {
|
|
|
}
|
|
|
|
|
|
private static CloseableHttpClient buildSSLCloseableHttpClient() throws Exception {
|
|
|
+ logger.info("--------------SEC附件 buildSSLCloseableHttpClient1 ----------------");
|
|
|
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
|
|
|
// 信任所有
|
|
|
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
|
|
return true;
|
|
|
}
|
|
|
}).build();
|
|
|
+ logger.info("--------------SEC附件 buildSSLCloseableHttpClient2 ----------------");
|
|
|
// ALLOW_ALL_HOSTNAME_VERIFIER:这个主机名验证器基本上是关闭主机名验证的,实现的是一个空操作,并且不会抛出javax.net.ssl.SSLException异常。
|
|
|
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new String[] { "TLSv1" }, null,
|
|
|
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
|
|
+ logger.info("--------------SEC附件 buildSSLCloseableHttpClient3 ----------------");
|
|
|
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
|
|
|
}
|
|
|
|