Class NoSessionCreationFilter
java.lang.Object
org.apache.shiro.web.servlet.ServletContextSupport
org.apache.shiro.web.servlet.AbstractFilter
org.apache.shiro.web.servlet.NameableFilter
org.apache.shiro.web.servlet.OncePerRequestFilter
org.apache.shiro.web.servlet.AdviceFilter
org.apache.shiro.web.filter.PathMatchingFilter
org.apache.shiro.web.filter.session.NoSessionCreationFilter
- All Implemented Interfaces:
javax.servlet.Filter,org.apache.shiro.lang.util.Nameable,PathConfigProcessor
A
PathMatchingFilter that will disable creating new Sessions during the request. This is a useful
filter to place in the front of any filter chains that may result in REST, SOAP or other service invocations that
are not intended to participate in a session.
This filter enables the following behavior:
- If a
Subjectdoes not yet have a Session by the time this filter is called, this filter effectively disables all calls tosubject.getSession()andsubject.getSession(true). If either are called during the request, an exception will be thrown. -
However, if the
Subjectalready has an associated session before this filter is invoked, either because it was created in another part of the application, or a filter higher in the chain created one, this filter has no effect.
subject.getSession(false) (i.e. a false boolean value) will be unaffected
and may be called without repercussion in all cases.- Since:
- 1.2
-
Field Summary
Fields inherited from class org.apache.shiro.web.filter.PathMatchingFilter
appliedPaths, pathMatcherFields inherited from class org.apache.shiro.web.servlet.OncePerRequestFilter
ALREADY_FILTERED_SUFFIXFields inherited from class org.apache.shiro.web.servlet.AbstractFilter
filterConfig -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanonPreHandle(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, Object mappedValue) This default implementation always returnstrueand should be overridden by subclasses for custom logic if necessary.Methods inherited from class org.apache.shiro.web.filter.PathMatchingFilter
getPathWithinApplication, isEnabled, pathsMatch, pathsMatch, preHandle, processPathConfigMethods inherited from class org.apache.shiro.web.servlet.AdviceFilter
afterCompletion, cleanup, doFilterInternal, executeChain, postHandleMethods inherited from class org.apache.shiro.web.servlet.OncePerRequestFilter
doFilter, getAlreadyFilteredAttributeName, isEnabled, isEnabled, isFilterOncePerRequest, setEnabled, setFilterOncePerRequest, shouldNotFilterMethods inherited from class org.apache.shiro.web.servlet.NameableFilter
getName, setName, toStringBuilderMethods inherited from class org.apache.shiro.web.servlet.AbstractFilter
destroy, getFilterConfig, getInitParam, init, onFilterConfigSet, setFilterConfigMethods inherited from class org.apache.shiro.web.servlet.ServletContextSupport
getContextAttribute, getContextInitParam, getServletContext, removeContextAttribute, setContextAttribute, setServletContext, toString
-
Constructor Details
-
NoSessionCreationFilter
public NoSessionCreationFilter()
-
-
Method Details
-
onPreHandle
protected boolean onPreHandle(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, Object mappedValue) throws Exception Description copied from class:PathMatchingFilterThis default implementation always returnstrueand should be overridden by subclasses for custom logic if necessary.- Overrides:
onPreHandlein classPathMatchingFilter- Parameters:
request- the incoming ServletRequestresponse- the outgoing ServletResponsemappedValue- the filter-specific config value mapped to this filter in the URL rules mappings.- Returns:
trueif the request should be able to continue,falseif the filter will handle the response directly.- Throws:
Exception- if an error occurs- See Also:
-