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()

      Constructor for PathMatcher.

  • 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)

      excludePaths.

      Parameters:
      paths - a String object
      Returns:
      a PathMatcher object
    • includePath

      public PathMatcher includePath(String path)

      includePath.

      Parameters:
      path - a String object
      Returns:
      a PathMatcher object
    • includePaths

      public PathMatcher includePaths(String... paths)

      includePaths.

      Parameters:
      paths - a String object
      Returns:
      a PathMatcher object
    • 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()

      warnRegexp.

    • warnInclude

      protected void warnInclude()

      warnInclude.

    • matches

      public boolean matches(CallContext ctx)
      Check if the context matches.
      Specified by:
      matches in interface Matcher
      Parameters:
      ctx - the context
      Returns:
      whether the context matches
    • setExcludedPaths

      public void setExcludedPaths(Iterable<String> paths)

      Setter for the field excludedPaths.

      Parameters:
      paths - a Collection object
    • setExcludedPatterns

      public void setExcludedPatterns(Iterable<String> regularExpressions)

      Setter for the field excludedPatterns.

      Parameters:
      regularExpressions - a Collection object
    • setExcludedPath

      public void setExcludedPath(String path)

      setExcludedPath.

      Parameters:
      path - a String object
    • setExcludedPattern

      public void setExcludedPattern(String regularExpression)

      setExcludedPattern.

      Parameters:
      regularExpression - a String object