/** * Returns <code>true</code> iff any of the configured realms' * {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} call returns <code>true</code> for * <em>all</em> roles specified, <code>false</code> otherwise. */ public boolean hasAllRoles(PrincipalCollection principals, Collection<String> roleIdentifiers) { assertRealmsConfigured(); for (String roleIdentifier : roleIdentifiers) { if (!hasRole(principals, roleIdentifier)) { return false; } } return true; }
/** * Calls {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} for each role name in the specified * collection and places the return value from each call at the respective location in the returned array. */ public boolean[] hasRoles(PrincipalCollection principals, List<String> roleIdentifiers) { assertRealmsConfigured(); if (roleIdentifiers != null && !roleIdentifiers.isEmpty()) { boolean[] hasRoles = new boolean[roleIdentifiers.size()]; int i = 0; for (String roleId : roleIdentifiers) { hasRoles[i++] = hasRole(principals, roleId); } return hasRoles; } return new boolean[0]; }
/** * If !{@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String) hasRole(role)}, throws * an <code>UnauthorizedException</code> otherwise returns quietly. */ public void checkRole(PrincipalCollection principals, String role) throws AuthorizationException { assertRealmsConfigured(); if (!hasRole(principals, role)) { throw new UnauthorizedException("Subject does not have role [" + role + "]"); } }
/** * Returns <code>true</code> iff any of the configured realms' * {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} call returns <code>true</code> for * <em>all</em> roles specified, <code>false</code> otherwise. */ public boolean hasAllRoles(PrincipalCollection principals, Collection<String> roleIdentifiers) { assertRealmsConfigured(); for (String roleIdentifier : roleIdentifiers) { if (!hasRole(principals, roleIdentifier)) { return false; } } return true; }
/** * Calls {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} for each role name in the specified * collection and places the return value from each call at the respective location in the returned array. */ public boolean[] hasRoles(PrincipalCollection principals, List<String> roleIdentifiers) { assertRealmsConfigured(); if (roleIdentifiers != null && !roleIdentifiers.isEmpty()) { boolean[] hasRoles = new boolean[roleIdentifiers.size()]; int i = 0; for (String roleId : roleIdentifiers) { hasRoles[i++] = hasRole(principals, roleId); } return hasRoles; } return new boolean[0]; }
/** * If !{@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String) hasRole(role)}, throws * an <code>UnauthorizedException</code> otherwise returns quietly. */ public void checkRole(PrincipalCollection principals, String role) throws AuthorizationException { assertRealmsConfigured(); if (!hasRole(principals, role)) { throw new UnauthorizedException("Subject does not have role [" + role + "]"); } }
/** * Returns <code>true</code> iff any of the configured realms' * {@link Realm#hasRole(org.apache.shiro.subject.PrincipalCollection , String)} call returns <code>true</code> for * <em>all</em> roles specified, <code>false</code> otherwise. */ public boolean hasAllRoles(PrincipalCollection principals, Collection<String> roleIdentifiers) { assertRealmsConfigured(); for (String roleIdentifier : roleIdentifiers) { if (!hasRole(principals, roleIdentifier)) { return false; } } return true; }
/** * Calls {@link #hasRole(org.apache.shiro.subject.PrincipalCollection , String)} for each role name in the specified * collection and places the return value from each call at the respective location in the returned array. */ public boolean[] hasRoles(PrincipalCollection principals, List<String> roleIdentifiers) { assertRealmsConfigured(); if (roleIdentifiers != null && !roleIdentifiers.isEmpty()) { boolean[] hasRoles = new boolean[roleIdentifiers.size()]; int i = 0; for (String roleId : roleIdentifiers) { hasRoles[i++] = hasRole(principals, roleId); } return hasRoles; } return new boolean[0]; }
/** * If !{@link #hasRole(org.apache.shiro.subject.PrincipalCollection , String) hasRole(role)}, throws * an <code>UnauthorizedException</code> otherwise returns quietly. */ public void checkRole(PrincipalCollection principals, String role) throws AuthorizationException { assertRealmsConfigured(); if (!hasRole(principals, role)) { throw new UnauthorizedException("Subject does not have role [" + role + "]"); } }