|
@@ -69,7 +69,7 @@ public class HuaTaiRequestApiComponents {
|
|
|
String busReqString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
String busReqString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
|
InsuranceLog.infoLog(InsuranceEnum.HTIC.getPinyin(), "\n\t---------> URl: {} \n---------> 请求参数:{}", url, busReqString);
|
|
InsuranceLog.infoLog(InsuranceEnum.HTIC.getPinyin(), "\n\t---------> URl: {} \n---------> 请求参数:{}", url, busReqString);
|
|
|
// ----加密starting------------
|
|
// ----加密starting------------
|
|
|
- //1.先获取16位随机字符串 Key
|
|
|
|
|
|
|
+ /* //1.先获取16位随机字符串 Key
|
|
|
String key=generateRadomStr(8);
|
|
String key=generateRadomStr(8);
|
|
|
//2.使用Base64加密请求报文
|
|
//2.使用Base64加密请求报文
|
|
|
String base64ReqJson=Base64Utils.getBase64Encode(busReqString);
|
|
String base64ReqJson=Base64Utils.getBase64Encode(busReqString);
|
|
@@ -83,17 +83,22 @@ public class HuaTaiRequestApiComponents {
|
|
|
throw new SystemException("RSA加密获取accessToken失败!");
|
|
throw new SystemException("RSA加密获取accessToken失败!");
|
|
|
}
|
|
}
|
|
|
HuaTaiEncryptReq encryptReq=new HuaTaiEncryptReq();
|
|
HuaTaiEncryptReq encryptReq=new HuaTaiEncryptReq();
|
|
|
|
|
+ encryptReq.setInsuredCode(properties.getInsuredCode());
|
|
|
|
|
+ encryptReq.setSourceCode("016");
|
|
|
encryptReq.setBusiContent(busiContent);
|
|
encryptReq.setBusiContent(busiContent);
|
|
|
encryptReq.setAccessToken(accessToken);
|
|
encryptReq.setAccessToken(accessToken);
|
|
|
String jsonString = JSON.toJSONString(encryptReq, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
String jsonString = JSON.toJSONString(encryptReq, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
|
InsuranceLog.infoLog(InsuranceEnum.HTIC.getPinyin(), "\n\t---------> 加密后的参数:{}", jsonString);
|
|
InsuranceLog.infoLog(InsuranceEnum.HTIC.getPinyin(), "\n\t---------> 加密后的参数:{}", jsonString);
|
|
|
|
|
+ HttpEntity<String> httpEntity = new HttpEntity<>(jsonString, httpHeaders);*/
|
|
|
//----加密endding------------
|
|
//----加密endding------------
|
|
|
- HttpEntity<String> httpEntity = new HttpEntity<>(jsonString, httpHeaders);
|
|
|
|
|
|
|
+ //不加密
|
|
|
|
|
+ HttpEntity<String> httpEntity = new HttpEntity<>(busReqString, httpHeaders);
|
|
|
ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
|
|
ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
|
|
|
- String body = response.getBody();
|
|
|
|
|
|
|
+ String body = response.getBody();
|
|
|
|
|
+
|
|
|
InsuranceLog.infoLog(InsuranceEnum.HTIC.getPinyin(), "\n\t---------> 解密前的参数:{}", body);
|
|
InsuranceLog.infoLog(InsuranceEnum.HTIC.getPinyin(), "\n\t---------> 解密前的参数:{}", body);
|
|
|
// ------解密starting---------
|
|
// ------解密starting---------
|
|
|
- HuaTaiEncryptRes encryptRes=JSON.parseObject(body,HuaTaiEncryptRes.class);
|
|
|
|
|
|
|
+ /*HuaTaiEncryptRes encryptRes=JSON.parseObject(body,HuaTaiEncryptRes.class);
|
|
|
//1.通过自己的私钥对key进行解密
|
|
//1.通过自己的私钥对key进行解密
|
|
|
String resAccessToken="";
|
|
String resAccessToken="";
|
|
|
try{
|
|
try{
|
|
@@ -105,9 +110,11 @@ public class HuaTaiRequestApiComponents {
|
|
|
String aseDecryptStr=AESUtilsWithDataBase.decryptECBPK5Hex(encryptRes.getBusiContent(),resAccessToken);
|
|
String aseDecryptStr=AESUtilsWithDataBase.decryptECBPK5Hex(encryptRes.getBusiContent(),resAccessToken);
|
|
|
//3.使用Base64解密最终返回报文
|
|
//3.使用Base64解密最终返回报文
|
|
|
String text = Base64Utils.getBase64Encode(aseDecryptStr);
|
|
String text = Base64Utils.getBase64Encode(aseDecryptStr);
|
|
|
- InsuranceLog.infoLog(InsuranceEnum.HTIC.getPinyin(), "\n\t---------> {}:{}", "响应参数", text);
|
|
|
|
|
- S t= JSON.parseObject(text, tClass);
|
|
|
|
|
|
|
+ S t= JSON.parseObject(text, tClass);*/
|
|
|
// ------解密ending---------
|
|
// ------解密ending---------
|
|
|
|
|
+ InsuranceLog.infoLog(InsuranceEnum.HTIC.getPinyin(), "\n\t---------> {}:{}", "响应参数", body);
|
|
|
|
|
+ //不加密
|
|
|
|
|
+ S t= JSON.parseObject(body, tClass);
|
|
|
if (ObjectUtils.isEmpty(t)) {
|
|
if (ObjectUtils.isEmpty(t)) {
|
|
|
throw new SystemException("请求失败");
|
|
throw new SystemException("请求失败");
|
|
|
}
|
|
}
|
|
@@ -124,11 +131,6 @@ public class HuaTaiRequestApiComponents {
|
|
|
*/
|
|
*/
|
|
|
private <Q extends HuaTaiBaseRequest, S extends HuaTaiBaseResponse> S request(Q request, Class<S> tClass, boolean verify, String domain, String urlInterface) {
|
|
private <Q extends HuaTaiBaseRequest, S extends HuaTaiBaseResponse> S request(Q request, Class<S> tClass, boolean verify, String domain, String urlInterface) {
|
|
|
String url = domain;
|
|
String url = domain;
|
|
|
- if (StringUtils.isNotEmpty(urlInterface)) {
|
|
|
|
|
- url = url + urlInterface + ".do";
|
|
|
|
|
- } else {
|
|
|
|
|
- url = url + request.getHead().getTransCode() + ".do";
|
|
|
|
|
- }
|
|
|
|
|
S response = post(request, url, tClass);
|
|
S response = post(request, url, tClass);
|
|
|
if (verify) {
|
|
if (verify) {
|
|
|
validationResults(response);
|
|
validationResults(response);
|