Class CachingSecurityManager

  • 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:
    RealmSecurityManager

    public abstract class CachingSecurityManager
    extends 
    implements SecurityManager, org.apache.shiro.util.Destroyable, org.apache.shiro.cache.CacheManagerAware, org.apache.shiro.event.EventBusAware
    A very basic starting point for the SecurityManager interface that merely provides logging and caching support. All actual SecurityManager method implementations are left to subclasses.

    Change in 1.0 - a default CacheManager instance is not created by default during instantiation. As caching strategies can vary greatly depending on an application's needs, a CacheManager instance must be explicitly configured if caching across the framework is to be enabled.

    Since:
    0.9
    • Constructor Detail

      • CachingSecurityManager

        public CachingSecurityManager()
        Default no-arg constructor that will automatically attempt to initialize a default cacheManager
    • Method Detail

      • getCacheManager

        public org.apache.shiro.cache.CacheManager getCacheManager()
        Returns the CacheManager used by this SecurityManager.
        Returns:
        the cacheManager used by this SecurityManager
      • setCacheManager

        public void setCacheManager​(org.apache.shiro.cache.CacheManager cacheManager)
        Sets the CacheManager used by this SecurityManager and potentially any of its children components.

        After the cacheManager attribute has been set, the template method afterCacheManagerSet() is executed to allow subclasses to adjust when a cacheManager is available.

        Specified by:
        setCacheManager in interface org.apache.shiro.cache.CacheManagerAware
        Parameters:
        cacheManager - the CacheManager used by this SecurityManager and potentially any of its children components.
      • afterCacheManagerSet

        protected void afterCacheManagerSet()
        Template callback to notify subclasses that a CacheManager has been set and is available for use via the getCacheManager() method.
      • getEventBus

        public org.apache.shiro.event.EventBus getEventBus()
        Returns the EventBus used by this SecurityManager and potentially any of its children components.
        Returns:
        the EventBus used by this SecurityManager and potentially any of its children components.
        Since:
        1.3
      • setEventBus

        public void setEventBus​(org.apache.shiro.event.EventBus eventBus)
        Sets the EventBus used by this SecurityManager and potentially any of its children components.

        After the eventBus attribute has been set, the template method afterEventBusSet() is executed to allow subclasses to adjust when a eventBus is available.

        Specified by:
        setEventBus in interface org.apache.shiro.event.EventBusAware
        Parameters:
        eventBus - the EventBus used by this SecurityManager and potentially any of its children components.
        Since:
        1.3
      • applyEventBusToCacheManager

        protected void applyEventBusToCacheManager()
        Since:
        1.3
      • afterEventBusSet

        protected void afterEventBusSet()
        Template callback to notify subclasses that an EventBus has been set and is available for use via the getEventBus() method.
        Since:
        1.3
      • destroy

        public void destroy()
        Destroys the cacheManager via LifecycleUtils.destroy.
        Specified by:
        destroy in interface org.apache.shiro.util.Destroyable