Class PathMatcher

java.lang.Object
org.pac4j.core.matching.matcher.PathMatcher
All Implemented Interfaces:
Matcher

public class PathMatcher extends Object implements Matcher
Matches all request paths except whitelisted (excluded) paths.
Since:
2.0.0
Author:
Rob Ward
  • Constructor Details

    • PathMatcher

      public PathMatcher()
    • PathMatcher

      @Deprecated public PathMatcher(String regexpPath)
      Deprecated.
  • Method Details

    • excludePath

      public PathMatcher excludePath(String path)
      Any path exactly matching this string will be excluded. Use this method if you are excluding a specific path.
      Parameters:
      path - the path to be excluded
      Returns:
      this path matcher
    • excludePaths

      public PathMatcher excludePaths(String... paths)
    • includePath

      public PathMatcher includePath(String path)
    • includePaths

      public PathMatcher includePaths(String... paths)
    • excludeBranch

      public PathMatcher excludeBranch(String path)
      Convenience method for excluding all paths starting with a prefix e.g. "/foo" would exclude "/foo", "/foo/bar", etc.
      Parameters:
      path - the prefix for the paths to be excluded
      Returns:
      this path matcher
    • excludeRegex

      public PathMatcher excludeRegex(String regex)
      Any path matching this regex will be excluded.
      Parameters:
      regex - the regular expression matching the paths to be excluded
      Returns:
      this path matcher
    • warnRegexp

      protected void warnRegexp()
    • warnInclude

      protected void warnInclude()
    • matches

      public boolean matches(WebContext context, SessionStore sessionStore)
      Description copied from interface: Matcher
      Check if the web context matches.
      Specified by:
      matches in interface Matcher
      Parameters:
      context - the web context
      sessionStore - the session store
      Returns:
      whether the web context matches
    • getExcludedPaths

      public Set<String> getExcludedPaths()
    • getExcludedPatterns

      public Set<Pattern> getExcludedPatterns()
    • setExcludedPaths

      public void setExcludedPaths(Collection<String> paths)
    • setExcludedPatterns

      public void setExcludedPatterns(Collection<String> regularExpressions)
    • setExcludedPath

      public void setExcludedPath(String path)
    • setExcludedPattern

      public void setExcludedPattern(String regularExpression)
    • toString

      public String toString()
      Overrides:
      toString in class Object