public class NoSessionCreationFilter extends PathMatchingFilter
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:
Subject
does not yet have a Session by the time this filter is called, this filter effectively
disables all calls to subject
.getSession()
and
subject
.getSession(true)
. If either are called
during the request, an exception will be thrown.Subject
already 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.appliedPaths, pathMatcher
ALREADY_FILTERED_SUFFIX
filterConfig
Constructor and Description |
---|
NoSessionCreationFilter() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
onPreHandle(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
Object mappedValue)
This default implementation always returns
true and should be overridden by subclasses for custom
logic if necessary. |
getPathWithinApplication, isEnabled, pathsMatch, pathsMatch, preHandle, processPathConfig
afterCompletion, cleanup, doFilterInternal, executeChain, postHandle
doFilter, getAlreadyFilteredAttributeName, isEnabled, isEnabled, setEnabled, shouldNotFilter
getName, setName, toStringBuilder
destroy, getFilterConfig, getInitParam, init, onFilterConfigSet, setFilterConfig
getContextAttribute, getContextInitParam, getServletContext, removeContextAttribute, setContextAttribute, setServletContext, toString
public NoSessionCreationFilter()
protected boolean onPreHandle(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, Object mappedValue) throws Exception
PathMatchingFilter
true
and should be overridden by subclasses for custom
logic if necessary.onPreHandle
in class PathMatchingFilter
request
- the incoming ServletRequestresponse
- the outgoing ServletResponsemappedValue
- the filter-specific config value mapped to this filter in the URL rules mappings.true
if the request should be able to continue, false
if the filter will
handle the response directly.Exception
- if an error occursPathMatchingFilter.isEnabled(javax.servlet.ServletRequest, javax.servlet.ServletResponse, String, Object)
Copyright © 2004–2019 The Apache Software Foundation. All rights reserved.