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:
ResourceConfigurable
,Environment
,NamedObjectEnvironment
,Destroyable
,Initializable
,MutableWebEnvironment
,WebEnvironment
public class IniWebEnvironment extends ResourceBasedWebEnvironment implements Initializable, Destroyable
- Since:
- 1.2
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_WEB_INI_RESOURCE_PATH
static String
FILTER_CHAIN_RESOLVER_NAME
-
Fields inherited from class org.apache.shiro.env.DefaultEnvironment
DEFAULT_SECURITY_MANAGER_KEY, objects
-
-
Constructor Summary
Constructors Constructor Description IniWebEnvironment()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
configure()
protected FilterChainResolver
createFilterChainResolver()
protected Ini
createIni(String configLocation, boolean required)
Creates anIni
instance reflecting the specified path, ornull
if the path does not exist and is not required.protected WebSecurityManager
createWebSecurityManager()
protected String[]
getDefaultConfigLocations()
Returns an array with two elements,/WEB-INF/shiro.ini
andclasspath:shiro.ini
.protected Ini
getDefaultIni()
protected Map<String,Object>
getDefaults()
protected Ini
getFrameworkIni()
Extension point to allow subclasses to provide anIni
configuration that will be merged into the users configuration.Ini
getIni()
Returns theIni
instance reflecting this WebEnvironment's configuration.protected WebIniSecurityManagerFactory
getSecurityManagerFactory()
Returns the SecurityManager factory used by this WebEnvironment.protected Ini
getSpecifiedIni(String[] configLocations)
void
init()
protected Ini
mergeIni(Ini ini1, Ini ini2)
protected Ini
parseConfig()
Loads configurationIni
fromResourceBasedWebEnvironment.getConfigLocations()
if set, otherwise falling back to thegetDefaultConfigLocations()
.void
setIni(Ini ini)
Allows for configuration via a directIni
instance instead of viaconfig locations
.protected void
setSecurityManagerFactory(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, getWebSecurityManager, setFilterChainResolver, setSecurityManager, setServletContext, setWebSecurityManager
-
Methods inherited from class org.apache.shiro.env.DefaultEnvironment
destroy, getObject, getObjects, getSecurityManagerName, lookupSecurityManager, setObject, setSecurityManagerName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.shiro.util.Destroyable
destroy
-
-
-
-
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
-
-
Constructor Detail
-
IniWebEnvironment
public IniWebEnvironment()
-
-
Method Detail
-
init
public void init()
Initializes this instance by resolving any potential (explicit or resource-configured)Ini
configuration and callingconfigure
for actual instance configuration.- Specified by:
init
in interfaceInitializable
-
parseConfig
protected Ini parseConfig()
Loads configurationIni
fromResourceBasedWebEnvironment.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 Ini getFrameworkIni()
Extension point to allow subclasses to provide anIni
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:
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 string
MyCustomRealm
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 Ini getSpecifiedIni(String[] configLocations) throws ConfigurationException
- Throws:
ConfigurationException
-
getDefaultIni
protected Ini getDefaultIni()
-
createIni
protected Ini createIni(String configLocation, boolean required) throws ConfigurationException
Creates anIni
instance reflecting the specified path, ornull
if the path does not exist and is not required. If the path is required and does not exist or is empty, aConfigurationException
will be thrown.- Parameters:
configLocation
- the resource path to load into anIni
instance.required
- if the path must exist and be converted to a non-emptyIni
instance.- Returns:
- an
Ini
instance reflecting the specified path, ornull
if the path does not exist and is not required. - Throws:
ConfigurationException
- if the path is required but results in a null or empty Ini instance.
-
createFilterChainResolver
protected FilterChainResolver createFilterChainResolver()
-
createWebSecurityManager
protected WebSecurityManager createWebSecurityManager()
-
getDefaultConfigLocations
protected String[] getDefaultConfigLocations()
Returns an array with two elements,/WEB-INF/shiro.ini
andclasspath:shiro.ini
.- Returns:
- an array with two elements,
/WEB-INF/shiro.ini
andclasspath:shiro.ini
.
-
getIni
public Ini getIni()
Returns theIni
instance reflecting this WebEnvironment's configuration.- Returns:
- the
Ini
instance reflecting this WebEnvironment's configuration.
-
setIni
public void setIni(Ini ini)
Allows for configuration via a directIni
instance 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
protected Map<String,Object> getDefaults()
-
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
-
-