Class IniWebEnvironment

java.lang.Object
org.apache.shiro.env.DefaultEnvironment
All Implemented Interfaces:
org.apache.shiro.config.ResourceConfigurable, org.apache.shiro.env.Environment, org.apache.shiro.env.NamedObjectEnvironment, org.apache.shiro.lang.util.Destroyable, org.apache.shiro.lang.util.Initializable, MutableWebEnvironment, WebEnvironment

public class IniWebEnvironment extends ResourceBasedWebEnvironment implements org.apache.shiro.lang.util.Initializable, org.apache.shiro.lang.util.Destroyable
WebEnvironment implementation configured by an Ini instance or Ini resource locations.
Since:
1.2
  • Field Details

  • Constructor Details

  • Method Details

    • init

      public void init()
      Initializes this instance by resolving any potential (explicit or resource-configured) Ini configuration and calling configure for actual instance configuration.
      Specified by:
      init in interface org.apache.shiro.lang.util.Initializable
    • parseConfig

      protected org.apache.shiro.config.Ini parseConfig()
      Loads configuration Ini from ResourceBasedWebEnvironment.getConfigLocations() if set, otherwise falling back to the getDefaultConfigLocations(). Finally any Ini objects will be merged with the value returned from getFrameworkIni()
      Returns:
      Ini configuration to be used by this Environment.
      Since:
      1.4
    • configure

      protected void configure()
    • getFrameworkIni

      protected org.apache.shiro.config.Ini getFrameworkIni()
      Extension point to allow subclasses to provide an Ini configuration that will be merged into the users configuration. The users configuration will override anything set here.

      NOTE: Framework developers should use with caution. It is possible a user could provide configuration that would conflict with the frameworks configuration. For example: if this method returns an Ini object with the following configuration:

      
           [main]
           realm = com.myco.FoobarRealm
           realm.foobarSpecificField = A string
       
      And the user provides a similar configuration:
      
           [main]
           realm = net.differentco.MyCustomRealm
       

      This would merge into:

      
           [main]
           realm = net.differentco.MyCustomRealm
           realm.foobarSpecificField = A string
       

      This may cause a configuration error if MyCustomRealminvalid input: '<'/code does not contain the field foobarSpecificField. This can be avoided if the Framework Ini uses more unique names, such as foobarRealm. which would result in a merged configuration that looks like:

      
           [main]
           foobarRealm = com.myco.FoobarRealm
           foobarRealm.foobarSpecificField = A string
           realm = net.differentco.MyCustomRealm
       

      Returns:
      Ini configuration used by the framework integrations.
      Since:
      1.4
    • getSpecifiedIni

      protected org.apache.shiro.config.Ini getSpecifiedIni(String[] configLocations) throws org.apache.shiro.config.ConfigurationException
      Throws:
      org.apache.shiro.config.ConfigurationException
    • mergeIni

      protected org.apache.shiro.config.Ini mergeIni(org.apache.shiro.config.Ini ini1, org.apache.shiro.config.Ini ini2)
    • getDefaultIni

      protected org.apache.shiro.config.Ini getDefaultIni()
    • createIni

      protected org.apache.shiro.config.Ini createIni(String configLocation, boolean required) throws org.apache.shiro.config.ConfigurationException
      Creates an Ini instance reflecting the specified path, or null if the path does not exist and is not required.

      If the path is required and does not exist or is empty, a ConfigurationException will be thrown.

      Parameters:
      configLocation - the resource path to load into an Ini instance.
      required - if the path must exist and be converted to a non-empty Ini instance.
      Returns:
      an Ini instance reflecting the specified path, or null if the path does not exist and is not required.
      Throws:
      org.apache.shiro.config.ConfigurationException - if the path is required but results in a null or empty Ini instance.
    • createFilterConfiguration

    • createFilterChainResolver

    • createWebSecurityManager

    • getDefaultConfigLocations

      Returns an array with two elements, /WEB-INF/shiro.ini and classpath:shiro.ini.
      Returns:
      an array with two elements, /WEB-INF/shiro.ini and classpath:shiro.ini.
    • getIni

      public org.apache.shiro.config.Ini getIni()
      Returns the Ini instance reflecting this WebEnvironment's configuration.
      Returns:
      the Ini instance reflecting this WebEnvironment's configuration.
    • setIni

      public void setIni(org.apache.shiro.config.Ini ini)
      Allows for configuration via a direct Ini instance instead of via config locations.

      If the specified instance is null or empty, the fallback/default resource-based configuration will be used.

      Parameters:
      ini - the ini instance to use for creation.
    • getDefaults

      protected Map<String,Object> getDefaults()
    • getSecurityManagerFactory

      Returns the SecurityManager factory used by this WebEnvironment.
      Returns:
      the SecurityManager factory used by this WebEnvironment.
      Since:
      1.4
    • setSecurityManagerFactory

      Allows for setting the SecurityManager factory which will be used to create the SecurityManager.
      Parameters:
      factory - the SecurityManager factory to used.
      Since:
      1.4