com.ibm.tspaces.ac
Class TsPrincipal

java.lang.Object
  |
  +--com.ibm.tspaces.ac.TsPrincipal

public class TsPrincipal
extends java.lang.Object
implements java.io.Serializable, java.security.Principal, java.security.acl.Group

This class implements the java.security.Principal, interface. A Principal is a user or group of users that have(or want) access to a resource. This also implements the java.security.acl.Group interface. This is used to represent a group of principals.

Note that Group extends Principal. Thus, either a Principal or a Group can be passed as an argument to methods containing a Principal parameter. For example, you can add either a Principal or a Group to a Group object by calling the object's addMember method, passing it the Principal or Group.

Author:
John Thomas
See Also:
Serialized Form

Constructor Summary
TsPrincipal(java.lang.String name)
          Constructor with Principal name specified.
 
Method Summary
protected  void addBelongsTo(java.security.acl.Group group)
          Adds the specified group to the member to show it belongs.
 boolean addMember(java.security.Principal user)
          Adds the specified member to the group.
 boolean equals(java.lang.Object another)
          Returns true if the object passed matches the Principal represented in this interface.
 java.lang.String getName()
          Return the name associated with this Principal
 int hashCode()
          Returns a hashcode for this principal.
 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.
protected  void removeBelongsTo(java.security.acl.Group group)
          Removes the specified group from the member.
 boolean removeMember(java.security.Principal user)
          Removes the specified member from the group.
 void setName(java.lang.String name)
          Set the name to be associated with this Principal
 java.lang.String toString()
          Prints a string representation of this Principal.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TsPrincipal

public TsPrincipal(java.lang.String name)
Constructor with Principal name specified.
Method Detail

getName

public java.lang.String getName()
Return the name associated with this Principal
Specified by:
getName in interface java.security.Principal
Returns:
name of Prinipal

setName

public void setName(java.lang.String name)
Set the name to be associated with this Principal

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.

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.

addBelongsTo

protected void addBelongsTo(java.security.acl.Group group)
Adds the specified group to the member to show it belongs. This is required to handle addtion of principals but it only is needed as an internal method for addMembers
Parameters:
the - group to add to this principal .

removeBelongsTo

protected void removeBelongsTo(java.security.acl.Group group)
Removes the specified group from the member. This is required to handle deletion of principals but it only is needed as an internal method for removeMembers
Parameters:
the - group to remove from to this principal .

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.

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.

equals

public boolean equals(java.lang.Object another)
Returns true if the object passed matches the Principal represented in this interface.
Specified by:
equals in interface java.security.Principal
Overrides:
equals in class java.lang.Object
Parameters:
another - the Principal object to compare with.
Returns:
true if the Principal objects are equal, false otherwise

toString

public java.lang.String toString()
Prints a string representation of this Principal.
Specified by:
toString in interface java.security.Principal
Overrides:
toString in class java.lang.Object
Returns:
the string representation of the Principal.

hashCode

public int hashCode()
Returns a hashcode for this principal.
Specified by:
hashCode in interface java.security.Principal
Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode for this principal.