记得上下班打卡 | git大法好,push需谨慎

Commit 0fdf2daf authored by anjiabin's avatar anjiabin

下单请求加密增加日志

parent b2f289ac
package com.liquidnet.service.base.codec.aspect; package com.liquidnet.service.base.codec.aspect;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.liquidnet.common.exception.constant.ErrorCode;
import com.liquidnet.commons.lang.util.JsonUtils; import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.codec.annotation.DecryptAndVerify; import com.liquidnet.service.base.codec.annotation.DecryptAndVerify;
import com.liquidnet.service.base.codec.exception.DecryptAndVerifyException; import com.liquidnet.service.base.codec.exception.DecryptAndVerifyException;
...@@ -31,7 +32,7 @@ public class DecryptAndVerifyAspect { ...@@ -31,7 +32,7 @@ public class DecryptAndVerifyAspect {
public Object around(ProceedingJoinPoint joinPoint) throws Throwable { public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
Object[] args = joinPoint.getArgs(); Object[] args = joinPoint.getArgs();
if (args == null || args.length == 0) { if (args == null || args.length == 0) {
throw new DecryptAndVerifyException(joinPoint.getSignature().getName() + ",参数为空"); throw new DecryptAndVerifyException(ErrorCode.HTTP_PARAM_ERROR.getCode(),joinPoint.getSignature().getName() + ",参数为空");
} }
EncryptedReq encryptedReq = null; EncryptedReq encryptedReq = null;
for (Object obj : args) { for (Object obj : args) {
...@@ -41,7 +42,7 @@ public class DecryptAndVerifyAspect { ...@@ -41,7 +42,7 @@ public class DecryptAndVerifyAspect {
} }
} }
if (encryptedReq == null) { if (encryptedReq == null) {
throw new DecryptAndVerifyException(joinPoint.getSignature().getName() + ",参数中无待解密类"); throw new DecryptAndVerifyException(ErrorCode.HTTP_PARAM_ERROR.getCode(),joinPoint.getSignature().getName() + ",参数中无待解密类");
} }
log.info("DecryptAndVerifyAspect 解密前 下单request:{}", JsonUtils.toJson(encryptedReq)); log.info("DecryptAndVerifyAspect 解密前 下单request:{}", JsonUtils.toJson(encryptedReq));
String decryptedData = decryptAndVerify(encryptedReq); String decryptedData = decryptAndVerify(encryptedReq);
...@@ -49,7 +50,7 @@ public class DecryptAndVerifyAspect { ...@@ -49,7 +50,7 @@ public class DecryptAndVerifyAspect {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
DecryptAndVerify annotation = methodSignature.getMethod().getAnnotation(DecryptAndVerify.class); DecryptAndVerify annotation = methodSignature.getMethod().getAnnotation(DecryptAndVerify.class);
if (annotation == null || annotation.decryptedClass() == null) { if (annotation == null || annotation.decryptedClass() == null) {
throw new DecryptAndVerifyException(joinPoint.getSignature().getName() + ",未指定解密类型"); throw new DecryptAndVerifyException(ErrorCode.HTTP_PARAM_ERROR.getCode(),joinPoint.getSignature().getName() + ",未指定解密类型");
} }
encryptedReq.setData(JSON.parseObject(decryptedData, annotation.decryptedClass())); encryptedReq.setData(JSON.parseObject(decryptedData, annotation.decryptedClass()));
return joinPoint.proceed(); return joinPoint.proceed();
...@@ -60,7 +61,7 @@ public class DecryptAndVerifyAspect { ...@@ -60,7 +61,7 @@ public class DecryptAndVerifyAspect {
if (sign.equals(encryptedReq.getSign())) { if (sign.equals(encryptedReq.getSign())) {
return CodecUtil.aesDecrypt(encryptedReq.getEncryptedData()); return CodecUtil.aesDecrypt(encryptedReq.getEncryptedData());
} else { } else {
throw new DecryptAndVerifyException("验签失败:" + JSON.toJSONString(encryptedReq)); throw new DecryptAndVerifyException(ErrorCode.HTTP_PARAM_ERROR.getCode(),"验签失败:");
} }
} }
} }
package com.liquidnet.service.base.codec.exception; package com.liquidnet.service.base.codec.exception;
import com.liquidnet.common.exception.LiquidnetServiceException;
/** /**
* @description: 解密验证异常 * @description: 解密验证异常
* @author: DFY * @author: DFY
* @time: 2020/3/30 13:58 * @time: 2020/3/30 13:58
*/ */
public class DecryptAndVerifyException extends RuntimeException { public class DecryptAndVerifyException extends LiquidnetServiceException {
public DecryptAndVerifyException(String message) { public DecryptAndVerifyException(String code,String message) {
super(message); super(code,message);
} }
} }
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