org.glite.security.voms.database
Class DBGroup

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

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

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

Author:
Karoly Lorentey, Akos Frohner

Field Summary
static long VO_GROUP_ID
          The id of the VO group.
 
Method Summary
 void addMember(DBUser user)
          Add a user to the members of this group.
 void checkPermission(Operation o)
          Convenience method: check that the client has the necessary privileges to perform the given operation on this group.
 int countAllGroups()
          Return the number of groups in this VO.
 int countChildGroups()
          Return the number of direct subgroups of this group.
 int countMembers()
          Returns the number of users who are members of this group.
 DBGroup createChildGroup(java.lang.String name)
          Creates a new group with this group as parent.
static DBGroup createVOGroup()
          Creates the VO group.
 void deleteGroup()
          Delete this group.
 DBACL getACL()
          Return this group's ACL.
 java.lang.String[] getChildGroupNames()
          Get the names of direct subgroups of this group.
 DBGroup[] getChildGroups()
          Get the direct subgroups of this group.
 DBAdmin getCreatedBy()
          Return the administrator who created this group.
 long getCreatedSerial()
          Return the serial number of the transaction that committed this group.
 DBACL getDefaultACL()
          Return this group's default ACL.
 java.lang.String getDN()
          Return the name of this group.
static DBGroup getInstance(java.lang.String name)
          Returns a DBGroup object representing the named group.
 java.lang.String[] getMemberNames()
          Return the names of the members of this group.
 DBUser[] getMembers()
          Return the members of this group as DBUser objects.
 User[] getMembersAsUser()
          Return the names of all members of this group as User objects.
 boolean getMust()
          Return true iff the group is non-deniable.
 DBGroup getParent()
          Return this group's parent group.
static DBGroup getVOGroup()
          Returns a DBGroup object representing the VO group.
 boolean isChildGroup(DBGroup child)
          Return true if the given group is a direct subgroup of this group.
 boolean isMember(DBUser user)
          Returns true if the given user is a member of this group.
 boolean isVOGroup()
          Return true if this group is the VO group.
 void removeAllMembers()
          Remove all members of this group.
 void removeMember(DBUser user)
          Remove a user from this group and all its subgroups.
 void setAttributes(boolean must)
          Set auxiliary attributes.
 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

VO_GROUP_ID

public static final long VO_GROUP_ID
The id of the VO group.

See Also:
Constant Field Values
Method Detail

getInstance

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

Parameters:
name - The fully qualified name of the group. (Null is an alias for the VO group.)
Returns:
The DBGroup instance representing the named group.
Throws:
NotInDatabase - If there is no such group in the database.
GeneralDatabaseException
ArgumentException

getVOGroup

public static DBGroup getVOGroup()
                          throws GeneralDatabaseException
Returns a DBGroup object representing the VO group.

Throws:
GeneralDatabaseException

getDN

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

Specified by:
getDN in interface DBContainer

getMust

public boolean getMust()
Return true iff the group is non-deniable.


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


getParent

public DBGroup getParent()
                  throws GeneralDatabaseException
Return this group's parent group.

Returns:
null if this group is the VO group.
Throws:
GeneralDatabaseException

getACL

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

Specified by:
getACL in interface DBContainer
Throws:
GeneralDatabaseException

getDefaultACL

public DBACL getDefaultACL()
                    throws GeneralDatabaseException
Return this group's default ACL.

Throws:
GeneralDatabaseException

getCreatedBy

public DBAdmin getCreatedBy()
                     throws GeneralDatabaseException,
                            NotInDatabase
Return the administrator who created this group.

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

isVOGroup

public boolean isVOGroup()
Return true if this group is the VO group.


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

Specified by:
checkPermission in interface DBContainer
Throws:
GeneralDatabaseException
VOMSSecurityException

countAllGroups

public int countAllGroups()
                   throws GeneralDatabaseException
Return the number of groups in this VO.

Returns:
The number of groups in this VO, including the VO group.
Throws:
GeneralDatabaseException

countChildGroups

public int countChildGroups()
                     throws GeneralDatabaseException
