From 02f18587bd8860b305e2c688e20465be166bb48c Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期四, 22 七月 2021 15:14:03 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/test' into test --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/helper/encrypt/ParammeterInterceptor.java | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/helper/encrypt/ParammeterInterceptor.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/helper/encrypt/ParammeterInterceptor.java index 6c6c010..8cb0c8a 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/helper/encrypt/ParammeterInterceptor.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/helper/encrypt/ParammeterInterceptor.java @@ -5,7 +5,6 @@ import com.panzhihua.common.model.helper.encrypt.EncryptQuery; import com.panzhihua.common.model.helper.encrypt.EncryptQueryClass; import com.panzhihua.common.model.helper.encrypt.IEncryptDecrypt; -import com.panzhihua.common.model.helper.sensitive.Sensitive; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.binding.BindingException; import org.apache.ibatis.binding.MapperMethod; @@ -19,7 +18,6 @@ import java.lang.reflect.Field; import java.sql.PreparedStatement; import java.util.*; -import java.util.stream.Stream; /** * 加密拦截器 @@ -40,7 +38,6 @@ @Override public Object intercept(Invocation invocation) throws Throwable { - //拦截 ParameterHandler 的 setParameters 方法 动态设置参数 if (invocation.getTarget() instanceof ParameterHandler) { ParameterHandler parameterHandler = (ParameterHandler) invocation.getTarget(); @@ -66,7 +63,7 @@ boolean encrypted = false; try{ /** - * 分页插件,会再分页查询时 进行多次查询,需要判断是否已对加密参数加密,防止多次加密后,查询失败 + * 分页插件,会在分页查询时 进行多次查询,需要判断是否已对加密参数加密,防止多次加密后,查询失败 */ encrypted = paramMap.get("encrypted")!=null; }catch (BindingException be){ @@ -78,16 +75,18 @@ Map.Entry<String, Object> entry = (Map.Entry<String, Object>) iterator.next(); if (entry.getKey().startsWith("param")) { Object v = entry.getValue(); - EncryptQueryClass encryptQueryClass = AnnotationUtils.findAnnotation(v.getClass(), EncryptQueryClass.class); - if (Objects.nonNull(encryptQueryClass)) { - Field[] declaredFields = v.getClass().getDeclaredFields(); - for (Field field : declaredFields) { - if (field.isAnnotationPresent(EncryptQuery.class)) { - try { - final Object encrypt = encryptDecrypt.encrypt(new Field[]{field}, v); - paramMap.put("encrypted", true); - } catch (IllegalAccessException e) { - e.printStackTrace(); + if(v!=null) { + EncryptQueryClass encryptQueryClass = AnnotationUtils.findAnnotation(v.getClass(), EncryptQueryClass.class); + if (Objects.nonNull(encryptQueryClass)) { + Field[] declaredFields = v.getClass().getDeclaredFields(); + for (Field field : declaredFields) { + if (field.isAnnotationPresent(EncryptQuery.class)) { + try { + final Object encrypt = encryptDecrypt.encrypt(new Field[]{field}, v); + paramMap.put("encrypted", true); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } } } } -- Gitblit v1.7.1