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.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
- Since:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringweb ini resource path.static final Stringfilter chain resolver name.static final Stringshiro filter config name.Fields inherited from class org.apache.shiro.env.DefaultEnvironment
DEFAULT_SECURITY_MANAGER_KEY, objects -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected FilterChainResolverprotected ShiroFilterConfigurationprotected org.apache.shiro.config.IniCreates anIniinstance reflecting the specified path, ornullif the path does not exist and is not required.protected WebSecurityManagerprotected String[]Returns an array with two elements,/WEB-INF/shiro.iniandclasspath:shiro.ini.protected org.apache.shiro.config.Iniprotected org.apache.shiro.config.IniExtension 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 WebIniSecurityManagerFactoryReturns 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.IniLoads 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 voidAllows 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, setConfigLocationsMethods inherited from class org.apache.shiro.web.env.DefaultWebEnvironment
getFilterChainResolver, getSecurityManager, getServletContext, getShiroFilterConfiguration, getWebSecurityManager, setFilterChainResolver, setSecurityManager, setServletContext, setShiroFilterConfiguration, setWebSecurityManagerMethods inherited from class org.apache.shiro.env.DefaultEnvironment
destroy, getObject, getObjects, getSecurityManagerName, lookupSecurityManager, setObject, setSecurityManagerNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.shiro.lang.util.Destroyable
destroy
-
Field Details
-
DEFAULT_WEB_INI_RESOURCE_PATH
web ini resource path.- See Also:
-
FILTER_CHAIN_RESOLVER_NAME
filter chain resolver name.- See Also:
-
SHIRO_FILTER_CONFIG_NAME
shiro filter config name.- See Also:
-
-
Constructor Details
-
IniWebEnvironment
public IniWebEnvironment()
-
-
Method Details
-
init
Initializes this instance by resolving any potential (explicit or resource-configured)Iniconfiguration and callingconfigurefor actual instance configuration.- Specified by:
initin interfaceorg.apache.shiro.lang.util.Initializable
-
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
-
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[main] realm = net.differentco.MyCustomRealmThis would merge into:
[main] realm = net.differentco.MyCustomRealm realm.foobarSpecificField = A stringThis may cause a configuration error if
MyCustomRealminvalid input: '<'/code does 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
-
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
-
createFilterChainResolver
-
createWebSecurityManager
-
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
Returns theIniinstance reflecting this WebEnvironment's configuration.- Returns:
- the
Iniinstance reflecting this WebEnvironment's configuration.
-
setIni
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.
-
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
-