feat:验签日志
This commit is contained in:
@@ -6,7 +6,6 @@ import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.utils.OpenSignatureUtil;
|
||||
import com.cool.store.utils.StringUtil;
|
||||
import com.cool.store.utils.UUIDUtils;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@@ -25,9 +24,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 接口映射 红圈通系统使用新验签, 云流水,新管家等使用旧的验签模式
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/4/5 18:11
|
||||
* @Version 1.0
|
||||
@@ -43,7 +42,6 @@ public class OpenApiValidateFilter implements Filter {
|
||||
private String coolAppKey;
|
||||
@Value("${cool.api.secret}")
|
||||
private String coolAppSecret;
|
||||
// 接口映射 除了红圈通系统,云流水,新管家等使用旧的验签模式
|
||||
private static final List<String> oldUrlMapping = new ArrayList<>(Arrays.asList(
|
||||
"/zxjp/open/v1/statusRefresh","/zxjp/open/v1/changePaymentStatus",
|
||||
"/zxjp/open/v1/getYlsToken", "/zxjp/open/v1/getStoreList",
|
||||
@@ -83,7 +81,7 @@ public class OpenApiValidateFilter implements Filter {
|
||||
long currentTime = System.currentTimeMillis() / 1000;
|
||||
long timeDiff = Math.abs(currentTime - timestamp);
|
||||
try {
|
||||
if (timeDiff > 1600) {
|
||||
if (timeDiff > 600) {
|
||||
log.info("OpenApiValidateFilter==>{}","请求已过期,服务器时间:" + currentTime + " 请求时间:" + timestamp);
|
||||
throw new ServiceException(ErrorCodeEnum.SIGN_FAIL,"请求已过期,请保证timestamp时间在10分钟之内");
|
||||
}
|
||||
@@ -126,6 +124,7 @@ public class OpenApiValidateFilter implements Filter {
|
||||
|
||||
String jsonBody = requestBody.toString();
|
||||
String serverSign;
|
||||
//接口映射 红圈通系统使用新验签, oldUrlMapping接口使用旧的验签模式 后续新增接口都使用新验签
|
||||
if (oldUrlMapping.contains(uri)) {
|
||||
serverSign = getOldSign(jsonBody, appKey, timestampStr);
|
||||
} else {
|
||||
@@ -158,7 +157,6 @@ public class OpenApiValidateFilter implements Filter {
|
||||
params.put("appKey", appKey);
|
||||
params.put("timestamp", timestampStr);
|
||||
|
||||
|
||||
return OpenSignatureUtil.generateSign(params, coolAppSecret);
|
||||
}
|
||||
|
||||
@@ -173,7 +171,6 @@ public class OpenApiValidateFilter implements Filter {
|
||||
params.put("appKey", appKey);
|
||||
params.put("timestamp", timestampStr);
|
||||
|
||||
|
||||
return OpenSignatureUtil.generateOldSign(params, coolAppSecret);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user