update 优化 加密模块 解密拦截器 将参数一起解密了 防止参数被多次加密不正常
This commit is contained in:
parent
83b6addbba
commit
bd88e27c82
@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.ibatis.executor.parameter.ParameterHandler;
|
||||||
import org.apache.ibatis.executor.resultset.ResultSetHandler;
|
import org.apache.ibatis.executor.resultset.ResultSetHandler;
|
||||||
import org.apache.ibatis.plugin.*;
|
import org.apache.ibatis.plugin.*;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
@ -39,12 +40,23 @@ public class MybatisDecryptInterceptor implements Interceptor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object intercept(Invocation invocation) throws Throwable {
|
public Object intercept(Invocation invocation) throws Throwable {
|
||||||
|
// 开始进行参数解密
|
||||||
|
ResultSetHandler resultSetHandler = (ResultSetHandler) invocation.getTarget();
|
||||||
|
Field parameterHandlerField = resultSetHandler.getClass().getDeclaredField("parameterHandler");
|
||||||
|
parameterHandlerField.setAccessible(true);
|
||||||
|
Object target = parameterHandlerField.get(resultSetHandler);
|
||||||
|
if (target instanceof ParameterHandler parameterHandler) {
|
||||||
|
Object parameterObject = parameterHandler.getParameterObject();
|
||||||
|
if (ObjectUtil.isNotNull(parameterObject) && !(parameterObject instanceof String)) {
|
||||||
|
this.decryptHandler(parameterObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 获取执行mysql执行结果
|
// 获取执行mysql执行结果
|
||||||
Object result = invocation.proceed();
|
Object result = invocation.proceed();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
decryptHandler(result);
|
this.decryptHandler(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user