优化 非对称加密 50%(未完)

v1.4.1
Parker 4 years ago
parent a8177cf1dd
commit fe1cdc5626

@ -120,6 +120,36 @@ public class ApiCryptoAsymmetricAop {
// 1. 拆解请求数据
// request 解密
if (annotation.enable() && annotation.requestDecrypt()){
enterDecrypt(args, method, asymmetric, cryptoModel);
}
// 2. 执行方法
returnValue = point.proceed(args);
// 3. 返回响应数据
// response 加密
if (annotation.enable() && annotation.responseEncrypt()){
returnValue = resultEncrypt(returnValue, asymmetric, cryptoModel);
}
return returnValue;
}else{
returnValue = point.proceed(args);
}
return returnValue;
}
/**
*
* @param args
* @param method
* @param asymmetric
* @param cryptoModel
*/
private void enterDecrypt(Object[] args, Method method, CryptoAsymmetricService asymmetric, CryptoAsymmetric cryptoModel) {
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
// 参数校验
@ -152,16 +182,20 @@ public class ApiCryptoAsymmetricAop {
}
}
// 2. 执行方法
returnValue = point.proceed(args);
// 3. 返回响应数据
// response 加密
if (annotation.enable() && annotation.responseEncrypt()){
/**
*
* @param returnValue
* @param asymmetric
* @param cryptoModel
* @return Object
*/
private Object resultEncrypt(Object returnValue, CryptoAsymmetricService asymmetric, CryptoAsymmetric cryptoModel) {
if(returnValue != null){
try {
// 执行加密过程
if(returnValue instanceof ResultVo){
// 重新赋值 data
ResultVo<Object> ret = (ResultVo<Object>) returnValue;
ret.setData(
asymmetric.encrypt(cryptoModel, ret.getData())
@ -176,16 +210,7 @@ public class ApiCryptoAsymmetricAop {
throw new ServiceException(CoreMsg.OTHER_EXCEPTION_CRYPTO_EN);
}
}
}
return returnValue;
}else{
returnValue = point.proceed(args);
}
return returnValue;
}
// ===============================
}

Loading…
Cancel
Save