|
@@ -11,7 +11,12 @@ import org.aspectj.lang.annotation.Around;
|
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
|
import org.aspectj.lang.annotation.Pointcut;
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
+import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.context.request.RequestContextHolder;
|
|
|
+import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
/**
|
|
|
* @Description: 数据库加解密
|
|
@@ -33,9 +38,13 @@ public class CryptAspect {
|
|
|
public Object aroundReturningController(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
|
//获取方法参数
|
|
|
Object[] args = joinPoint.getArgs();
|
|
|
-
|
|
|
- //获取参数实体类注解加密
|
|
|
- CryptPojoUtils.encryptFields(args);
|
|
|
+ //获取请求
|
|
|
+ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
+ //验证是否需要跳过
|
|
|
+ if (!matchPermitAllUrl(request)){
|
|
|
+ //获取参数实体类注解加密
|
|
|
+ CryptPojoUtils.encryptFields(args);
|
|
|
+ }
|
|
|
//执行方法后获取出参
|
|
|
Object proceed = joinPoint.proceed(args);
|
|
|
if (null == proceed) {
|
|
@@ -99,4 +108,19 @@ public class CryptAspect {
|
|
|
|
|
|
return proceed;
|
|
|
}
|
|
|
+
|
|
|
+ private Boolean matchPermitAllUrl(HttpServletRequest request) {
|
|
|
+ if (matchers("/concept/conceptInfoExcelIm", request)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean matchers(String url, HttpServletRequest request) {
|
|
|
+ AntPathRequestMatcher matcher = new AntPathRequestMatcher(url);
|
|
|
+ if (matcher.matches(request)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|