Class IniShiroFilter
- All Implemented Interfaces:
javax.servlet.Filter,org.apache.shiro.lang.util.Nameable
Deprecated.
Deprecated
This filter has been deprecated as of Shiro 1.2 in favor of using theShiroFilter in web.xml instead.
See the ShiroFilter JavaDoc for usage.
======================
Servlet Filter that configures and enables all Shiro functions within a web application by using the
INI configuration format.
The actual INI configuration contents are not covered here, but instead in Shiro's
Configuration Documentation and additional web-specific
Web Documentation.
Usage
Default
By default, the simplest filter declaration expects ashiro.ini resource to be located at
/WEB-INF/shiro.ini, or, if not there, falls back to checking the root of the classpath
(i.e. classpath:shiro.ini):
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
</filter>
Custom Path
If you want the INI configuration to be somewhere other than/WEB-INF/shiro.ini or
classpath:shiro.ini, you may specify an alternate location via the configPath init-param:
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
<init-param>
<param-name>configPath</param-name>
<param-value>/WEB-INF/someFile.ini</param-value>
</init-param>
</filter>
Unqualified (schemeless or 'non-prefixed') paths are assumed to be ServletContext resource paths, resolvable
via ServletContext#getResourceAsStream.
Non-ServletContext resources may be loaded from qualified locations by specifying prefixes indicating the source,
e.g. file:, url:, and classpath:. See the
ResourceUtils.getInputStreamForPath(String) JavaDoc for more.
Inline
For relatively simple environments, you can embed the INI config directly inside the filter declaration with theconfig init-param:
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>
#INI config goes here...
</param-value>
</init-param>
</filter>
Although this is typically not recommended because any Shiro configuration changes would contribute to version control
'noise' in the web.xml file.
When creating the shiro.ini configuration itself, please see Shiro's
Configuration Documentation and
Web Documentation.- Since:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.ini config param name.static final StringDeprecated.ini config path param name.static final StringDeprecated.default web ini resource path.Fields 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 voidapplyFilterChainResolver(org.apache.shiro.config.Ini ini, Map<String, ?> defaults) Deprecated.protected voidDeprecated.applySecurityManager(org.apache.shiro.config.Ini ini) Deprecated.protected voidDeprecated.protected org.apache.shiro.config.IniconvertConfigToIni(String config) Deprecated.protected org.apache.shiro.config.IniconvertPathToIni(String path) Deprecated.Converts the specified file path to anIniinstance.Deprecated.Returns the actual INI configuration text to use to build theSecurityManagerandFilterChainResolverused by the web application ornullif theconfigPathshould be used to load a fallback INI source.Deprecated.Returns the config path to be used to load a .ini file for configuration if a configuration is not specified via theconfigattribute.protected org.apache.shiro.config.InigetServletContextIniResource(String servletContextPath) Deprecated.Returns the INI instance reflecting the specified servlet context resource path ornullif no resource was found.voidinit()Deprecated.protected org.apache.shiro.config.IniDeprecated.protected org.apache.shiro.config.IniDeprecated.voidDeprecated.Sets the actual INI configuration text to use to build theSecurityManagerandFilterChainResolverused by the web application.voidsetConfigPath(String configPath) Deprecated.Sets the config path to be used to load a .ini file for configuration if a configuration is not specified via theconfigattribute.Methods inherited from class org.apache.shiro.web.servlet.AbstractShiroFilter
createDefaultSecurityManager, createSubject, doFilterInternal, executeChain, getExecutionChain, getFilterChainResolver, getSecurityManager, isHttpSessions, isStaticSecurityManagerEnabled, onFilterConfigSet, prepareServletRequest, prepareServletResponse, setFilterChainResolver, setSecurityManager, setShiroFilterConfiguration, setStaticSecurityManagerEnabled, updateSessionLastAccessTime, wrapServletRequest, wrapServletResponseMethods 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, setFilterConfigMethods inherited from class org.apache.shiro.web.servlet.ServletContextSupport
getContextAttribute, getContextInitParam, getServletContext, removeContextAttribute, setContextAttribute, setServletContext, toString
-
Field Details
-
CONFIG_INI_PARAM_NAME
-
CONFIG_PATH_INI_PARAM_NAME
Deprecated.ini config path param name.- See Also:
-
DEFAULT_WEB_INI_RESOURCE_PATH
Deprecated.default web ini resource path.- See Also:
-
-
Constructor Details
-
IniShiroFilter
public IniShiroFilter()Deprecated.
-
-
Method Details
-
getConfig
Deprecated.Returns the actual INI configuration text to use to build theSecurityManagerandFilterChainResolverused by the web application ornullif theconfigPathshould be used to load a fallback INI source. This value isnullby default, but it will be automatically set to the value of the 'config'init-paramif it exists in theFilterConfigprovided by the servlet container at startup.- Returns:
- the actual INI configuration text to use to build the
SecurityManagerandFilterChainResolverused by the web application ornullif theconfigPathshould be used to load a fallback INI source.
-
setConfig
Deprecated.Sets the actual INI configuration text to use to build theSecurityManagerandFilterChainResolverused by the web application. If this value isnull, theconfigPathwill be checked to see if a .ini file should be loaded instead. This value isnullby default, but it will be automatically set to the value of the 'config'init-paramif it exists in theFilterConfigprovided by the servlet container at startup.- Parameters:
config- the actual INI configuration text to use to build theSecurityManagerandFilterChainResolverused by the web application.
-
getConfigPath
Deprecated.Returns the config path to be used to load a .ini file for configuration if a configuration is not specified via theconfigattribute. This value isnullby default, but it will be automatically set to the value of the 'configPath'init-paramif it exists in theFilterConfigprovided by the servlet container at startup.- Returns:
- the config path to be used to load a .ini file for configuration if a configuration is
not specified via the
configattribute.
-
setConfigPath
Deprecated.Sets the config path to be used to load a .ini file for configuration if a configuration is not specified via theconfigattribute. This value isnullby default, but it will be automatically set to the value of the 'configPath'init-paramif it exists in theFilterConfigprovided by the servlet container at startup.- Parameters:
configPath- the config path to be used to load a .ini file for configuration if a configuration is not specified via theconfigattribute.
-
init
Deprecated.- Overrides:
initin classAbstractShiroFilter- Throws:
Exception
-
applyInitParams
-
configure
-
loadIniFromConfig
Deprecated. -
loadIniFromPath
Deprecated. -
applySecurityManager
Deprecated. -
applyFilterChainResolver
Deprecated. -
convertConfigToIni
Deprecated. -
getServletContextIniResource
Deprecated.Returns the INI instance reflecting the specified servlet context resource path ornullif no resource was found.- Parameters:
servletContextPath- the servlet context resource path of the INI file to load- Returns:
- the INI instance reflecting the specified servlet context resource path or
nullif no resource was found. - Since:
- 1.2
-
convertPathToIni
Deprecated.Converts the specified file path to anIniinstance. If the path does not have a resource prefix as defined byResourceUtils.hasResourcePrefix(String), the path is expected to be resolvable by theServletContextviaServletContext.getResourceAsStream(String).- Parameters:
path- the path of the INI resource to load into an INI instance.- Returns:
- an INI instance populated based on the given INI resource path.
-
ShiroFilter