protected void afterCacheManagerSet() { super.afterCacheManagerSet(); //trigger obtaining the authorization cache if possible getAvailableAuthorizationCache(); }
/** * This implementation clears out any cached authentication data by calling * {@link #clearCachedAuthenticationInfo(org.apache.shiro.subject.PrincipalCollection)}. * If overriding in a subclass, be sure to call {@code super.doClearCache} to ensure this behavior is maintained. * * @param principals principals the principals of the account for which to clear any cached data. * @since 1.2 */ @Override protected void doClearCache(PrincipalCollection principals) { super.doClearCache(principals); clearCachedAuthenticationInfo(principals); }
/** * Returns {@code true} if authorization caching should be utilized if a {@link CacheManager} has been * {@link #setCacheManager(org.apache.shiro.cache.CacheManager) configured}, {@code false} otherwise. * <p/> * The default value is {@code true}. * * @return {@code true} if authorization caching should be utilized, {@code false} otherwise. */ public boolean isAuthorizationCachingEnabled() { return isCachingEnabled() && authorizationCachingEnabled; }
private Cache<Object, AuthorizationInfo> getAvailableAuthorizationCache() { Cache<Object, AuthorizationInfo> cache = getAuthorizationCache(); if (cache == null && isAuthorizationCachingEnabled()) { cache = getAuthorizationCacheLazy(); } return cache; }
public boolean hasRole(PrincipalCollection principal, String roleIdentifier) { AuthorizationInfo info = getAuthorizationInfo(principal); return hasRole(roleIdentifier, info); }
public boolean isPermitted(PrincipalCollection principals, Permission permission) { AuthorizationInfo info = getAuthorizationInfo(principals); return isPermitted(permission, info); }
public void checkPermission(PrincipalCollection principal, Permission permission) throws AuthorizationException { AuthorizationInfo info = getAuthorizationInfo(principal); checkPermission(permission, info); }
public void checkPermissions(PrincipalCollection principal, Collection<Permission> permissions) throws AuthorizationException { AuthorizationInfo info = getAuthorizationInfo(principal); checkPermissions(permissions, info); }
public void checkRoles(PrincipalCollection principal, Collection<String> roles) throws AuthorizationException { AuthorizationInfo info = getAuthorizationInfo(principal); checkRoles(roles, info); }
public boolean isPermittedAll(PrincipalCollection principal, Collection<Permission> permissions) { AuthorizationInfo info = getAuthorizationInfo(principal); return info != null && isPermittedAll(permissions, info); }
public boolean hasAllRoles(PrincipalCollection principal, Collection<String> roleIdentifiers) { AuthorizationInfo info = getAuthorizationInfo(principal); return info != null && hasAllRoles(roleIdentifiers, info); }
public void checkRole(PrincipalCollection principal, String role) throws AuthorizationException { AuthorizationInfo info = getAuthorizationInfo(principal); checkRole(role, info); }
public void checkPermissions(PrincipalCollection subjectIdentifier, String... permissions) throws AuthorizationException { if (permissions != null) { for (String permString : permissions) { checkPermission(subjectIdentifier, permString); } } }
protected AuthenticationInfo buildAuthenticationInfo(Object principal, Object credentials) { Collection<Object> principals = new ArrayList<Object>(3); principals.add(new UserIdPrincipal(USER_ID)); principals.add(new UsernamePrincipal(USERNAME)); principals.add(USER_ID + USERNAME); return new SimpleAuthenticationInfo(principals, PASSWORD, getName()); }
/** * Sets the <tt>CacheManager</tt> to be used for data caching to reduce EIS round trips. * <p/> * This property is <tt>null</tt> by default, indicating that caching is turned off. * * @param cacheManager the <tt>CacheManager</tt> to use for data caching, or <tt>null</tt> to disable caching. */ public void setCacheManager(CacheManager cacheManager) { this.cacheManager = cacheManager; afterCacheManagerSet(); }
public void addAccount(String username, String password) { addAccount(username, password, (String[]) null); }
@Override protected AuthenticationInfo buildAuthenticationInfo(Object principal, Object credentials) { String username = (String) principal; UsernamePrincipal customPrincipal = new UsernamePrincipal(username); return new SimpleAccount(customPrincipal, credentials, getName()); } };
/** * Returns {@code true} if authentication caching should be utilized if a {@link CacheManager} has been * {@link #setCacheManager(org.apache.shiro.cache.CacheManager) configured}, {@code false} otherwise. * <p/> * The default value is {@code true}. * * @return {@code true} if authentication caching should be utilized, {@code false} otherwise. */ public boolean isAuthenticationCachingEnabled() { return this.authenticationCachingEnabled && isCachingEnabled(); }
/** * This implementation attempts to acquire an authentication cache if one is not already configured. * * @since 1.2 */ protected void afterCacheManagerSet() { //trigger obtaining the authorization cache if possible getAvailableAuthenticationCache(); }
public boolean[] isPermitted(PrincipalCollection principals, List<Permission> permissions) { AuthorizationInfo info = getAuthorizationInfo(principals); return isPermitted(permissions, info); }