org.jboss.security
Class SimpleGroup

java.lang.Object
  extended by org.jboss.security.SimplePrincipal
      extended by org.jboss.security.SimpleGroup
All Implemented Interfaces:
Serializable, Cloneable, Group, Principal

public class SimpleGroup
extends SimplePrincipal
implements Group, Cloneable

An implementation of Group that manages a collection of Principal objects based on their hashCode() and equals() methods. This class is not thread safe.

Version:
$Revision: 57203 $
Author:
Scott.Stark@jboss.org
See Also:
Serialized Form

Constructor Summary
SimpleGroup(String groupName)
           
 
Method Summary
 boolean addMember(Principal user)
          Adds the specified member to the group.
 Object clone()
           
 boolean isMember(Principal member)
          Returns true if the passed principal is a member of the group.
 Enumeration members()
          Returns an enumeration of the members in the group.
 boolean removeMember(Principal user)
          Removes the specified member from the group.
 String toString()
           
 
Methods inherited from class org.jboss.security.SimplePrincipal
equals, getName, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.security.Principal
equals, getName, hashCode
 

Constructor Detail

SimpleGroup

public SimpleGroup(String groupName)
Method Detail

addMember

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

Specified by:
addMember in interface 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.

isMember

public boolean isMember(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. A special check is made to see if the member is an instance of org.jboss.security.AnybodyPrincipal or org.jboss.security.NobodyPrincipal since these classes do not hash to meaningful values.

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

members

public 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 subinterface of Principal).

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

removeMember

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

Specified by:
removeMember in interface 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.

toString

public String toString()
Specified by:
toString in interface Principal
Overrides:
toString in class SimplePrincipal

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.