⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 urlpatternmatcher.java

📁 用于JAVA的Web的权限过滤器
💻 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 + -