Example usage for org.apache.shiro.realm AuthorizingRealm isAuthorizationCachingEnabled

List of usage examples for org.apache.shiro.realm AuthorizingRealm isAuthorizationCachingEnabled

Introduction

In this page you can find the example usage for org.apache.shiro.realm AuthorizingRealm isAuthorizationCachingEnabled.

Prototype

public boolean isAuthorizationCachingEnabled() 

Source Link

Document

Returns true if authorization caching should be utilized if a CacheManager has been #setCacheManager(org.apache.shiro.cache.CacheManager) configured , false otherwise.

Usage

From source file:org.pepstock.jem.gwt.server.RolesManagerServiceImpl.java

License:Open Source License

/**
 * This method clears all authorizations cache when a role is changed.<br>
 * That's necessary to invalidate the cache and then to have the updates
 * soon available.//from  w  w  w. j  a v a 2s  .c  o  m
 */
private void clearAuthorizationCache() {
    RealmSecurityManager mgr = (RealmSecurityManager) SecurityUtils.getSecurityManager();
    Collection<Realm> realmCollection = mgr.getRealms();
    for (Realm realm : realmCollection) {
        if (realm instanceof AuthorizingRealm) {
            AuthorizingRealm authz = (AuthorizingRealm) realm;
            if (authz.isAuthorizationCachingEnabled()) {
                authz.getAuthorizationCache().clear();
            }
        }
    }
}