本文内的代码写法仅表示其基本含义,实际项目中需要做更精确的调整。
1. 基本AOP切面能力
指定切面
在每一个controller类里的接口方法内,对web前台页面传入的参数进行解密
@Before("execution(public * com.xxx.yyy.controller.*.*(..))")
public void decrypt(JoinPoint joinPoint) throws CException {
// 捕获方法参数列表
List<Object> methodArgs = AspectHelper.getMethodArgs(joinPoint);
if (methodArgs.size() == 0) {
return;
}
for (Object item : methodArgs) {
// 对参数项进行敏感字段解密处理
try {
argHandlerDecrypt.strategyhandle(item);
} catch (Exception e) {
log.error("failed to decrypt, message: ", e);
throw new CException(ErrorCode.RSA_DECRYPT_FAIL);
}
}
}
2021/4/5大约 4 分钟