net.sf.jguard.principals
Class JGuardPrincipal

java.lang.Object
  extended bynet.sf.jguard.principals.JGuardPrincipal
All Implemented Interfaces:
java.lang.Comparable, java.security.Principal, java.io.Serializable

public class JGuardPrincipal
extends java.lang.Object
implements java.security.Principal, java.io.Serializable, java.lang.Comparable

Principal represents the notion of a role.

Author:
Charles Gay
See Also:
Serialized Form

Constructor Summary
JGuardPrincipal()
          empty constructor.
JGuardPrincipal(java.lang.String name, java.lang.String applicationName)
          constructor.
 
Method Summary
 void addDomain(URLDomain domain)
          add an URLDomain tothe JGuardPrincipal.
 void addPermission(URLPermission permission)
          add a permission to the JGuardPrincipal.
 java.lang.Object clone()
          override the java.lang.Object 's clone method.
 int compareTo(java.lang.Object o)
          method used to compare two objects.
 boolean equals(java.lang.Object another)
          compare an object to this JGuardPrincipal.
 java.lang.String getApplicationName()
           
 java.util.Set getDomains()
           
 java.lang.String getName()
           
 java.util.Set getOrphanedPermissions()
          return the permissions not bound to a domain owned by this JGuardPrincipal.
 java.util.Set getPermissions()
           
 java.util.Set getPermissionsFromDomains()
           
 int hashCode()
          override Object's hashcode method.
 void removeDomain(URLDomain domain)
           
 void setApplicationName(java.lang.String string)
          define application name.
 void setDomains(java.util.Set doms)
           
 void setName(java.lang.String string)
           
 void setPermissions(java.util.Set perms)
           
 java.lang.String toString()
          override the Object's toString method.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JGuardPrincipal

public JGuardPrincipal()
empty constructor.


JGuardPrincipal

public JGuardPrincipal(java.lang.String name,
                       java.lang.String applicationName)
constructor.

Parameters:
name -
applicationName -
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
override the java.lang.Object 's clone method.

Returns:
new JGuardPricipal with the same internal references (permissions and Domains).
Throws:
java.lang.CloneNotSupportedException

getName

public java.lang.String getName()
Specified by:
getName in interface java.security.Principal
See Also:
Principal.getName()

equals

public boolean equals(java.lang.Object another)
compare an object to this JGuardPrincipal. override the Object's equals method.

Specified by:
equals in interface java.security.Principal
Parameters:
another - object to compare
Returns:
true if another is equals to this JGuardPrincipal

toString

public java.lang.String toString()
override the Object's toString method. return String representation

Specified by:
toString in interface java.security.Principal

hashCode

public int hashCode()
override Object's hashcode method.

Specified by:
hashCode in interface java.security.Principal

setName

public void setName(java.lang.String string)
Parameters:
string -

getPermissions

public java.util.Set getPermissions()
Returns:

getOrphanedPermissions

public java.util.Set getOrphanedPermissions()
return the permissions not bound to a domain owned by this JGuardPrincipal.

Returns:

setPermissions

public void setPermissions(java.util.Set perms)

addPermission

public void addPermission(URLPermission permission)
add a permission to the JGuardPrincipal.

Parameters:
permission -

addDomain

public void addDomain(URLDomain domain)
add an URLDomain tothe JGuardPrincipal.

Parameters:
domain -

getApplicationName

public java.lang.String getApplicationName()
Returns:
application name

setApplicationName

public void setApplicationName(java.lang.String string)
define application name.

Parameters:
string -

getDomains

public java.util.Set getDomains()
Returns:
Returns the domains.

getPermissionsFromDomains

public java.util.Set getPermissionsFromDomains()
Returns:
Returns the permissionsFromDomains.

setDomains

public void setDomains(java.util.Set doms)

compareTo

public int compareTo(java.lang.Object o)
method used to compare two objects. this method is used in Collection to order items, and MUST be consistent with the equals method (eache method should return 0/true in the same cases).

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - object to compare
Returns:
0 if both objects are equals, <0 if 0 is lesser than the JGuardPrincipal, >0 if 0 is greater than the JGuardPrincipal
See Also:
Comparable.compareTo(java.lang.Object), Comparable.compareTo(java.lang.Object)

removeDomain

public void removeDomain(URLDomain domain)