protected AuthorizationInfo getAuthorizationInfo()

in core/src/main/java/org/apache/shiro/realm/AuthorizingRealm.java [331:374]


    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {

        if (principals == null) {
            return null;
        }

        AuthorizationInfo info = null;

        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Retrieving AuthorizationInfo for principals [" + principals + "]");
        }

        Cache<Object, AuthorizationInfo> cache = getAvailableAuthorizationCache();
        if (cache != null) {
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Attempting to retrieve the AuthorizationInfo from cache.");
            }
            Object key = getAuthorizationCacheKey(principals);
            info = cache.get(key);
            if (LOGGER.isTraceEnabled()) {
                if (info == null) {
                    LOGGER.trace("No AuthorizationInfo found in cache for principals [" + principals + "]");
                } else {
                    LOGGER.trace("AuthorizationInfo found in cache for principals [" + principals + "]");
                }
            }
        }


        if (info == null) {
            // Call template method if the info was not found in a cache
            info = doGetAuthorizationInfo(principals);
            // If the info is not null and the cache has been created, then cache the authorization info.
            if (info != null && cache != null) {
                if (LOGGER.isTraceEnabled()) {
                    LOGGER.trace("Caching authorization info for principals: [" + principals + "].");
                }
                Object key = getAuthorizationCacheKey(principals);
                cache.put(key, info);
            }
        }

        return info;
    }