Class IniShiroFilter

  • All Implemented Interfaces:
    Filter, Nameable

    @Deprecated
    public class IniShiroFilter
    extends AbstractShiroFilter
    Deprecated.
    in 1.2 in favor of using the ShiroFilter

    Deprecated

    This filter has been deprecated as of Shiro 1.2 in favor of using the ShiroFilter 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 a shiro.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 the config 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
    • Method Detail

      • getConfig

        public String getConfig()
        Deprecated.
        Returns the actual INI configuration text to use to build the SecurityManager and FilterChainResolver used by the web application or null if the configPath should be used to load a fallback INI source.

        This value is null by default, but it will be automatically set to the value of the 'config' init-param if it exists in the FilterConfig provided by the servlet container at startup.

        Returns:
        the actual INI configuration text to use to build the SecurityManager and FilterChainResolver used by the web application or null if the configPath 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 the SecurityManager and FilterChainResolver used by the web application. If this value is null, the configPath will be checked to see if a .ini file should be loaded instead.

        This value is null by default, but it will be automatically set to the value of the 'config' init-param if it exists in the FilterConfig provided by the servlet container at startup.

        Parameters:
        config - the actual INI configuration text to use to build the SecurityManager and FilterChainResolver 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 the config attribute.

        This value is null by default, but it will be automatically set to the value of the 'configPath' init-param if it exists in the FilterConfig 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 the config attribute.

        This value is null by default, but it will be automatically set to the value of the 'configPath' init-param if it exists in the FilterConfig 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 the config attribute.
      • getServletContextIniResource

        protected Ini getServletContextIniResource​(String servletContextPath)
        Deprecated.
        Returns the INI instance reflecting the specified servlet context resource path or null 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