public class IniWebEnvironment extends ResourceBasedWebEnvironment implements Initializable, Destroyable
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_WEB_INI_RESOURCE_PATH |
static String |
FILTER_CHAIN_RESOLVER_NAME |
DEFAULT_SECURITY_MANAGER_KEY, objects
Constructor and Description |
---|
IniWebEnvironment() |
Modifier and Type | Method and Description |
---|---|
protected void |
configure() |
protected FilterChainResolver |
createFilterChainResolver() |
protected Ini |
createIni(String configLocation,
boolean required)
Creates an
Ini instance reflecting the specified path, or null 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 and classpath:shiro.ini . |
protected Ini |
getDefaultIni() |
protected Map<String,Object> |
getDefaults() |
protected Ini |
getFrameworkIni()
Extension point to allow subclasses to provide an
Ini configuration that will be merged into the
users configuration. |
Ini |
getIni()
Returns the
Ini 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 configuration
Ini from ResourceBasedWebEnvironment.getConfigLocations() if set, otherwise falling back
to the getDefaultConfigLocations() . |
void |
setIni(Ini ini)
Allows for configuration via a direct
Ini instance instead of via
config locations . |
protected void |
setSecurityManagerFactory(WebIniSecurityManagerFactory factory)
Allows for setting the SecurityManager factory which will be used to create the SecurityManager.
|
getConfigLocations, setConfigLocations, setConfigLocations
getFilterChainResolver, getSecurityManager, getServletContext, getWebSecurityManager, setFilterChainResolver, setSecurityManager, setServletContext, setWebSecurityManager
destroy, getObject, getObjects, getSecurityManagerName, lookupSecurityManager, setObject, setSecurityManagerName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
destroy
public static final String DEFAULT_WEB_INI_RESOURCE_PATH
public static final String FILTER_CHAIN_RESOLVER_NAME
public IniWebEnvironment()
public void init()
Ini
configuration and calling configure
for actual instance configuration.init
in interface Initializable
protected Ini parseConfig()
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()
protected void configure()
protected Ini getFrameworkIni()
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 MyCustomRealm
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
protected Ini getSpecifiedIni(String[] configLocations) throws ConfigurationException
ConfigurationException
protected Ini getDefaultIni()
protected Ini createIni(String configLocation, boolean required) throws ConfigurationException
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.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.Ini
instance reflecting the specified path, or null
if the path does not exist and
is not required.ConfigurationException
- if the path is required but results in a null or empty Ini instance.protected FilterChainResolver createFilterChainResolver()
protected WebSecurityManager createWebSecurityManager()
protected String[] getDefaultConfigLocations()
/WEB-INF/shiro.ini
and classpath:shiro.ini
./WEB-INF/shiro.ini
and classpath:shiro.ini
.public Ini getIni()
Ini
instance reflecting this WebEnvironment's configuration.Ini
instance reflecting this WebEnvironment's configuration.public void setIni(Ini ini)
Ini
instance instead of via
config locations
.
If the specified instance is null or empty, the fallback/default resource-based configuration will be used.ini
- the ini instance to use for creation.protected Map<String,Object> getDefaults()
protected WebIniSecurityManagerFactory getSecurityManagerFactory()
protected void setSecurityManagerFactory(WebIniSecurityManagerFactory factory)
factory
- the SecurityManager factory to used.Copyright © 2004–2019 The Apache Software Foundation. All rights reserved.