📄 urlpatternmatcher.java
字号:
package dev.trade.common.securityfilter.filter;
import org.apache.oro.text.regex.*;
import java.util.Collection;
/**
* URLPatternMatcher - A non-thread safe object to be used to match a request
* pattern with URLPattern objects.
*/
public class URLPatternMatcher {
private PatternMatcher patternMatcher;
/**
* Constructor
*/
public URLPatternMatcher() {
patternMatcher = new Perl5Matcher();
}
/**
* Test to see if a string pattern matches a URLPattern.
*
* @param pattern a String pattern to check for a match
* @param urlPattern a URLPattern object to match against
* @return true if the pattern matched the urlPattern, false otherwise
* @throws Exception
*/
public boolean match(String pattern, URLPattern urlPattern) throws Exception {
return patternMatcher.matches(pattern, urlPattern.getCompiledPattern());
}
/**
* Test to see if a string pattern and HTTP method matches a URLPattern.
*
* @param pattern a String pattern to check for a match
* @param httpMethod an HTTP pattern to check for a match
* @param urlPattern a URLPattern object to match against
* @return true if the pattern matched the urlPattern, false otherwise
* @throws Exception
*/
public boolean match(String pattern, String httpMethod, URLPattern urlPattern) throws Exception {
if (match(pattern, urlPattern)) {
Collection methods = urlPattern.getWebResourceCollection().getHttpMethods();
if (methods.isEmpty() || methods.contains(httpMethod.toUpperCase())) {
return true;
}
}
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -