com.opensymphony.user
Class Group

java.lang.Object
  extended bycom.opensymphony.user.Entity
      extended bycom.opensymphony.user.Group
All Implemented Interfaces:
java.security.acl.Group, java.security.Principal, java.io.Serializable

public final class Group
extends Entity
implements java.security.acl.Group

Entity that represents a Group of Users.

Refer to Entity for more information.

Version:
$Revision: 1.2 $
Author:
Joe Walnes
See Also:
Entity, Serialized Form

Nested Class Summary
 class Group.Accessor
          Group specific Accessor.
 
Field Summary
 
Fields inherited from class com.opensymphony.user.Entity
accessor, mutable, name
 
Method Summary
 boolean addMember(java.security.Principal user)
          Adds the specified member to the group.
 boolean addUser(User user)
          Add User to members of this Group.
 boolean containsUser(java.lang.String user)
          Determine whether Group contains supplied User as member.
 boolean containsUser(User user)
          Determine whether Group contains supplied User as member.
 java.util.List getUsers()
          List all Users that Group contains as members.
 boolean isMember(java.security.Principal member)
          Returns true if the passed principal is a member of the group.
 java.util.Enumeration members()
          Returns an enumeration of the members in the group.
 void remove()
          Remove Group from associated AccessProvider.
 boolean removeMember(java.security.Principal user)
          Removes the specified member from the group.
 boolean removeUser(User user)
          Remove User from members of this Group.
 
Methods inherited from class com.opensymphony.user.Entity
equals, getAccessProvider, getCredentialsProvider, getName, getProfileProvider, getPropertySet, getUserManager, hashCode, isMutable, store, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.security.Principal
equals, getName, hashCode, toString
 

Method Detail

isMember

public boolean isMember(java.security.Principal member)
Returns true if the passed principal is a member of the group. This method does a recursive search, so if a principal belongs to a group which is a member of this group, true is returned.

Specified by:
isMember in interface java.security.acl.Group
Parameters:
member - the principal whose membership is to be checked.
Returns:
true if the principal is a member of this group, false otherwise.

getUsers

public java.util.List getUsers()
List all Users that Group contains as members. Modifiying this Collection will not add or remove Users.

Returns:
List of usernames (String)

addMember

public boolean addMember(java.security.Principal user)
Adds the specified member to the group.

Specified by:
addMember in interface java.security.acl.Group
Parameters:
user - the principal to add to this group.
Returns:
true if the member was successfully added, false if the principal was already a member.

addUser

public boolean addUser(User user)
Add User to members of this Group. Returns whether any modifications were made.


containsUser

public boolean containsUser(User user)
Determine whether Group contains supplied User as member.


containsUser

public boolean containsUser(java.lang.String user)
Determine whether Group contains supplied User as member.


members

public java.util.Enumeration members()
Returns an enumeration of the members in the group. The returned objects can be instances of either Principal or Group (which is a subclass of Principal).

Specified by:
members in interface java.security.acl.Group
Returns:
an enumeration of the group members.

remove

public void remove()
            throws ImmutableException
Remove Group from associated AccessProvider.

Specified by:
remove in class Entity
Throws:
ImmutableException

removeMember

public boolean removeMember(java.security.Principal user)
Removes the specified member from the group.

Specified by:
removeMember in interface java.security.acl.Group
Parameters:
user - the principal to remove from this group.
Returns:
true if the principal was removed, or false if the principal was not a member.

removeUser

public boolean removeUser(User user)
Remove User from members of this Group. Returns whether any modifications were made.


See www.opensymphony.com for more information.