Package org.apache.shiro.mgt
Class RealmSecurityManager
- java.lang.Object
-
- org.apache.shiro.mgt.CachingSecurityManager
-
- org.apache.shiro.mgt.RealmSecurityManager
-
- All Implemented Interfaces:
Authenticator
,Authorizer
,org.apache.shiro.cache.CacheManagerAware
,org.apache.shiro.event.EventBusAware
,SecurityManager
,SessionManager
,org.apache.shiro.util.Destroyable
- Direct Known Subclasses:
AuthenticatingSecurityManager
public abstract class RealmSecurityManager extends CachingSecurityManager
Shiro support of aSecurityManager
class hierarchy based around a collection ofRealm
s. All actualSecurityManager
method implementations are left to subclasses.- Since:
- 0.9
-
-
Constructor Summary
Constructors Constructor Description RealmSecurityManager()
Default no-arg constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
afterCacheManagerSet()
Simply callsapplyCacheManagerToRealms()
to allow the newly setCacheManager
to be propagated to the internal collection ofRealm
that would need to use it.protected void
afterEventBusSet()
Template callback to notify subclasses that anEventBus
has been set and is available for use via thegetEventBus()
method.protected void
afterRealmsSet()
protected void
applyCacheManagerToRealms()
Sets the internalCacheManager
on any internal configuredRealms
that implement theCacheManagerAware
interface.protected void
applyEventBusToRealms()
void
destroy()
Destroys thecacheManager
viaLifecycleUtils.destroy
.Collection<Realm>
getRealms()
Returns theRealm
s managed by this SecurityManager instance.void
setRealm(Realm realm)
Convenience method for applications using a single realm that merely wraps the realm in a list and then invokes thesetRealms(java.util.Collection<org.apache.shiro.realm.Realm>)
method.void
setRealms(Collection<Realm> realms)
Sets the realms managed by this SecurityManager instance.-
Methods inherited from class org.apache.shiro.mgt.CachingSecurityManager
applyEventBusToCacheManager, getCacheManager, getEventBus, setCacheManager, setEventBus
-
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.authc.Authenticator
authenticate
-
Methods inherited from interface org.apache.shiro.authz.Authorizer
checkPermission, checkPermission, checkPermissions, checkPermissions, checkRole, checkRoles, checkRoles, hasAllRoles, hasRole, hasRoles, isPermitted, isPermitted, isPermitted, isPermitted, isPermittedAll, isPermittedAll
-
Methods inherited from interface org.apache.shiro.mgt.SecurityManager
createSubject, login, logout
-
Methods inherited from interface org.apache.shiro.session.mgt.SessionManager
getSession, start
-
-
-
-
Method Detail
-
setRealm
public void setRealm(Realm realm)
Convenience method for applications using a single realm that merely wraps the realm in a list and then invokes thesetRealms(java.util.Collection<org.apache.shiro.realm.Realm>)
method.- Parameters:
realm
- the realm to set for a single-realm application.- Since:
- 0.2
-
setRealms
public void setRealms(Collection<Realm> realms)
Sets the realms managed by this SecurityManager instance.- Parameters:
realms
- the realms managed by this SecurityManager instance.- Throws:
IllegalArgumentException
- if the realms collection is null or empty.
-
afterRealmsSet
protected void afterRealmsSet()
-
getRealms
public Collection<Realm> getRealms()
Returns theRealm
s managed by this SecurityManager instance.- Returns:
- the
Realm
s managed by this SecurityManager instance.
-
applyCacheManagerToRealms
protected void applyCacheManagerToRealms()
Sets the internalCacheManager
on any internal configuredRealms
that implement theCacheManagerAware
interface. This method is called after setting a cacheManager on this securityManager via thesetCacheManager
method to allow it to be propagated down to all the internal Realms that would need to use it. It is also called after setting one or more realms via thesetRealm
orsetRealms
methods to allow these newly available realms to be given the cache manager already in use.
-
applyEventBusToRealms
protected void applyEventBusToRealms()
Sets the internalEventBus
on any internal configuredRealms
that implement theEventBusAware
interface. This method is called after setting an eventBus on this securityManager via thesetEventBus
method to allow it to be propagated down to all the internal Realms that would need to use it. It is also called after setting one or more realms via thesetRealm
orsetRealms
methods to allow these newly available realms to be given the EventBus already in use.- Since:
- 1.3
-
afterCacheManagerSet
protected void afterCacheManagerSet()
Simply callsapplyCacheManagerToRealms()
to allow the newly setCacheManager
to be propagated to the internal collection ofRealm
that would need to use it.- Overrides:
afterCacheManagerSet
in classCachingSecurityManager
-
afterEventBusSet
protected void afterEventBusSet()
Description copied from class:CachingSecurityManager
Template callback to notify subclasses that anEventBus
has been set and is available for use via thegetEventBus()
method.- Overrides:
afterEventBusSet
in classCachingSecurityManager
-
destroy
public void destroy()
Description copied from class:CachingSecurityManager
Destroys thecacheManager
viaLifecycleUtils.destroy
.- Specified by:
destroy
in interfaceorg.apache.shiro.util.Destroyable
- Overrides:
destroy
in classCachingSecurityManager
-
-