From b382844e370dcad6f30d2d9af6ab912c9d532ded Mon Sep 17 00:00:00 2001 From: "jihuan.yin@ipiaoniu.com" Date: Tue, 30 Mar 2021 17:34:43 +0800 Subject: [PATCH] =?UTF-8?q?bugfix=20https://github.com/yinjihuan/monkey-ap?= =?UTF-8?q?i-encrypt/issues/69=20AntPathMatcher=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cxytiandi/encrypt/core/EncryptionFilter.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/core/EncryptionFilter.java b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/core/EncryptionFilter.java index 9e22c8f..dbd95d5 100644 --- a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/core/EncryptionFilter.java +++ b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/core/EncryptionFilter.java @@ -19,15 +19,14 @@ import com.cxytiandi.encrypt.algorithm.AesEncryptAlgorithm; import com.cxytiandi.encrypt.algorithm.EncryptAlgorithm; +import org.springframework.util.AntPathMatcher; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.HandlerExecutionChain; import org.springframework.web.servlet.HandlerMapping; -import org.springframework.web.servlet.handler.AbstractHandlerMethodMapping; /** * 数据加解密过滤器 @@ -227,6 +226,14 @@ private boolean contains(List list, String uri, String methodType, HttpS return true; } + // 优先用AntPathMatcher,其实用这个也够了,底层是一样的,下面用的方式兜底 + for (String u : list) { + boolean match = new AntPathMatcher().match(u, uri); + if (match) { + return true; + } + } + try { // 支持RestFul风格API // 采用Spring MVC内置的匹配方式将当前请求匹配到对应的Controller Method上,获取注解进行匹配是否要加解密