Return the number of direct subgroups of this group.

Returns:
The number of direct subgroups of this group.
Throws:
GeneralDatabaseException

isChildGroup

public boolean isChildGroup(DBGroup child)
                     throws GeneralDatabaseException
Return true if the given group is a direct subgroup of this group.

Parameters:
child - The group to check.
Returns:
true if child is a direct subgroup of this group.
Throws:
GeneralDatabaseException

getChildGroups

public DBGroup[] getChildGroups()
                         throws GeneralDatabaseException
Get the direct subgroups of this group.

Returns:
The array of the direct subgroups of this group.
Throws:
GeneralDatabaseException

getChildGroupNames

public java.lang.String[] getChildGroupNames()
                                      throws GeneralDatabaseException
Get the names of direct subgroups of this group.

Returns:
The names of direct subgroups.
Throws:
GeneralDatabaseException

createVOGroup

public static DBGroup createVOGroup()
                             throws GeneralDatabaseException,
                                    ArgumentException
Creates the VO group.

Throws:
GeneralDatabaseException
ArgumentException

createChildGroup

public DBGroup createChildGroup(java.lang.String name)
                         throws GeneralDatabaseException,
                                ArgumentException
Creates a new group with this group as parent. Note that this method does not check for naming inconsistencies. It is up to the caller to ensure that the name of the new group corresponds to the configured naming scheme.

The new groups gets a copy of the parent group's ACL and default ACL, extended with an entry for the current user.

The group becomes a non-deniable group by default.

Parameters:
name - The fqgn of the new group.
Returns:
the newly created group.
Throws:
ArgumentException - if a group with the given name already exists.
GeneralDatabaseException

deleteGroup

public void deleteGroup()
                 throws GeneralDatabaseException,
                        ArgumentException
Delete this group.

Throws:
ArgumentException - if the group has members or subcontainers or if the group is the VO group.
GeneralDatabaseException

countMembers

public int countMembers()
                 throws GeneralDatabaseException
Returns the number of users who are members of this group.

Returns:
The number of users who are in this group.
Throws:
GeneralDatabaseException

isMember

public boolean isMember(DBUser user)
                 throws GeneralDatabaseException
Returns true if the given user is a member of this group.

Parameters:
user - The user to check for.
Returns:
True if the given user is a member; false otherwise.
Throws:
GeneralDatabaseException

getMembers

public DBUser[] getMembers()
                    throws GeneralDatabaseException
Return the members of this group as DBUser objects.

Specified by:
getMembers in interface DBContainer
Returns:
The members of this group.
Throws:
GeneralDatabaseException

getMembersAsUser

public User[] getMembersAsUser()
                        throws GeneralDatabaseException
Return the names of all members of this group as User objects.

Specified by:
getMembersAsUser in interface DBContainer
Returns:
The members of this group.
Throws:
GeneralDatabaseException

getMemberNames

public java.lang.String[] getMemberNames()
                                  throws GeneralDatabaseException
Return the names of the members of this group.

Specified by:
getMemberNames in interface DBContainer
Returns:
The members of this group.
Throws:
GeneralDatabaseException

addMember

public void addMember(DBUser user)
               throws GeneralDatabaseException,
                      ArgumentException
Add a user to the members of this group.

Specified by:
addMember in interface DBContainer
Parameters:
user - The user to add.
Throws:
ArgumentException - if the user is already a member of this group.
GeneralDatabaseException

removeMember

public void removeMember(DBUser user)
                  throws GeneralDatabaseException,
                         ArgumentException
Remove a user from this group and all its subgroups.

Specified by:
removeMember in interface DBContainer
Parameters:
user - The user to remove.
Throws:
ArgumentException - if the user is not a member of the group.
GeneralDatabaseException

removeAllMembers

public void removeAllMembers()
                      throws GeneralDatabaseException
Remove all members of this group.

Throws:
GeneralDatabaseException

setAttributes

public void setAttributes(boolean must)
                   throws InconsistentDatabase,
                          DatabaseError
Set auxiliary attributes.

Throws:
InconsistentDatabase
DatabaseError