Commit bf51de7b authored by hongguangwu's avatar hongguangwu

MVP1.7.16-法大大

parent e73ddb98
......@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fadada.api.utils.crypt.FddCryptUtil;
import com.fasc.open.api.constants.RequestConstants;
import com.fasc.open.api.exception.ApiException;
......@@ -16,6 +17,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -27,6 +29,8 @@ import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
import static com.alibaba.fastjson.serializer.SerializerFeature.*;
/**
* @auther huyc
* @date 2022/6/29
......@@ -135,21 +139,26 @@ public class FascController {
return "{\"code\":\"200\";\"msg\":\"success\"}";
}*/
private static final SerializerFeature[] features = new SerializerFeature[]{
WriteMapNullValue, WriteNullNumberAsZero, WriteNullListAsEmpty,
WriteNullStringAsEmpty, WriteDateUseDateFormat
};
@Operation(summary = "异步通知", description = "异步通知")
@RequestMapping(value = "/api/fascCallback")
public R<String> notifyUrl(HttpServletRequest request, HttpServletResponse response) throws Exception {
// 新增推送日志
TFascPushLog pushLog = new TFascPushLog();
pushLog.setTransReferenceId(fascConfig.getOpenId());
pushLog.setReturnData(JSON.toJSONString(request));
pushLog.setTaskStatus(CommonConstants.ONE_STRING);
pushLog.setTypeKey("签署任务事件,异步通知");
pushLog.setTypeName("签署任务事件,异步通知");
tFascPushLogService.save(pushLog);
if (checkSign(request)) {
if (checkSign(request, pushLog)) {
return R.failed("验签失败");
}
tFascPushLogService.updateById(pushLog);
String fddEvent = request.getHeader(FASC_EVENT);
String fddBizContent = request.getParameter(FASC_BIZ_CONTENT);
if (Common.isNotNull(fddEvent)) {
......@@ -173,13 +182,14 @@ public class FascController {
pushLog.setReturnData("签署任务作废事件:fddEvent:" + fddEvent + ";fddBizContent:" + fddBizContent);
return R.ok(null, "success");
}
}
tFascPushLogService.updateById(pushLog);
}
return R.ok(null, "success");
}
//验证签名,返回true表示失败
public boolean checkSign(HttpServletRequest request) throws Exception {
public boolean checkSign(HttpServletRequest request, TFascPushLog pushLog) throws Exception {
Map<String, String> paraMap = new HashMap<>();
paraMap.put(RequestConstants.APP_ID, request.getHeader(RequestConstants.APP_ID));
......@@ -190,8 +200,13 @@ public class FascController {
paraMap.put(FASC_BIZ_CONTENT, request.getParameter(FASC_BIZ_CONTENT));
//参数排序,ascii码排序
String sortParam = FddCryptUtil.sortParameters(paraMap);
String timeStamp = request.getHeader(RequestConstants.TIMESTAMP);
pushLog.setReturnData(sortParam);
//计算之后得到签名 该签名需要放到请求头
String signature = FddCryptUtil.sign(sortParam, request.getHeader(RequestConstants.TIMESTAMP), fascConfig.getAppSecret());
if (Common.isEmpty(sortParam) || Common.isEmpty(timeStamp)) {
return true;
}
String signature = FddCryptUtil.sign(sortParam, timeStamp, fascConfig.getAppSecret());
if (StringUtils.equals(signature, request.getHeader(RequestConstants.SIGN))) {
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment