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

Commit 0fdf2daf authored by anjiabin's avatar anjiabin

下单请求加密增加日志

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