Class MvcRequestMatcher
- java.lang.Object
-
- org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher
-
- All Implemented Interfaces:
RequestMatcher,RequestVariablesExtractor
public class MvcRequestMatcher extends java.lang.Object implements RequestMatcher, RequestVariablesExtractor
ARequestMatcherthat uses Spring MVC'sHandlerMappingIntrospectorto match the path and extract variables.It is important to understand that Spring MVC's matching is relative to the servlet path. This means if you have mapped any servlet to a path that starts with "/" and is greater than one, you should also specify the
setServletPath(String)attribute to differentiate mappings.- Since:
- 4.1.1
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.springframework.security.web.util.matcher.RequestMatcher
RequestMatcher.MatchResult
-
-
Constructor Summary
Constructors Constructor Description MvcRequestMatcher(org.springframework.web.servlet.handler.HandlerMappingIntrospector introspector, java.lang.String pattern)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>extractUriTemplateVariables(javax.servlet.http.HttpServletRequest request)Deprecated.protected java.lang.StringgetServletPath()RequestMatcher.MatchResultmatcher(javax.servlet.http.HttpServletRequest request)Returns a MatchResult for this RequestMatcher The default implementation returnsCollections.emptyMap()whenRequestMatcher.MatchResult.getVariables()is invoked.booleanmatches(javax.servlet.http.HttpServletRequest request)Decides whether the rule implemented by the strategy matches the supplied request.voidsetMethod(org.springframework.http.HttpMethod method)voidsetServletPath(java.lang.String servletPath)The servlet path to match on.java.lang.StringtoString()
-
-
-
Method Detail
-
matches
public boolean matches(javax.servlet.http.HttpServletRequest request)
Description copied from interface:RequestMatcherDecides whether the rule implemented by the strategy matches the supplied request.- Specified by:
matchesin interfaceRequestMatcher- Parameters:
request- the request to check for a match- Returns:
- true if the request matches, false otherwise
-
extractUriTemplateVariables
@Deprecated public java.util.Map<java.lang.String,java.lang.String> extractUriTemplateVariables(javax.servlet.http.HttpServletRequest request)
Deprecated.Description copied from interface:RequestVariablesExtractorExtract URL template variables from the request.- Specified by:
extractUriTemplateVariablesin interfaceRequestVariablesExtractor- Parameters:
request- the HttpServletRequest to obtain a URL to extract the variables from- Returns:
- the URL variables or empty if no variables are found
-
matcher
public RequestMatcher.MatchResult matcher(javax.servlet.http.HttpServletRequest request)
Description copied from interface:RequestMatcherReturns a MatchResult for this RequestMatcher The default implementation returnsCollections.emptyMap()whenRequestMatcher.MatchResult.getVariables()is invoked.- Specified by:
matcherin interfaceRequestMatcher- Returns:
- the MatchResult from comparing this RequestMatcher against the HttpServletRequest
-
setMethod
public void setMethod(org.springframework.http.HttpMethod method)
- Parameters:
method- the method to set
-
setServletPath
public void setServletPath(java.lang.String servletPath)
The servlet path to match on. The default is undefined which means any servlet path.- Parameters:
servletPath- the servletPath to set
-
getServletPath
protected final java.lang.String getServletPath()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-