org.edg.security.voms.database
Class DBRole

java.lang.Object
  |
  +--org.edg.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.

Version:
$Name: v0_7_0 $
Author:
Karoly Lorentey, Akos Frohner

Field Summary
private  long acl
          The id of this role's ACL.
private static ContainerNamingScheme cns
          The container naming scheme for this instance of VOMS.
private  long createdBy
          The id of the client who created this role.
private  long createdSerial
          The number of the transaction that committed this role.
private  long id
          The id of this role.
private static int ID
           
private static org.apache.log4j.Logger log
          Logger.
private  java.lang.String name
          The name of this role, in display form.
private static int NAME
           
(package private) static Sequence seq
          Sequence.
 
Constructor Summary
private DBRole(long id)
          Initialize a new DBRole from the given id.
private DBRole(java.lang.String name)
          Initialize a new DBRole from the given name.
 
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.
(package private)  long getACLId()
          Return the ACL id of this role.
 DBAdmin getCreatedBy()
          Return the user who created this role.
(package private)  long getCreatedByid()
          Return the id of 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.
(package private)  long getId()
          Return the id of this role.
(package private) static DBRole getInstance(long id)
          Returns a DBRole object representing the role with the given id.
static DBRole getInstance(java.lang.String name)
          Returns a DBRole object representing the named role.
 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.
private  void initialize(int from)
          Retrieve the given role from the database.
 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
 

Field Detail

log

private static final org.apache.log4j.Logger log
Logger.


name

private java.lang.String name
The name of this role, in display form.


id

private long id
The id of this role.


acl

private long acl
The id of this role's ACL.


createdBy

private long createdBy
The id of the client who created this role.


createdSerial

private long createdSerial
The number of the transaction that committed this role.


seq

static final Sequence seq
Sequence.


cns

private static ContainerNamingScheme cns
The container naming scheme for this instance of VOMS.


NAME

private static final int NAME
See Also:
Constant Field Values

ID

private static final int ID
See Also:
Constant Field Values
Constructor Detail

DBRole

private DBRole(java.lang.String name)
        throws GeneralDatabaseException,
               NotInDatabase,
               ArgumentException
Initialize a new DBRole from the given name.


DBRole

private DBRole(long id)
        throws GeneralDatabaseException,
               NotInDatabase
Initialize a new DBRole from the given id.

Method Detail

initialize

private void initialize(int from)
                 throws GeneralDatabaseException,
                        NotInDatabase,
                        ArgumentException
Retrieve the given role from the database.

GeneralDatabaseException
NotInDatabase
ArgumentException

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

getInstance

static DBRole getInstance(long id)
                   throws GeneralDatabaseException,
                          NotInDatabase
Returns a DBRole object representing the role with the given id.

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

getId

long getId()
Return the id of this role.


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
Overrides:
toString in class java.lang.Object

getACLId

long getACLId()
Return the ACL id of this role. Please consider using getACL() instead of this method.


getCreatedByid

long getCreatedByid()
Return the id of the user who created this role. Please consider using getCreatedBy() instead of this method.


getCreatedSerial

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


getACL

public DBACL getACL()
             throws DatabaseError,
                    InconsistentDatabase
Return this role's ACL.

Specified by:
getACL in interface DBContainer
DatabaseError
InconsistentDatabase

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
GeneralDatabaseException
VOMSSecurityException

deleteRole

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

GeneralDatabaseException
ArgumentException

countMembers

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

GeneralDatabaseException

countMembers

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

GeneralDatabaseException

isMember

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

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.

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!

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!

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.

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.

GeneralDatabaseException

addMember

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

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.

GeneralDatabaseException
ArgumentException

removeMember

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

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.

GeneralDatabaseException
ArgumentException

removeAllMembers

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

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.

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.
GeneralDatabaseException

countRoles

public static int countRoles()
                      throws GeneralDatabaseException
GeneralDatabaseException