org.glite.security.voms.database
Class DBRole

java.lang.Object
  extended byorg.glite.security.voms.database.DBRole
All Implemented Interfaces:
DBContainer

public final class DBRole
extends java.lang.Object
implements DBContainer

A class representing the roles in a VO. Essentially, a database wrapper class for the roles table.

Author:
Karoly Lorentey, Akos Frohner

Method Summary
 void addMember(DBUser user)
          Adds this role to user in the VO group.
 void addMember(DBUser user, DBGroup group)
          Adds this role to the given user in the given group.
 void checkPermission(Operation o)
          Convenience method: check that the client has the necessary privileges to perform the given operation on this role.
 int countMembers()
          Returns the number of users who have this role, in any group.
 int countMembers(DBGroup group)
          Returns the number of users who have this role in the given group.
static int countRoles()
           
static DBRole createRole(java.lang.String name)
          Creates a new role.
 void deleteRole()
          Delete this role.
 DBACL getACL()
          Return this role's ACL.
 DBAdmin getCreatedBy()
          Return the user who created this role.
 long getCreatedSerial()
          Return the serial number of the transaction that committed this role.
 java.lang.String getDN()
          Return the name of this role.
static DBRole getInstance(java.lang.String name)
          Returns a DBRole object representing the named role.
 java.lang.String[] getMemberNames()
          Return the names of all users that have this role in any of the groups.
 java.lang.String[] getMemberNames(DBGroup group)
          Return the names of all users that have this role in any of the groups.
 DBUser[] getMembers()
          Return all users that have this role in any of the groups.
 DBUser[] getMembers(DBGroup group)
          Return all users that have this role in the given group.
 User[] getMembersAsUser()
          Return all users that have this role in any of the groups.
 User[] getMembersAsUser(DBGroup group)
          Return all users that have this role in the given group.
static java.lang.String[] getRoleNames()
          Get the names of all roles that are associated with this group.
 boolean isMember(DBUser user)
          Returns true if the given user has this role in any group.
 boolean isMember(DBUser user, DBGroup group)
          Returns true if the given user has this role in the given group.
 void removeAllMembers()
          Rids this role from every user in all groups.
 void removeAllMembers(DBGroup group)
          Rids this role from every user in the given group.
 void removeMember(DBUser user)
          Rids the given user from this role in every group.
 void removeMember(DBUser user, DBGroup group)
          Removes this role from the given user associated with the given group.
 java.lang.String toString()
          Convert to a human-readable string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static DBRole getInstance(java.lang.String name)
                          throws GeneralDatabaseException,
                                 NotInDatabase,
                                 ArgumentException
Returns a DBRole object representing the named role.

Parameters:
name - The name of the role.
Returns:
The DBRole instance representing the named role.
Throws:
NotInDatabase - If there is no such group in the database.
GeneralDatabaseException
ArgumentException

getDN

public java.lang.String getDN()
Return the name of this role.

Specified by:
getDN in interface DBContainer

toString

public java.lang.String toString()
Convert to a human-readable string.

Specified by:
toString in interface DBContainer

getCreatedSerial

public long getCreatedSerial()
Return the serial number of the transaction that committed this role.


getACL

public DBACL getACL()
             throws GeneralDatabaseException
Return this role's ACL.

Specified by:
getACL in interface DBContainer
Throws:
GeneralDatabaseException

getCreatedBy

public DBAdmin getCreatedBy()
                     throws GeneralDatabaseException,
                            NotInDatabase
Return the user who created this role.

Throws:
NotInDatabase - if the administrator has been deleted from the database.
GeneralDatabaseException

checkPermission

public void checkPermission(Operation o)
                     throws GeneralDatabaseException,
                            VOMSSecurityException
Convenience method: check that the client has the necessary privileges to perform the given operation on this role.

Specified by:
checkPermission in interface DBContainer
Throws:
GeneralDatabaseException
VOMSSecurityException

deleteRole

public void deleteRole()
                throws GeneralDatabaseException,
                       ArgumentException
Delete this role.

Throws:
GeneralDatabaseException
ArgumentException

countMembers

