/** * Used by the {@link Authorizer Authorizer} implementation methods to ensure that the {@link #setRealms realms} * has been set. The default implementation ensures the property is not null and not empty. * * @throws IllegalStateException if the <tt>realms</tt> property is configured incorrectly. */ protected void assertRealmsConfigured() throws IllegalStateException { Collection<Realm> realms = getRealms(); if (realms == null || realms.isEmpty()) { String msg = "Configuration error: No realms have been configured! One or more realms must be " + "present to execute an authorization operation."; throw new IllegalStateException(msg); } }
/** * Returns <code>true</code> if any of the configured realms' * {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} call returns <code>true</code>, * <code>false</code> otherwise. */ public boolean hasRole(PrincipalCollection principals, String roleIdentifier) { assertRealmsConfigured(); for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) continue; if (((Authorizer) realm).hasRole(principals, roleIdentifier)) { return true; } } return false; }
/** * Sets the internal {@link #getRolePermissionResolver} on any internal configured * {@link #getRealms Realms} that implement the {@link org.apache.shiro.authz.permission.RolePermissionResolverAware RolePermissionResolverAware} interface. * <p/> * This method is called after setting a rolePermissionResolver on this ModularRealmAuthorizer via the * {@link #setRolePermissionResolver(org.apache.shiro.authz.permission.RolePermissionResolver) setRolePermissionResolver} method. * <p/> * It is also called after setting one or more realms via the {@link #setRealms setRealms} method to allow these * newly available realms to be given the <code>RolePermissionResolver</code> already in use. * * @since 1.0 */ protected void applyRolePermissionResolverToRealms() { RolePermissionResolver resolver = getRolePermissionResolver(); Collection<Realm> realms = getRealms(); if (resolver != null && realms != null && !realms.isEmpty()) { for (Realm realm : realms) { if (realm instanceof RolePermissionResolverAware) { ((RolePermissionResolverAware) realm).setRolePermissionResolver(resolver); } } } }
/** * Returns <code>true</code> if any of the configured realms' * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, String)} returns <code>true</code>, * <code>false</code> otherwise. */ public boolean isPermitted(PrincipalCollection principals, String permission) { assertRealmsConfigured(); for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) continue; if (((Authorizer) realm).isPermitted(principals, permission)) { return true; } } return false; }
/** * Returns <code>true</code> if any of the configured realms' * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, Permission)} call returns <code>true</code>, * <code>false</code> otherwise. */ public boolean isPermitted(PrincipalCollection principals, Permission permission) { assertRealmsConfigured(); for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) continue; if (((Authorizer) realm).isPermitted(principals, permission)) { return true; } } return false; }
/** * Sets the internal {@link #getPermissionResolver} on any internal configured * {@link #getRealms Realms} that implement the {@link org.apache.shiro.authz.permission.PermissionResolverAware PermissionResolverAware} interface. * <p/> * This method is called after setting a permissionResolver on this ModularRealmAuthorizer via the * {@link #setPermissionResolver(org.apache.shiro.authz.permission.PermissionResolver) setPermissionResolver} method. * <p/> * It is also called after setting one or more realms via the {@link #setRealms setRealms} method to allow these * newly available realms to be given the <code>PermissionResolver</code> already in use. * * @since 1.0 */ protected void applyPermissionResolverToRealms() { PermissionResolver resolver = getPermissionResolver(); Collection<Realm> realms = getRealms(); if (resolver != null && realms != null && !realms.isEmpty()) { for (Realm realm : realms) { if (realm instanceof PermissionResolverAware) { ((PermissionResolverAware) realm).setPermissionResolver(resolver); } } } }
/** * Used by the {@link Authorizer Authorizer} implementation methods to ensure that the {@link #setRealms realms} * has been set. The default implementation ensures the property is not null and not empty. * * @throws IllegalStateException if the <tt>realms</tt> property is configured incorrectly. */ protected void assertRealmsConfigured() throws IllegalStateException { Collection<Realm> realms = getRealms(); if (realms == null || realms.isEmpty()) { String msg = "Configuration error: No realms have been configured! One or more realms must be " + "present to execute an authorization operation."; throw new IllegalStateException(msg); } }
/** * Returns <code>true</code> if any of the configured realms' * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, Permission)} call returns <code>true</code>, * <code>false</code> otherwise. */ public boolean isPermitted(PrincipalCollection principals, Permission permission) { assertRealmsConfigured(); for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) continue; if (((Authorizer) realm).isPermitted(principals, permission)) { return true; } } return false; }
/** * Returns <code>true</code> if any of the configured realms' * {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} call returns <code>true</code>, * <code>false</code> otherwise. */ public boolean hasRole(PrincipalCollection principals, String roleIdentifier) { assertRealmsConfigured(); for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) continue; if (((Authorizer) realm).hasRole(principals, roleIdentifier)) { return true; } } return false; }
/** * Returns <code>true</code> if any of the configured realms' * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, String)} returns <code>true</code>, * <code>false</code> otherwise. */ public boolean isPermitted(PrincipalCollection principals, String permission) { assertRealmsConfigured(); for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) continue; if (((Authorizer) realm).isPermitted(principals, permission)) { return true; } } return false; }
/** * Sets the internal {@link #getPermissionResolver} on any internal configured * {@link #getRealms Realms} that implement the {@link org.apache.shiro.authz.permission.PermissionResolverAware PermissionResolverAware} interface. * <p/> * This method is called after setting a permissionResolver on this ModularRealmAuthorizer via the * {@link #setPermissionResolver(org.apache.shiro.authz.permission.PermissionResolver) setPermissionResolver} method. * <p/> * It is also called after setting one or more realms via the {@link #setRealms setRealms} method to allow these * newly available realms to be given the <code>PermissionResolver</code> already in use. * * @since 1.0 */ protected void applyPermissionResolverToRealms() { PermissionResolver resolver = getPermissionResolver(); Collection<Realm> realms = getRealms(); if (resolver != null && realms != null && !realms.isEmpty()) { for (Realm realm : realms) { if (realm instanceof PermissionResolverAware) { ((PermissionResolverAware) realm).setPermissionResolver(resolver); } } } }
/** * Sets the internal {@link #getRolePermissionResolver} on any internal configured * {@link #getRealms Realms} that implement the {@link org.apache.shiro.authz.permission.RolePermissionResolverAware RolePermissionResolverAware} interface. * <p/> * This method is called after setting a rolePermissionResolver on this ModularRealmAuthorizer via the * {@link #setRolePermissionResolver(org.apache.shiro.authz.permission.RolePermissionResolver) setRolePermissionResolver} method. * <p/> * It is also called after setting one or more realms via the {@link #setRealms setRealms} method to allow these * newly available realms to be given the <code>RolePermissionResolver</code> already in use. * * @since 1.0 */ protected void applyRolePermissionResolverToRealms() { RolePermissionResolver resolver = getRolePermissionResolver(); Collection<Realm> realms = getRealms(); if (resolver != null && realms != null && !realms.isEmpty()) { for (Realm realm : realms) { if (realm instanceof RolePermissionResolverAware) { ((RolePermissionResolverAware) realm).setRolePermissionResolver(resolver); } } } }
/** * Used by the {@link Authorizer Authorizer} implementation methods to ensure that the {@link #setRealms realms} * has been set. The default implementation ensures the property is not null and not empty. * * @throws IllegalStateException if the <tt>realms</tt> property is configured incorrectly. */ protected void assertRealmsConfigured() throws IllegalStateException { Collection<Realm> realms = getRealms(); if (realms == null || realms.isEmpty()) { String msg = "Configuration error: No realms have been configured! One or more realms must be " + "present to execute an authorization operation."; throw new IllegalStateException(msg); } }
/** * Returns <code>true</code> if any of the configured realms' * {@link Realm#isPermitted(org.apache.shiro.subject.PrincipalCollection , String)} returns <code>true</code>, * <code>false</code> otherwise. */ public boolean isPermitted(PrincipalCollection principals, String permission) { assertRealmsConfigured(); for (Realm realm : getRealms()) { if (realm.isPermitted(principals, permission)) { return true; } } return false; }
/** * Returns <code>true</code> if any of the configured realms' * {@link Realm#isPermitted(org.apache.shiro.subject.PrincipalCollection , Permission)} call returns <code>true</code>, * <code>false</code> otherwise. */ public boolean isPermitted(PrincipalCollection principals, Permission permission) { assertRealmsConfigured(); for (Realm realm : getRealms()) { if (realm.isPermitted(principals, permission)) { return true; } } return false; }
/** * Returns <code>true</code> if any of the configured realms' * {@link Realm#hasRole(org.apache.shiro.subject.PrincipalCollection , String)} call returns <code>true</code>, * <code>false</code> otherwise. */ public boolean hasRole(PrincipalCollection principals, String roleIdentifier) { assertRealmsConfigured(); for (Realm realm : getRealms()) { if (realm.hasRole(principals, roleIdentifier)) { return true; } } return false; }
/** * Sets the internal {@link #getRolePermissionResolver} on any internal configured * {@link #getRealms Realms} that implement the {@link org.apache.shiro.authz.permission.RolePermissionResolverAware RolePermissionResolverAware} interface. * <p/> * This method is called after setting a rolePermissionResolver on this ModularRealmAuthorizer via the * {@link #setRolePermissionResolver(org.apache.shiro.authz.permission.RolePermissionResolver) setRolePermissionResolver} method. * <p/> * It is also called after setting one or more realms via the {@link #setRealms setRealms} method to allow these * newly available realms to be given the <code>RolePermissionResolver</code> already in use. * * @since 1.0 */ protected void applyRolePermissionResolverToRealms() { RolePermissionResolver resolver = getRolePermissionResolver(); Collection<Realm> realms = getRealms(); if (resolver != null && realms != null && !realms.isEmpty()) { for (Realm realm : realms) { if (realm instanceof RolePermissionResolverAware) { ((RolePermissionResolverAware) realm).setRolePermissionResolver(resolver); } } } }
/** * Sets the internal {@link #getPermissionResolver} on any internal configured * {@link #getRealms Realms} that implement the {@link org.apache.shiro.authz.permission.PermissionResolverAware PermissionResolverAware} interface. * <p/> * This method is called after setting a permissionResolver on this ModularRealmAuthorizer via the * {@link #setPermissionResolver(org.apache.shiro.authz.permission.PermissionResolver) setPermissionResolver} method. * <p/> * It is also called after setting one or more realms via the {@link #setRealms setRealms} method to allow these * newly available realms to be given the <code>PermissionResolver</code> already in use. * * @since 1.0 */ protected void applyPermissionResolverToRealms() { PermissionResolver resolver = getPermissionResolver(); Collection<Realm> realms = getRealms(); if (resolver != null && realms != null && !realms.isEmpty()) { for (Realm realm : realms) { if (realm instanceof PermissionResolverAware) { ((PermissionResolverAware) realm).setPermissionResolver(resolver); } } } }