Package org.apache.shiro.web.servlet
Class ShiroFilter
-
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 forweb.xml
configuration. It expects the presence of a ShiroWebEnvironment
in theServletContext
, also configured viaweb.xml
.Usage
As this Filter expects an availableWebEnvironment
instance to be configured, it must be defined inweb.xml
with the companionEnvironmentLoaderListener
, which performs the necessary environment setup. For example:<listener> <listener-class>
Configuration options (configuration file paths, etc) are specified as part of theEnvironmentLoaderListener
</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>EnvironmentLoaderListener
configuration. See theEnvironmentLoader
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
Constructors Constructor Description ShiroFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
init()
Configures this instance based on the existingWebEnvironment
instance available to the currently accessibleservletContext
.-
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
-
-
-
-
Constructor Detail
-
ShiroFilter
public ShiroFilter()
-
-
Method Detail
-
init
public void init() throws Exception
Configures this instance based on the existingWebEnvironment
instance available to the currently accessibleservletContext
.- Overrides:
init
in classAbstractShiroFilter
- Throws:
Exception
- Since:
- 1.2
- See Also:
EnvironmentLoaderListener
-
-