|
@@ -54,28 +54,30 @@ public class BoHaiRequestApiComponent {
|
|
|
private <Q extends BoHaiBaseRequest, S extends BoHaiBaseResponse> S post(Q q, String url, Class<S> tClass) throws Exception {
|
|
private <Q extends BoHaiBaseRequest, S extends BoHaiBaseResponse> S post(Q q, String url, Class<S> tClass) throws Exception {
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
+
|
|
|
String busReqString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
String busReqString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
|
InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> URl: {} \n---------> 请求参数:{}", url, busReqString);
|
|
InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> URl: {} \n---------> 请求参数:{}", url, busReqString);
|
|
|
-
|
|
|
|
|
BoHaiEncrypted boHaiEncrypted = new BoHaiEncrypted(busReqString, properties);
|
|
BoHaiEncrypted boHaiEncrypted = new BoHaiEncrypted(busReqString, properties);
|
|
|
String json = JSON.toJSONString(boHaiEncrypted, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
String json = JSON.toJSONString(boHaiEncrypted, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
|
-
|
|
|
|
|
- // 获取请求头
|
|
|
|
|
|
|
+ // 获取请求头signature 和加密后的内容
|
|
|
Map<String, String> stringStringMap = SignatureUtils.encryptAndSign(properties.getSelfPrivateKey(),
|
|
Map<String, String> stringStringMap = SignatureUtils.encryptAndSign(properties.getSelfPrivateKey(),
|
|
|
properties.getBoHaiPublicKey(), json, true, true);
|
|
properties.getBoHaiPublicKey(), json, true, true);
|
|
|
String signature = stringStringMap.get("signature");
|
|
String signature = stringStringMap.get("signature");
|
|
|
String content = stringStringMap.get("content");
|
|
String content = stringStringMap.get("content");
|
|
|
httpHeaders.set("signature", signature);
|
|
httpHeaders.set("signature", signature);
|
|
|
- InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 加密后的参数:{}", content);
|
|
|
|
|
- InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 加密后的参数:{}", signature);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 加密后的参数:{} \n\t---------> 请求头内容signature:{}", content,
|
|
|
|
|
+ signature);
|
|
|
|
|
+ // 请求
|
|
|
HttpEntity<String> httpEntity = new HttpEntity<>(content, httpHeaders);
|
|
HttpEntity<String> httpEntity = new HttpEntity<>(content, httpHeaders);
|
|
|
- //----加密endding------------
|
|
|
|
|
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.BPIC.getPinyin(), "\n\t---------> 解密前的参数:{}", body);
|
|
InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 解密前的参数:{}", body);
|
|
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ // 解密响应
|
|
|
|
|
+ BoHaiEncrypted encrypted = JSON.parseObject(body).toJavaObject(BoHaiEncrypted.class);
|
|
|
|
|
+ String info = SignatureUtils.decryptByPrivateKey(encrypted.getBizContent(), properties.getSelfPrivateKey());
|
|
|
|
|
+ InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 解密后的参数:{}", info);
|
|
|
|
|
+ return JSON.parseObject(body).toJavaObject(tClass);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -84,22 +86,30 @@ public class BoHaiRequestApiComponent {
|
|
|
*
|
|
*
|
|
|
* @param request 生成订单号请求实体
|
|
* @param request 生成订单号请求实体
|
|
|
* @return 返回订单号响应
|
|
* @return 返回订单号响应
|
|
|
- * @throws Exception
|
|
|
|
|
*/
|
|
*/
|
|
|
public GenerateOrderNoResponse generateOrderNo(GenerateOrderNoRequest request) throws Exception {
|
|
public GenerateOrderNoResponse generateOrderNo(GenerateOrderNoRequest request) throws Exception {
|
|
|
return post(request, properties.getUrl(), GenerateOrderNoResponse.class);
|
|
return post(request, properties.getUrl(), GenerateOrderNoResponse.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public VehicleTypeQueryResponse vehicleTypeQuery(VehicleTypeQueryRequest request) throws Exception{
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 车辆查询
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request 车辆查询请求实体
|
|
|
|
|
+ * @return 响应
|
|
|
|
|
+ */
|
|
|
|
|
+ public VehicleTypeQueryResponse vehicleTypeQuery(VehicleTypeQueryRequest request) throws Exception {
|
|
|
return post(request, properties.getUrl(), VehicleTypeQueryResponse.class);
|
|
return post(request, properties.getUrl(), VehicleTypeQueryResponse.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public VehicleConfirmationResponse vehicleConfirmation(VehicleConfirmationReqeust request) throws Exception{
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 车辆确认
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request 车辆确认 请求实体
|
|
|
|
|
+ * @return 响应
|
|
|
|
|
+ */
|
|
|
|
|
+ public VehicleConfirmationResponse vehicleConfirmation(VehicleConfirmationReqeust request) throws Exception {
|
|
|
return post(request, properties.getUrl(), VehicleConfirmationResponse.class);
|
|
return post(request, properties.getUrl(), VehicleConfirmationResponse.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|