protected void afterCacheManagerSet() { super.afterCacheManagerSet(); //trigger obtaining the authorization cache if possible getAvailableAuthorizationCache(); }
/** * Initializes this realm and potentially enables a cache, depending on configuration. * <p/> * When this method is called, the following logic is executed: * <ol> * <li>If the {@link #setAuthorizationCache cache} property has been set, it will be * used to cache the AuthorizationInfo objects returned from {@link #getAuthorizationInfo} * method invocations. * All future calls to {@code getAuthorizationInfo} will attempt to use this cache first * to alleviate any potentially unnecessary calls to an underlying data store.</li> * <li>If the {@link #setAuthorizationCache cache} property has <b>not</b> been set, * the {@link #setCacheManager cacheManager} property will be checked. * If a {@code cacheManager} has been set, it will be used to create an authorization * {@code cache}, and this newly created cache which will be used as specified in #1.</li> * <li>If neither the {@link #setAuthorizationCache (org.apache.shiro.cache.Cache) cache} * or {@link #setCacheManager(org.apache.shiro.cache.CacheManager) cacheManager} * properties are set, caching will be disabled and authorization look-ups will be delegated to * subclass implementations for each authorization check.</li> * </ol> */ protected void onInit() { super.onInit(); //trigger obtaining the authorization cache if possible getAvailableAuthorizationCache(); }
/** * Clears out the AuthorizationInfo cache entry for the specified account. * <p/> * This method is provided as a convenience to subclasses so they can invalidate a cache entry when they * change an account's authorization data (add/remove roles or permissions) during runtime. Because an account's * AuthorizationInfo can be cached, there needs to be a way to invalidate the cache for only that account so that * subsequent authorization operations don't used the (old) cached value if account data changes. * <p/> * After this method is called, the next authorization check for that same account will result in a call to * {@link #getAuthorizationInfo(org.apache.shiro.subject.PrincipalCollection) getAuthorizationInfo}, and the * resulting return value will be cached before being returned so it can be reused for later authorization checks. * <p/> * If you wish to clear out all associated cached data (and not just authorization data), use the * {@link #clearCache(org.apache.shiro.subject.PrincipalCollection)} method instead (which will in turn call this * method by default). * * @param principals the principals of the account for which to clear the cached AuthorizationInfo. */ protected void clearCachedAuthorizationInfo(PrincipalCollection principals) { if (principals == null) { return; } Cache<Object, AuthorizationInfo> cache = getAvailableAuthorizationCache(); //cache instance will be non-null if caching is enabled: if (cache != null) { Object key = getAuthorizationCacheKey(principals); cache.remove(key); } }
Cache<Object, AuthorizationInfo> cache = getAvailableAuthorizationCache(); if (cache != null) { if (log.isTraceEnabled()) {
protected void afterCacheManagerSet() { super.afterCacheManagerSet(); //trigger obtaining the authorization cache if possible getAvailableAuthorizationCache(); }
/** * Initializes this realm and potentially enables a cache, depending on configuration. * <p/> * When this method is called, the following logic is executed: * <ol> * <li>If the {@link #setAuthorizationCache cache} property has been set, it will be * used to cache the AuthorizationInfo objects returned from {@link #getAuthorizationInfo} * method invocations. * All future calls to {@code getAuthorizationInfo} will attempt to use this cache first * to alleviate any potentially unnecessary calls to an underlying data store.</li> * <li>If the {@link #setAuthorizationCache cache} property has <b>not</b> been set, * the {@link #setCacheManager cacheManager} property will be checked. * If a {@code cacheManager} has been set, it will be used to create an authorization * {@code cache}, and this newly created cache which will be used as specified in #1.</li> * <li>If neither the {@link #setAuthorizationCache (org.apache.shiro.cache.Cache) cache} * or {@link #setCacheManager(org.apache.shiro.cache.CacheManager) cacheManager} * properties are set, caching will be disabled and authorization look-ups will be delegated to * subclass implementations for each authorization check.</li> * </ol> */ protected void onInit() { super.onInit(); //trigger obtaining the authorization cache if possible getAvailableAuthorizationCache(); }
/** * Clears out the AuthorizationInfo cache entry for the specified account. * <p/> * This method is provided as a convenience to subclasses so they can invalidate a cache entry when they * change an account's authorization data (add/remove roles or permissions) during runtime. Because an account's * AuthorizationInfo can be cached, there needs to be a way to invalidate the cache for only that account so that * subsequent authorization operations don't used the (old) cached value if account data changes. * <p/> * After this method is called, the next authorization check for that same account will result in a call to * {@link #getAuthorizationInfo(org.apache.shiro.subject.PrincipalCollection) getAuthorizationInfo}, and the * resulting return value will be cached before being returned so it can be reused for later authorization checks. * <p/> * If you wish to clear out all associated cached data (and not just authorization data), use the * {@link #clearCache(org.apache.shiro.subject.PrincipalCollection)} method instead (which will in turn call this * method by default). * * @param principals the principals of the account for which to clear the cached AuthorizationInfo. */ protected void clearCachedAuthorizationInfo(PrincipalCollection principals) { if (principals == null) { return; } Cache<Object, AuthorizationInfo> cache = getAvailableAuthorizationCache(); //cache instance will be non-null if caching is enabled: if (cache != null) { Object key = getAuthorizationCacheKey(principals); cache.remove(key); } }
Cache<Object, AuthorizationInfo> cache = getAvailableAuthorizationCache(); if (cache != null) { if (log.isTraceEnabled()) {
protected void afterCacheManagerSet() { //trigger obtaining the authorization cache if possible getAvailableAuthorizationCache(); }
/** * Initializes this realm and potentially enables a cache, depending on configuration. * <p/> * When this method is called, the following logic is executed: * <ol> * <li>If the {@link #setAuthorizationCache cache} property has been set, it will be * used to cache the AuthorizationInfo objects returned from {@link #getAuthorizationInfo} * method invocations. * All future calls to {@code getAuthorizationInfo} will attempt to use this cache first * to alleviate any potentially unnecessary calls to an underlying data store.</li> * <li>If the {@link #setAuthorizationCache cache} property has <b>not</b> been set, * the {@link #setCacheManager cacheManager} property will be checked. * If a {@code cacheManager} has been set, it will be used to create an authorization * {@code cache}, and this newly created cache which will be used as specified in #1.</li> * <li>If neither the {@link #setAuthorizationCache (org.apache.shiro.cache.Cache) cache} * or {@link #setCacheManager(org.apache.shiro.cache.CacheManager) cacheManager} * properties are set, caching will be disabled and authorization look-ups will be delegated to * subclass implementations for each authorization check.</li> * </ol> */ public final void init() { //trigger obtaining the authorization cache if possible getAvailableAuthorizationCache(); onInit(); }
/** * Clears out the AuthorizationInfo cache entry for the specified account. * <p/> * This method is provided as a convenience to subclasses so they can invalidate a cache entry when they * change an account's authorization data (add/remove roles or permissions) during runtime. Because an account's * AuthorizationInfo can be cached, there needs to be a way to invalidate the cache for only that account so that * subsequent authorization operations don't used the (old) cached value if account data changes. * <p/> * After this method is called, the next authorization check for that same account will result in a call to * {@link #getAuthorizationInfo(org.apache.shiro.subject.PrincipalCollection) getAuthorizationInfo}, and the * resulting return value will be cached before being returned so it can be reused for later authorization checks. * * @param principals the principals of the account for which to clear the cached AuthorizationInfo. */ protected void clearCachedAuthorizationInfo(PrincipalCollection principals) { if (principals == null) { return; } Cache<Object, AuthorizationInfo> cache = getAvailableAuthorizationCache(); //cache instance will be non-null if caching is enabled: if (cache != null) { Object key = getAuthorizationCacheKey(principals); cache.remove(key); } }
Cache<Object, AuthorizationInfo> cache = getAvailableAuthorizationCache(); if (cache != null) { if (log.isTraceEnabled()) {