Package org.apache.shiro.web.servlet
Class IniShiroFilter
-
@Deprecated public class IniShiroFilter extends AbstractShiroFilter
Deprecated.in 1.2 in favor of using theShiroFilter
Deprecated
This filter has been deprecated as of Shiro 1.2 in favor of using theShiroFilter
inweb.xml
instead. See theShiroFilter
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
orclasspath:shiro.ini
, you may specify an alternate location via theconfigPath 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 beServletContext
resource paths, resolvable viaServletContext#getResourceAsStream
. Non-ServletContext resources may be loaded from qualified locations by specifying prefixes indicating the source, e.g.file:
,url:
, andclasspath:
. See theResourceUtils.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:
- Apache Shiro INI Configuration, Apache Shiro Web Documentation
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIG_INIT_PARAM_NAME
Deprecated.static String
CONFIG_PATH_INIT_PARAM_NAME
Deprecated.static String
DEFAULT_WEB_INI_RESOURCE_PATH
Deprecated.-
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 IniShiroFilter()
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
applyFilterChainResolver(Ini ini, Map<String,?> defaults)
Deprecated.protected void
applyInitParams()
Deprecated.protected Map<String,?>
applySecurityManager(Ini ini)
Deprecated.protected void
configure()
Deprecated.protected Ini
convertConfigToIni(String config)
Deprecated.protected Ini
convertPathToIni(String path)
Deprecated.Converts the specified file path to anIni
instance.String
getConfig()
Deprecated.Returns the actual INI configuration text to use to build theSecurityManager
andFilterChainResolver
used by the web application ornull
if theconfigPath
should be used to load a fallback INI source.String
getConfigPath()
Deprecated.Returns the config path to be used to load a .ini file for configuration if a configuration is not specified via theconfig
attribute.protected Ini
getServletContextIniResource(String servletContextPath)
Deprecated.Returns the INI instance reflecting the specified servlet context resource path ornull
if no resource was found.void
init()
Deprecated.protected Ini
loadIniFromConfig()
Deprecated.protected Ini
loadIniFromPath()
Deprecated.void
setConfig(String config)
Deprecated.Sets the actual INI configuration text to use to build theSecurityManager
andFilterChainResolver
used by the web application.void
setConfigPath(String configPath)
Deprecated.Sets the config path to be used to load a .ini file for configuration if a configuration is not specified via theconfig
attribute.-
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
-
-
-
-
Field Detail
-
CONFIG_INIT_PARAM_NAME
public static final String CONFIG_INIT_PARAM_NAME
Deprecated.- See Also:
- Constant Field Values
-
CONFIG_PATH_INIT_PARAM_NAME
public static final String CONFIG_PATH_INIT_PARAM_NAME
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_WEB_INI_RESOURCE_PATH
public static final String DEFAULT_WEB_INI_RESOURCE_PATH
Deprecated.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IniShiroFilter
public IniShiroFilter()
Deprecated.
-
-
Method Detail
-
getConfig
public String getConfig()
Deprecated.Returns the actual INI configuration text to use to build theSecurityManager
andFilterChainResolver
used by the web application ornull
if theconfigPath
should be used to load a fallback INI source. This value isnull
by default, but it will be automatically set to the value of the 'config
'init-param
if it exists in theFilterConfig
provided by the servlet container at startup.- Returns:
- the actual INI configuration text to use to build the
SecurityManager
andFilterChainResolver
used by the web application ornull
if theconfigPath
should be used to load a fallback INI source.
-
setConfig
public void setConfig(String config)
Deprecated.Sets the actual INI configuration text to use to build theSecurityManager
andFilterChainResolver
used by the web application. If this value isnull
, theconfigPath
will be checked to see if a .ini file should be loaded instead. This value isnull
by default, but it will be automatically set to the value of the 'config
'init-param
if it exists in theFilterConfig
provided by the servlet container at startup.- Parameters:
config
- the actual INI configuration text to use to build theSecurityManager
andFilterChainResolver
used by the web application.
-
getConfigPath
public String getConfigPath()
Deprecated.Returns the config path to be used to load a .ini file for configuration if a configuration is not specified via theconfig
attribute. This value isnull
by default, but it will be automatically set to the value of the 'configPath
'init-param
if it exists in theFilterConfig
provided 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
config
attribute.
-
setConfigPath
public void setConfigPath(String configPath)
Deprecated.Sets the config path to be used to load a .ini file for configuration if a configuration is not specified via theconfig
attribute. This value isnull
by default, but it will be automatically set to the value of the 'configPath
'init-param
if it exists in theFilterConfig
provided 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 theconfig
attribute.
-
init
public void init() throws Exception
Deprecated.- Overrides:
init
in classAbstractShiroFilter
- Throws:
Exception
-
applyInitParams
protected void applyInitParams() throws Exception
Deprecated.- Throws:
Exception
-
loadIniFromConfig
protected Ini loadIniFromConfig()
Deprecated.
-
loadIniFromPath
protected Ini loadIniFromPath()
Deprecated.
-
applySecurityManager
protected Map<String,?> applySecurityManager(Ini ini)
Deprecated.
-
applyFilterChainResolver
protected void applyFilterChainResolver(Ini ini, Map<String,?> defaults)
Deprecated.
-
convertConfigToIni
protected Ini convertConfigToIni(String config)
Deprecated.
-
getServletContextIniResource
protected Ini getServletContextIniResource(String servletContextPath)
Deprecated.Returns the INI instance reflecting the specified servlet context resource path ornull
if 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
null
if no resource was found. - Since:
- 1.2
-
convertPathToIni
protected Ini convertPathToIni(String path)
Deprecated.Converts the specified file path to anIni
instance. If the path does not have a resource prefix as defined byResourceUtils.hasResourcePrefix(String)
, the path is expected to be resolvable by theServletContext
viaServletContext.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.
-
-