Package org.apache.shiro.web.filter.mgt
Class PathMatchingFilterChainResolver
- java.lang.Object
-
- org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver
-
- All Implemented Interfaces:
FilterChainResolver
public class PathMatchingFilterChainResolver extends Object implements FilterChainResolver
AFilterChainResolverthat resolvesFilterChains based on url path matching, as determined by a configurablePathMatcher. This implementation functions by consulting aFilterChainManagerfor all configured filter chains (keyed by configured path pattern). If an incoming Request path matches one of the configured path patterns (via thePathMatcher, the corresponding configuredFilterChainis returned.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description PathMatchingFilterChainResolver()PathMatchingFilterChainResolver(javax.servlet.FilterConfig filterConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.servlet.FilterChaingetChain(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain originalChain)Returns the filter chain that should be executed for the given request, ornullif the original chain should be used.FilterChainManagergetFilterChainManager()org.apache.shiro.util.PatternMatchergetPathMatcher()Returns thePatternMatcherused when determining if an incoming request's path matches a configured filter chain.protected StringgetPathWithinApplication(javax.servlet.ServletRequest request)Merely returnsWebUtils.and can be overridden by subclasses for custom request-to-application-path resolution behavior.getPathWithinApplication(request)protected booleanpathMatches(String pattern, String path)Returnstrueif an incoming request path (thepathargument) matches a configured filter chain path (thepatternargument),falseotherwise.voidsetFilterChainManager(FilterChainManager filterChainManager)voidsetPathMatcher(org.apache.shiro.util.PatternMatcher pathMatcher)Sets thePatternMatcherused when determining if an incoming request's path matches a configured filter chain.
-
-
-
Method Detail
-
getPathMatcher
public org.apache.shiro.util.PatternMatcher getPathMatcher()
Returns thePatternMatcherused when determining if an incoming request's path matches a configured filter chain. Unless overridden, the default implementation is anAntPathMatcher.- Returns:
- the
PatternMatcherused when determining if an incoming request's path matches a configured filter chain.
-
setPathMatcher
public void setPathMatcher(org.apache.shiro.util.PatternMatcher pathMatcher)
Sets thePatternMatcherused when determining if an incoming request's path matches a configured filter chain. Unless overridden, the default implementation is anAntPathMatcher.- Parameters:
pathMatcher- thePatternMatcherused when determining if an incoming request's path matches a configured filter chain.
-
getFilterChainManager
public FilterChainManager getFilterChainManager()
-
setFilterChainManager
public void setFilterChainManager(FilterChainManager filterChainManager)
-
getChain
public javax.servlet.FilterChain getChain(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain originalChain)Description copied from interface:FilterChainResolverReturns the filter chain that should be executed for the given request, ornullif the original chain should be used. This method allows a implementation to define arbitrary securityFilterchains for any given request or URL pattern.- Specified by:
getChainin interfaceFilterChainResolver- Parameters:
request- the incoming ServletRequestresponse- the outgoing ServletResponseoriginalChain- the originalFilterChainintercepted by the ShiroFilter implementation.- Returns:
- the filter chain that should be executed for the given request, or
nullif the original chain should be used.
-
pathMatches
protected boolean pathMatches(String pattern, String path)
Returnstrueif an incoming request path (thepathargument) matches a configured filter chain path (thepatternargument),falseotherwise. Simply delegates to. Subclass implementors should think carefully before overriding this method, as typically a customgetPathMatcher().matches(pattern,path)PathMatchershould be configured for custom path matching behavior instead. Favor OO composition rather than inheritance to limit your exposure to Shiro implementation details which may change over time.- Parameters:
pattern- the pattern to match againstpath- the value to match with the specifiedpattern- Returns:
trueif the requestpathmatches the specified filter chain urlpattern,falseotherwise.
-
getPathWithinApplication
protected String getPathWithinApplication(javax.servlet.ServletRequest request)
Merely returnsWebUtils.and can be overridden by subclasses for custom request-to-application-path resolution behavior.getPathWithinApplication(request)- Parameters:
request- the incomingServletRequest- Returns:
- the request's path within the appliation.
-
-