org.apache.shiro.web.filter.session
Class NoSessionCreationFilter

java.lang.Object
  extended by org.apache.shiro.web.servlet.ServletContextSupport
      extended by org.apache.shiro.web.servlet.AbstractFilter
          extended by org.apache.shiro.web.servlet.NameableFilter
              extended by org.apache.shiro.web.servlet.OncePerRequestFilter
                  extended by org.apache.shiro.web.servlet.AdviceFilter
                      extended by org.apache.shiro.web.filter.PathMatchingFilter
                          extended by org.apache.shiro.web.filter.session.NoSessionCreationFilter
All Implemented Interfaces:
Filter, Nameable, PathConfigProcessor

public class NoSessionCreationFilter
extends PathMatchingFilter

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:

  1. If a 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.
  2. However, if the 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.
Finally, calls to 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, pathMatcher
 
Fields inherited from class org.apache.shiro.web.servlet.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX
 
Fields inherited from class org.apache.shiro.web.servlet.AbstractFilter
filterConfig
 
Constructor Summary
NoSessionCreationFilter()
           
 
Method Summary
protected  boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue)
          This default implementation always returns true and 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, processPathConfig
 
Methods inherited from class org.apache.shiro.web.servlet.AdviceFilter
afterCompletion, cleanup, doFilterInternal, executeChain, postHandle
 
Methods inherited from class org.apache.shiro.web.servlet.OncePerRequestFilter
doFilter, getAlreadyFilteredAttributeName, isEnabled, isEnabled, setEnabled, shouldNotFilter
 
Methods inherited from class org.apache.shiro.web.servlet.NameableFilter
getName, setName, toStringBuilder
 
Methods inherited from class org.apache.shiro.web.servlet.AbstractFilter
destroy, getFilterConfig, getInitParam, init, onFilterConfigSet, setFilterConfig
 
Methods inherited from class org.apache.shiro.web.servlet.ServletContextSupport
getContextAttribute, getContextInitParam, getServletContext, removeContextAttribute, setContextAttribute, setServletContext, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NoSessionCreationFilter

public NoSessionCreationFilter()
Method Detail

onPreHandle

protected boolean onPreHandle(ServletRequest request,
                              ServletResponse response,
                              Object mappedValue)
                       throws Exception
Description copied from class: PathMatchingFilter
This default implementation always returns true and should be overridden by subclasses for custom logic if necessary.

Overrides:
onPreHandle in class PathMatchingFilter
Parameters:
request - the incoming ServletRequest
response - the outgoing ServletResponse
mappedValue - the filter-specific config value mapped to this filter in the URL rules mappings.
Returns:
true if the request should be able to continue, false if the filter will handle the response directly.
Throws:
Exception - if an error occurs
See Also:
PathMatchingFilter.isEnabled(javax.servlet.ServletRequest, javax.servlet.ServletResponse, String, Object)


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.