1. 修复 databus 在多层嵌套的 json 报文,签名存在异常的 bug
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.zt.plat.framework.common.util.security;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.zt.plat.framework.common.util.json.JsonUtils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
@@ -126,7 +127,11 @@ public final class CryptoSignatureUtils {
|
||||
continue;
|
||||
}
|
||||
sb.append(key).append('=');
|
||||
if (value instanceof String || value instanceof Number || value instanceof Boolean) {
|
||||
sb.append(value);
|
||||
} else {
|
||||
sb.append(JsonUtils.toJsonString(value));
|
||||
}
|
||||
sb.append('&');
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
|
||||
@@ -286,8 +286,7 @@ public class GatewaySecurityFilter extends OncePerRequestFilter {
|
||||
try {
|
||||
boolean valid = CryptoSignatureUtils.verifySignature(signaturePayload, signatureType);
|
||||
if (!valid) {
|
||||
log.error("[API-PORTAL] 签名校验失败");
|
||||
return;
|
||||
throw new SecurityValidationException(HttpStatus.UNAUTHORIZED, "签名校验失败");
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new SecurityValidationException(HttpStatus.INTERNAL_SERVER_ERROR, "签名算法配置异常");
|
||||
|
||||
Reference in New Issue
Block a user