public int countMembers()
                 throws GeneralDatabaseException
Returns the number of users who have this role, in any group.

Throws:
GeneralDatabaseException

countMembers

public int countMembers(DBGroup group)
                 throws GeneralDatabaseException
Returns the number of users who have this role in the given group.

Throws:
GeneralDatabaseException

isMember

public boolean isMember(DBUser user)
                 throws GeneralDatabaseException
Returns true if the given user has this role in any group.

Throws:
GeneralDatabaseException

isMember

public boolean isMember(DBUser user,
                        DBGroup group)
                 throws GeneralDatabaseException
Returns true if the given user has this role in the given group. The group may not be null.

Throws:
GeneralDatabaseException

getMembers

public DBUser[] getMembers()
                    throws GeneralDatabaseException
Return all users that have this role in any of the groups. This is not the same as the member list for the VO group!

Specified by:
getMembers in interface DBContainer
Throws:
GeneralDatabaseException

getMembersAsUser

public User[] getMembersAsUser()
                        throws GeneralDatabaseException
Return all users that have this role in any of the groups. This is not the same as the member list for the VO group!

Specified by:
getMembersAsUser in interface DBContainer
Throws:
GeneralDatabaseException

getMemberNames

public java.lang.String[] getMemberNames()
                                  throws GeneralDatabaseException
Return the names of all users that have this role in any of the groups.

Specified by:
getMemberNames in interface DBContainer
Throws:
GeneralDatabaseException

getMembers

public DBUser[] getMembers(DBGroup group)
                    throws GeneralDatabaseException
Return all users that have this role in the given group. The group may not be null.

Throws:
GeneralDatabaseException

getMembersAsUser

public User[] getMembersAsUser(DBGroup group)
                        throws GeneralDatabaseException
Return all users that have this role in the given group. The group may not be null.

Throws:
GeneralDatabaseException

getMemberNames

public java.lang.String[] getMemberNames(DBGroup group)
                                  throws GeneralDatabaseException
Return the names of all users that have this role in any of the groups.

Throws:
GeneralDatabaseException

addMember

public void addMember(DBUser user)
               throws GeneralDatabaseException,
                      ArgumentException
Adds this role to user in the VO group.

Specified by:
addMember in interface DBContainer
Throws:
GeneralDatabaseException
ArgumentException

addMember

public void addMember(DBUser user,
                      DBGroup group)
               throws GeneralDatabaseException,
                      ArgumentException
Adds this role to the given user in the given group. Group may be null for the VO group.

Throws:
GeneralDatabaseException
ArgumentException

removeMember

public void removeMember(DBUser user)
                  throws GeneralDatabaseException,
                         ArgumentException
Rids the given user from this role in every group.

Specified by:
removeMember in interface DBContainer
Throws:
GeneralDatabaseException
ArgumentException

removeMember

public void removeMember(DBUser user,
                         DBGroup group)
                  throws GeneralDatabaseException,
                         ArgumentException
Removes this role from the given user associated with the given group. If group is null, completely rids the user from this role.

Throws:
GeneralDatabaseException
ArgumentException

removeAllMembers

public void removeAllMembers()
                      throws GeneralDatabaseException
Rids this role from every user in all groups.

Throws:
GeneralDatabaseException

removeAllMembers

public void removeAllMembers(DBGroup group)
                      throws GeneralDatabaseException
Rids this role from every user in the given group. If the group is null, removes all members from the entire role.

Throws:
GeneralDatabaseException

createRole

public static DBRole createRole(java.lang.String name)
                         throws GeneralDatabaseException,
                                ArgumentException
Creates a new role.

Parameters:
name - The name of the new role.
Returns:
The DBRole object corresponding to the newly created role.
Throws:
ArgumentException - if the role is already in the database.
GeneralDatabaseException

getRoleNames

public static java.lang.String[] getRoleNames()
                                       throws GeneralDatabaseException
Get the names of all roles that are associated with this group.

Returns:
The names of direct subgroups.
Throws:
GeneralDatabaseException

countRoles

public static int countRoles()
                      throws GeneralDatabaseException
Throws:
GeneralDatabaseException