Package org.apache.shiro.web.env
Class IniWebEnvironment
- java.lang.Object
-
- org.apache.shiro.env.DefaultEnvironment
-
- org.apache.shiro.web.env.DefaultWebEnvironment
-
- org.apache.shiro.web.env.ResourceBasedWebEnvironment
-
- org.apache.shiro.web.env.IniWebEnvironment
-
- All Implemented Interfaces:
org.apache.shiro.config.ResourceConfigurable,org.apache.shiro.env.Environment,org.apache.shiro.env.NamedObjectEnvironment,org.apache.shiro.util.Destroyable,org.apache.shiro.util.Initializable,MutableWebEnvironment,WebEnvironment
public class IniWebEnvironment extends ResourceBasedWebEnvironment implements org.apache.shiro.util.Initializable, org.apache.shiro.util.Destroyable
- Since:
- 1.2
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_WEB_INI_RESOURCE_PATHstatic StringFILTER_CHAIN_RESOLVER_NAMEstatic StringSHIRO_FILTER_CONFIG_NAME
-
Constructor Summary
Constructors Constructor Description IniWebEnvironment()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconfigure()protected FilterChainResolvercreateFilterChainResolver()protected ShiroFilterConfigurationcreateFilterConfiguration()protected org.apache.shiro.config.InicreateIni(String configLocation, boolean required)Creates anIniinstance reflecting the specified path, ornullif the path does not exist and is not required.protected WebSecurityManagercreateWebSecurityManager()protected String[]getDefaultConfigLocations()Returns an array with two elements,/WEB-INF/shiro.iniandclasspath:shiro.ini.protected org.apache.shiro.config.InigetDefaultIni()protected Map<String,Object>getDefaults()protected org.apache.shiro.config.InigetFrameworkIni()Extension point to allow subclasses to provide anIniconfiguration that will be merged into the users configuration.org.apache.shiro.config.InigetIni()Returns theIniinstance reflecting this WebEnvironment's configuration.protected WebIniSecurityManagerFactorygetSecurityManagerFactory()Returns the SecurityManager factory used by this WebEnvironment.protected org.apache.shiro.config.InigetSpecifiedIni(String[] configLocations)voidinit()Initializes this instance by resolving any potential (explicit or resource-configured)Iniconfiguration and callingconfigurefor actual instance configuration.protected org.apache.shiro.config.InimergeIni(org.apache.shiro.config.Ini ini1, org.apache.shiro.config.Ini ini2)protected org.apache.shiro.config.IniparseConfig()Loads configurationInifromResourceBasedWebEnvironment.getConfigLocations()if set, otherwise falling back to thegetDefaultConfigLocations().voidsetIni(org.apache.shiro.config.Ini ini)Allows for configuration via a directIniinstance instead of viaconfig locations.protected voidsetSecurityManagerFactory(WebIniSecurityManagerFactory factory)Allows for setting the SecurityManager factory which will be used to create the SecurityManager.-
Methods inherited from class org.apache.shiro.web.env.ResourceBasedWebEnvironment
getConfigLocations, setConfigLocations, setConfigLocations
-
Methods inherited from class org.apache.shiro.web.env.DefaultWebEnvironment
getFilterChainResolver, getSecurityManager, getServletContext, getShiroFilterConfiguration, getWebSecurityManager, setFilterChainResolver, setSecurityManager, setServletContext, setShiroFilterConfiguration, setWebSecurityManager
-
Methods inherited from class org.apache.shiro.env.DefaultEnvironment
destroy, getObject, getObjects, getSecurityManagerName, lookupSecurityManager, setObject, setSecurityManagerName
-
-
-
-
Field Detail
-
DEFAULT_WEB_INI_RESOURCE_PATH
public static final String DEFAULT_WEB_INI_RESOURCE_PATH
- See Also:
- Constant Field Values
-
FILTER_CHAIN_RESOLVER_NAME
public static final String FILTER_CHAIN_RESOLVER_NAME
- See Also:
- Constant Field Values
-
SHIRO_FILTER_CONFIG_NAME
public static final String SHIRO_FILTER_CONFIG_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init()
Initializes this instance by resolving any potential (explicit or resource-configured)Iniconfiguration and callingconfigurefor actual instance configuration.- Specified by:
initin interfaceorg.apache.shiro.util.Initializable
-
parseConfig
protected org.apache.shiro.config.Ini parseConfig()
Loads configurationInifromResourceBasedWebEnvironment.getConfigLocations()if set, otherwise falling back to thegetDefaultConfigLocations(). Finally any Ini objects will be merged with the value returned fromgetFrameworkIni()- 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 anIniconfiguration 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:
And the user provides a similar configuration:[main] realm = com.myco.FoobarRealm realm.foobarSpecificField = A string
This would merge into:[main] realm = net.differentco.MyCustomRealm
This may cause a configuration error if[main] realm = net.differentco.MyCustomRealm realm.foobarSpecificField = A stringMyCustomRealmdoes not contain the fieldfoobarSpecificField. This can be avoided if the Framework Ini uses more unique names, such asfoobarRealm. 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 anIniinstance reflecting the specified path, ornullif the path does not exist and is not required. If the path is required and does not exist or is empty, aConfigurationExceptionwill be thrown.- Parameters:
configLocation- the resource path to load into anIniinstance.required- if the path must exist and be converted to a non-emptyIniinstance.- Returns:
- an
Iniinstance reflecting the specified path, ornullif 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
protected ShiroFilterConfiguration createFilterConfiguration()
-
createFilterChainResolver
protected FilterChainResolver createFilterChainResolver()
-
createWebSecurityManager
protected WebSecurityManager createWebSecurityManager()
-
getDefaultConfigLocations
protected String[] getDefaultConfigLocations()
Returns an array with two elements,/WEB-INF/shiro.iniandclasspath:shiro.ini.- Returns:
- an array with two elements,
/WEB-INF/shiro.iniandclasspath:shiro.ini.
-
getIni
public org.apache.shiro.config.Ini getIni()
Returns theIniinstance reflecting this WebEnvironment's configuration.- Returns:
- the
Iniinstance reflecting this WebEnvironment's configuration.
-
setIni
public void setIni(org.apache.shiro.config.Ini ini)
Allows for configuration via a directIniinstance instead of viaconfig 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.
-
getSecurityManagerFactory
protected WebIniSecurityManagerFactory getSecurityManagerFactory()
Returns the SecurityManager factory used by this WebEnvironment.- Returns:
- the SecurityManager factory used by this WebEnvironment.
- Since:
- 1.4
-
setSecurityManagerFactory
protected void setSecurityManagerFactory(WebIniSecurityManagerFactory factory)
Allows for setting the SecurityManager factory which will be used to create the SecurityManager.- Parameters:
factory- the SecurityManager factory to used.- Since:
- 1.4
-
-