org.apache.shiro.web.servlet
Class ShiroFilter

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.AbstractShiroFilter
                      extended by org.apache.shiro.web.servlet.ShiroFilter
All Implemented Interfaces:
Filter, Nameable

public class ShiroFilter
extends AbstractShiroFilter

Primary Shiro Filter for web applications configuring Shiro via Servlet <listener> in web.xml.

As of Shiro 1.2, this is Shiro's preferred filter for web.xml configuration. It expects the presence of a Shiro WebEnvironment in the ServletContext, also configured via web.xml.

Usage

As this Filter expects an available WebEnvironment instance to be configured, it must be defined in web.xml with the companion EnvironmentLoaderListener, which performs the necessary environment setup. For example:
 <listener>
     <listener-class>EnvironmentLoaderListener</listener-class>
 </listener>
 ...
 <filter>
     <filter-name>ShiroFilter</filter-name>
     <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
 </filter>

 <-- Filter all web requests.  This filter mapping is typically declared
     before all others to ensure any other filters are secured as well: -->
 <filter-mapping>
     <filter-name>ShiroFilter</filter-name>
     <url-pattern>/*</url-pattern>
 </filter-mapping>
 
Configuration options (configuration file paths, etc) are specified as part of the EnvironmentLoaderListener configuration. See the EnvironmentLoader JavaDoc for configuration options.

Since:
1.2
See Also:
EnvironmentLoader, EnvironmentLoaderListener, Apache Shiro Web Documentation

Field Summary
 
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
ShiroFilter()
           
 
Method Summary
 void init()
          Configures this instance based on the existing WebEnvironment instance available to the currently accessible servletContext.
 
Methods inherited from class org.apache.shiro.web.servlet.AbstractShiroFilter
createDefaultSecurityManager, createSubject, doFilterInternal, executeChain, getExecutionChain, getFilterChainResolver, getSecurityManager, isHttpSessions, isStaticSecurityManagerEnabled, onFilterConfigSet, prepareServletRequest, prepareServletResponse, setFilterChainResolver, setSecurityManager, setStaticSecurityManagerEnabled, updateSessionLastAccessTime, wrapServletRequest, wrapServletResponse
 
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, 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

ShiroFilter

public ShiroFilter()
Method Detail

init

public void init()
          throws Exception
Configures this instance based on the existing WebEnvironment instance available to the currently accessible servletContext.

Overrides:
init in class AbstractShiroFilter
Throws:
Exception
Since:
1.2
See Also:
EnvironmentLoaderListener


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