|
@ -1,15 +1,24 @@
|
|
|
package com.yihu.wlyy.service.service.prescription;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.wlyy.service.common.SystemConfig;
|
|
|
import com.yihu.wlyy.service.common.http.HttpApiException;
|
|
|
import com.yihu.wlyy.service.common.util.StringUtil;
|
|
|
import com.yihu.wlyy.service.common.util.WebserviceUtil;
|
|
|
import com.yihu.wlyy.service.service.LogService;
|
|
|
import com.yihu.wlyy.service.service.ZysoftApi;
|
|
|
import com.yihu.wlyy.service.service.ZysoftBaseService;
|
|
|
import com.zoe.phip.ssp.sdk.ApiException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.PrintWriter;
|
|
|
import java.io.StringWriter;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
/**
|
|
@ -17,7 +26,7 @@ import java.util.Map;
|
|
|
* 长处方CA认证服务
|
|
|
*/
|
|
|
@Service
|
|
|
public class PrescriptionCAService {
|
|
|
public class PrescriptionCAService extends ZysoftBaseService {
|
|
|
|
|
|
private String IS_APPLIED="XMCAF_SOFT_judgeRealNameSoftCertIsApplied"; //判断实名软证书是否已申请
|
|
|
private String REQUEST_SIGN = "XMCAF_SOFT_requestRealNameSoftCertAndSign";//请求实名软证书并进行数字签名
|
|
@ -32,7 +41,7 @@ public class PrescriptionCAService {
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
private String getHeaderXml(String api,String srcBusinessStreamNO)
|
|
|
private String getHeaderXml(String api,String srcBusinessStreamNO,String srcRequestStreamNO)
|
|
|
{
|
|
|
return "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
|
|
"<root>\n" +
|
|
@ -49,12 +58,96 @@ public class PrescriptionCAService {
|
|
|
" <srcBusinessNodeName>审核</srcBusinessNodeName>\n" +
|
|
|
" <srcOperatorAccount>"+srcBusinessStreamNO+"</srcOperatorAccount>\n" +
|
|
|
" <srcBusinessStreamNO>"+srcBusinessStreamNO+"</srcBusinessStreamNO>\n" +
|
|
|
" <srcRequestStreamNO>"+srcRequestStreamNO+"</srcRequestStreamNO>\n" +
|
|
|
" <srcDataExtProperty></srcDataExtProperty>\n" +
|
|
|
"</root>";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* CA认证服务二次封装
|
|
|
* 生产环境 智业CA接口二次封装
|
|
|
* @param api
|
|
|
* @param params
|
|
|
* @param srcBusinessStreamNO
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String postZyCaServer(String api, Map<String,String> params,String srcBusinessStreamNO,String content) throws Exception{
|
|
|
|
|
|
|
|
|
String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
|
|
"<root>\n";
|
|
|
if(params!=null && params.size()>0)
|
|
|
{
|
|
|
for(String key : params.keySet())
|
|
|
{
|
|
|
msgBody += " <"+key+">"+params.get(key)+"</"+key+">\n";
|
|
|
}
|
|
|
}
|
|
|
msgBody += "</root>";
|
|
|
String srcRequestStreamNO = UUID.randomUUID().toString().replace("-", "");
|
|
|
String msgHeader = getHeaderXml(api,srcBusinessStreamNO,srcRequestStreamNO);
|
|
|
|
|
|
System.out.println("msgHerder:"+msgHeader);
|
|
|
System.out.println("msgBody:"+msgBody);
|
|
|
|
|
|
String re = "";
|
|
|
Map<String,String> paramsList = new HashMap<>();
|
|
|
paramsList.put("msgHeader",msgHeader);
|
|
|
paramsList.put("msgBody",msgBody);
|
|
|
|
|
|
|
|
|
//新增日志
|
|
|
String method = "POST";
|
|
|
Boolean isSuccess = true;
|
|
|
String error = "";
|
|
|
|
|
|
int times = 0;
|
|
|
try {
|
|
|
// re = ZysoftApi.getSingleton().post(ca_url, paramsList, null,true);
|
|
|
re = ZysoftApi.getSingleton().capost(paramsList, null,true);
|
|
|
|
|
|
System.out.println("re=====>:"+re);
|
|
|
// Map<String,String> map = objectMapper.readValue(re,Map.class);
|
|
|
// String code = map.get("CODE");
|
|
|
//
|
|
|
// if(!code.equals("1"))
|
|
|
// {
|
|
|
// throw new HttpApiException(Integer.valueOf(code),map.get("MESSAGE"));
|
|
|
// }
|
|
|
|
|
|
//保存http日志
|
|
|
logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
StringWriter sw = new StringWriter();
|
|
|
PrintWriter pw = new PrintWriter(sw);
|
|
|
ex.printStackTrace(pw);
|
|
|
System.out.println("error1:"+ex.getMessage());
|
|
|
error = sw.toString();
|
|
|
System.out.println("error2:"+error);
|
|
|
|
|
|
//保存http日志
|
|
|
logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
|
|
|
|
|
|
if(ex instanceof ApiException)
|
|
|
{
|
|
|
ApiException apiEx = (ApiException) ex;
|
|
|
System.out.println("error3:"+ex.getMessage());
|
|
|
throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
|
|
|
}
|
|
|
else{
|
|
|
System.out.println("error4:"+ex.getMessage());
|
|
|
throw new HttpApiException(-1,ex.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return re;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 测试环境:CA认证服务二次封装
|
|
|
*/
|
|
|
private String postCAServer(String api, Map<String,String> params,String srcBusinessStreamNO) throws Exception
|
|
|
{
|
|
@ -73,8 +166,8 @@ public class PrescriptionCAService {
|
|
|
}
|
|
|
|
|
|
msgBody += "</root>";
|
|
|
|
|
|
String msgHeader = getHeaderXml(api,srcBusinessStreamNO);
|
|
|
String srcRequestStreamNO = UUID.randomUUID().toString().replace("-", "");
|
|
|
String msgHeader = getHeaderXml(api,srcBusinessStreamNO,srcRequestStreamNO);
|
|
|
|
|
|
Map<String,String> p = new HashMap<>();
|
|
|
p.put("msgHeader",msgHeader);
|
|
@ -98,7 +191,9 @@ public class PrescriptionCAService {
|
|
|
params.put("strUserIdcardNum",strUserIdcardNum);
|
|
|
|
|
|
body = objectMapper.writeValueAsString(params);
|
|
|
re = postCAServer(action, params,srcBusinessStreamNO);
|
|
|
// re = postCAServer(action, params,srcBusinessStreamNO);
|
|
|
//生产环境,调用智业统一平台接口,rest接口
|
|
|
re = postZyCaServer(action, params,srcBusinessStreamNO,"判断是否有实名证书");
|
|
|
|
|
|
if(StringUtil.isEmpty(re))
|
|
|
{
|
|
@ -147,7 +242,10 @@ public class PrescriptionCAService {
|
|
|
|
|
|
|
|
|
body = objectMapper.writeValueAsString(params);
|
|
|
re = postCAServer(action, params,srcBusinessStreamNO);
|
|
|
//测试环境开启下面这行代码,webservice接口
|
|
|
// re = postCAServer(action, params,srcBusinessStreamNO);
|
|
|
//生产环境,调用智业统一平台接口,rest接口
|
|
|
re = postZyCaServer(action, params,srcBusinessStreamNO,"请求实名软证书并进行数字签名");
|
|
|
|
|
|
if(StringUtil.isEmpty(re))
|
|
|
{
|
|
@ -196,8 +294,9 @@ public class PrescriptionCAService {
|
|
|
|
|
|
body = objectMapper.writeValueAsString(params);
|
|
|
|
|
|
re = postCAServer(action, params,srcBusinessStreamNO);
|
|
|
// re = postCAServer(action, params,srcBusinessStreamNO);
|
|
|
|
|
|
re = postZyCaServer(action, params,srcBusinessStreamNO,"获取实名软证书的过期时间");
|
|
|
if(StringUtil.isEmpty(re))
|
|
|
{
|
|
|
throw new Exception("返回为空!");
|
|
@ -244,7 +343,8 @@ public class PrescriptionCAService {
|
|
|
params.put("strNewCalledPasswd",strNewCalledPasswd);
|
|
|
|
|
|
body = objectMapper.writeValueAsString(params);
|
|
|
re = postCAServer(action, params,srcBusinessStreamNO);
|
|
|
// re = postCAServer(action, params,srcBusinessStreamNO);
|
|
|
re = postZyCaServer(action, params,srcBusinessStreamNO,"修改实名软证书调用保护口令");
|
|
|
|
|
|
if(StringUtil.isEmpty(re))
|
|
|
{
|
|
@ -297,8 +397,8 @@ public class PrescriptionCAService {
|
|
|
params.put("strOriginalData",strOriginalData);
|
|
|
|
|
|
body = objectMapper.writeValueAsString(params);
|
|
|
re = postCAServer(action, params,srcBusinessStreamNO);
|
|
|
|
|
|
// re = postCAServer(action, params,srcBusinessStreamNO);
|
|
|
re = postZyCaServer(action, params,srcBusinessStreamNO,"验证签名(带多服务器负载均衡)");
|
|
|
if(StringUtil.isEmpty(re))
|
|
|
{
|
|
|
throw new Exception("返回为空!");
|