Class RegexRequestMatcher
- java.lang.Object
-
- org.springframework.security.web.util.matcher.RegexRequestMatcher
-
- All Implemented Interfaces:
RequestMatcher
public final class RegexRequestMatcher extends java.lang.Object implements RequestMatcher
Uses a regular expression to decide whether a supplied the URL of a suppliedHttpServletRequest
. Can also be configured to match a specific HTTP method. The match is performed against theservletPath + pathInfo + queryString
of the request and is case-sensitive by default. Case-insensitive matching can be used by using the constructor which takes thecaseInsensitive
argument.- Since:
- 3.1
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.springframework.security.web.util.matcher.RequestMatcher
RequestMatcher.MatchResult
-
-
Constructor Summary
Constructors Constructor Description RegexRequestMatcher(java.lang.String pattern, java.lang.String httpMethod)
Creates a case-sensitivePattern
instance to match against the request.RegexRequestMatcher(java.lang.String pattern, java.lang.String httpMethod, boolean caseInsensitive)
As above, but allows setting of whether case-insensitive matching should be used.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
matches(javax.servlet.http.HttpServletRequest request)
Performs the match of the request URL (servletPath + pathInfo + queryString
) against the compiled pattern.static RegexRequestMatcher
regexMatcher(java.lang.String pattern)
Creates a case-sensitivePattern
instance to match against the request.static RegexRequestMatcher
regexMatcher(org.springframework.http.HttpMethod method)
Creates an instance that matches to all requests with the sameHttpMethod
.static RegexRequestMatcher
regexMatcher(org.springframework.http.HttpMethod method, java.lang.String pattern)
Creates a case-sensitivePattern
instance to match against the request.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.springframework.security.web.util.matcher.RequestMatcher
matcher
-
-
-
-
Constructor Detail
-
RegexRequestMatcher
public RegexRequestMatcher(java.lang.String pattern, java.lang.String httpMethod)
Creates a case-sensitivePattern
instance to match against the request.- Parameters:
pattern
- the regular expression to compile into a pattern.httpMethod
- the HTTP method to match. May be null to match all methods.
-
RegexRequestMatcher
public RegexRequestMatcher(java.lang.String pattern, java.lang.String httpMethod, boolean caseInsensitive)
As above, but allows setting of whether case-insensitive matching should be used.- Parameters:
pattern
- the regular expression to compile into a pattern.httpMethod
- the HTTP method to match. May be null to match all methods.caseInsensitive
- if true, the pattern will be compiled with thePattern.CASE_INSENSITIVE
flag set.
-
-
Method Detail
-
regexMatcher
public static RegexRequestMatcher regexMatcher(java.lang.String pattern)
Creates a case-sensitivePattern
instance to match against the request.- Parameters:
pattern
- the regular expression to compile into a pattern.- Since:
- 5.8
-
regexMatcher
public static RegexRequestMatcher regexMatcher(org.springframework.http.HttpMethod method)
Creates an instance that matches to all requests with the sameHttpMethod
.- Parameters:
method
- the HTTP method to match. Must not be null.- Since:
- 5.8
-
regexMatcher
public static RegexRequestMatcher regexMatcher(org.springframework.http.HttpMethod method, java.lang.String pattern)
Creates a case-sensitivePattern
instance to match against the request.- Parameters:
method
- the HTTP method to match. May be null to match all methods.pattern
- the regular expression to compile into a pattern.- Since:
- 5.8
-
matches
public boolean matches(javax.servlet.http.HttpServletRequest request)
Performs the match of the request URL (servletPath + pathInfo + queryString
) against the compiled pattern. If the query string is present, a question mark will be prepended.- Specified by:
matches
in interfaceRequestMatcher
- Parameters:
request
- the request to match- Returns:
- true if the pattern matches the URL, false otherwise.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-