com.ecyrd.jspwiki.auth.authorize
Class DefaultGroup

java.lang.Object
  extended by com.ecyrd.jspwiki.auth.authorize.DefaultGroup
All Implemented Interfaces:
Group, Principal

public class DefaultGroup
extends Object
implements Group

Provides a concrete implementation of the Group interface.

Since:
2.3
Version:
$Revision: 1.9 $ $Date: 2006/06/17 23:11:24 $
Author:
Andrew Jaquith

Field Summary
 
Fields inherited from interface com.ecyrd.jspwiki.auth.authorize.Group
RESTRICTED_GROUPNAMES
 
Constructor Summary
DefaultGroup(String name)
           
 
Method Summary
 boolean add(Principal user)
          Adds a Principal to the group.
 void addWikiEventListener(WikiEventListener listener)
          Registers a WikiEventListener with this Group.
 void clear()
          Clears all Principals from the group list.
 boolean equals(Object o)
          Two DefaultGroups are equal if they contain identical member Principals and have the same name.
 String getName()
          The name of the group.
 boolean isMember(Principal principal)
          Returns true if a Principal is a member of the group.
 Principal[] members()
          Returns the members of the group as an array of Principal objects.
 boolean remove(Principal user)
          Removes a Principal from the group.
 void removeWikiEventListener(WikiEventListener listener)
          Un-registers a WikiEventListener with this Group.
 String toString()
          Returns a string representation of the group.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.security.Principal
hashCode
 

Constructor Detail

DefaultGroup

public DefaultGroup(String name)
Method Detail

add

public boolean add(Principal user)
Adds a Principal to the group. When a Principal is added successfully, also sends a WikiSecurityEvent of type WikiSecurityEvent.GROUP_ADD_MEMBER to all of its registered WikiEventListeners.

Specified by:
add in interface Group
Parameters:
user - the principal to add
Returns:
true if the operation was successful

addWikiEventListener

public void addWikiEventListener(WikiEventListener listener)
Registers a WikiEventListener with this Group.

Specified by:
addWikiEventListener in interface Group
Parameters:
listener - the event listener

clear

public void clear()
Clears all Principals from the group list. When a Group's members are cleared successfully, also sends a WikiSecurityEvent of type WikiSecurityEvent.GROUP_CLEAR_MEMBERS to all of its registered WikiEventListeners.

Specified by:
clear in interface Group

equals

public boolean equals(Object o)
Two DefaultGroups are equal if they contain identical member Principals and have the same name.

Specified by:
equals in interface Group
Specified by:
equals in interface Principal
Overrides:
equals in class Object

getName

public String getName()
Description copied from interface: Group
The name of the group. Typically, this is set in concrete classes' constructors.

Specified by:
getName in interface Group
Specified by:
getName in interface Principal
Returns:
the name of the Group

isMember

public boolean isMember(Principal principal)
Returns true if a Principal is a member of the group. Specifically, the Principal's getName() method must return the same value as one of the Principals in the group member list. The Principal's type does not need to match.

Specified by:
isMember in interface Group
Parameters:
principal - the principal about whom membeship status is sought
Returns:
the result of the operation

members

public Principal[] members()
Description copied from interface: Group
Returns the members of the group as an array of Principal objects.

Specified by:
members in interface Group

remove

public boolean remove(Principal user)
Removes a Principal from the group. When a Principal is added successfully, also sends a WikiSecurityEvent of type WikiSecurityEvent.GROUP_REMOVE_MEMBER to all of its registered WikiEventListeners.

Specified by:
remove in interface Group
Parameters:
user - the principal to remove
Returns:
true if the operation was successful

removeWikiEventListener

public void removeWikiEventListener(WikiEventListener listener)
Un-registers a WikiEventListener with this Group.

Specified by:
removeWikiEventListener in interface Group
Parameters:
listener - the event listener

toString

public String toString()
Returns a string representation of the group.

Specified by:
toString in interface Group
Specified by:
toString in interface Principal
Overrides:
toString in class Object
Returns:
the string
See Also:
Object.toString()