Beispiel #1
0
  /**
   * Returns the <code>Privileges</code> that the <code>Group</code> has.
   *
   * @param securityAccess
   * @throws GeneralSecurityException
   */
  public Privilege[] getPrivileges(SecurityAccess securityAccess) throws GeneralSecurityException {
    Role[] roles = securityAccess.getAllRolesForGroup(this);
    HashSet privilegeSet = new HashSet();

    // gather privileges for all associated roles
    for (int i = 0; i < roles.length; i++) {
      Privilege[] rolePrivileges = registry.getPrivilegesForRole(securityAccess, roles[i]);
      for (int j = 0; j < rolePrivileges.length; j++) {
        privilegeSet.add(rolePrivileges[j]);
      }
    }
    return (Privilege[]) privilegeSet.toArray(new Privilege[privilegeSet.size()]);
  }
Beispiel #2
0
 /**
  * Returns the rights that this <code>Group</code> has on the given <code>SecurableObject</code>.
  *
  * @param securityAccess
  */
 public RightSet getRights(SecurityAccess securityAccess, SecurableObject object)
     throws GeneralSecurityException {
   Role[] roles = securityAccess.getAllRolesForGroup(this);
   RightSet rights = null;
   for (int i = 0; i < roles.length; i++) {
     Right[] roleRights = registry.getRights(securityAccess, object, roles[i]);
     switch (i) {
       case 0:
         {
           rights = new RightSet(roleRights);
           break;
         }
       default:
         {
           rights.merge(new RightSet(roleRights));
         }
     }
   }
   return rights;
 }