net.sf.jguard.principals
Class JGuardPrincipal

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

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

Principal represents the notion of a role.

Author:
Charles Gay, Vinícius Pitta Lima de Araújo
See Also:
Serialized Form

Constructor Summary
JGuardPrincipal()
          empty constructor.
JGuardPrincipal(java.lang.String name)
          constructor.
JGuardPrincipal(java.lang.String name, java.lang.String applicationName)
          constructor.
 
Method Summary
 void addDomain(Domain domain)
          add an Domain to the JGuardPrincipal.
 void addPermission(java.security.Permission 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 getDescendants()
           
 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()
          return all permissions owned by this Principal plus permissions inherited from descendants.
 java.util.Set getPermissionsFromDomains()
           
 int hashCode()
          override Object's hashcode method.
 boolean isActive()
           
 void removeDomain(Domain domain)
           
 void setActive(boolean active)
           
 void setApplicationName(java.lang.String string)
          define application name.
 void setDescendants(java.util.Set descendants)
           
 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)
constructor.

Parameters:
name -
applicationName -

JGuardPrincipal

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

Parameters:
name -
applicationName -
Method Detail

clone

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

Overrides:
clone in class java.lang.Object
Returns:
new JGuardPricipal with the same internal references (permissions and Domains).

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
Overrides:
equals in class java.lang.Object
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
Overrides:
toString in class java.lang.Object

hashCode

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

Specified by:
hashCode in interface java.security.Principal
Overrides:
hashCode in class java.lang.Object

setName

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

getPermissions

public java.util.Set getPermissions()
return all permissions owned by this Principal plus permissions inherited from descendants.

Returns:
permissions

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)
Parameters:
set -

addPermission

public void addPermission(java.security.Permission permission)
add a permission to the JGuardPrincipal.

Parameters:
permission -

addDomain

public void addDomain(Domain domain)
add an Domain to the 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)
Parameters:
domains - The domains to set.

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(Domain domain)

getDescendants

public java.util.Set getDescendants()

setDescendants

public void setDescendants(java.util.Set descendants)

isActive

public boolean isActive()

setActive

public void setActive(boolean active)