org.safehaus.triplesec.guardian
Class Role

java.lang.Object
  extended by org.safehaus.triplesec.guardian.Role
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class Role
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable, java.io.Serializable

An application role. Roles are application specific and contain a set of permission grants. Users assigned to these Roles inherit the set of permission grants from their roles.

Version:
$Rev: 74 $, $Date: 2005-11-11 02:03:22 -0500 (Fri, 11 Nov 2005) $
Author:
Alex Karasulu, Trustin Lee
See Also:
Serialized Form

Constructor Summary
Role(ApplicationPolicy store, java.lang.String name, Permissions permissions)
          Creates a new Role instance.
Role(ApplicationPolicy store, java.lang.String name, Permissions permissions, java.lang.String description)
          Creates a new Role instance with a description.
 
Method Summary
 void checkPermission(Permission permission)
          Assertive permission check to test if this role has the effective permission.
 void checkPermission(Permission permission, java.lang.String message)
          Assertive permission check to test if this Role has the effective permission.
 void checkPermission(java.lang.String permissionName)
          Assertive permission check to test if this role has the effective permission.
 void checkPermission(java.lang.String permissionName, java.lang.String message)
          Assertive permission check to test if this role has the effective permission.
 java.lang.Object clone()
           
 int compareTo(java.lang.Object that)
           
 boolean equals(java.lang.Object that)
           
 java.lang.String getApplicationName()
          Gets the application name this Role is defined for.
 java.lang.String getDescription()
          Gets a brief description for this Role if one exists.
 Permissions getGrants()
          Gets a set of permissions granted to this role.
 java.lang.String getName()
          Gets the name of this Role.
 int hashCode()
           
 boolean hasPermission(Permission permission)
          Get's whether or not this Role has the permission.
 boolean hasPermission(java.lang.String permissionName)
          Get's whether or not this Role has the permission.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Role

public Role(ApplicationPolicy store,
            java.lang.String name,
            Permissions permissions,
            java.lang.String description)
Creates a new Role instance with a description.

Parameters:
store - the parent store this role is defined for
name - the name of this role
permissions - a set of permissions granted for this role
description - a breif description of the role

Role

public Role(ApplicationPolicy store,
            java.lang.String name,
            Permissions permissions)
Creates a new Role instance.

Parameters:
store - the parent store this role is defined for
name - the name of this role
permissions - a set of permissions granted for this role
Method Detail

getName

public java.lang.String getName()
Gets the name of this Role.

Returns:
the name of this Role

getDescription

public java.lang.String getDescription()
Gets a brief description for this Role if one exists.

Returns:
a description for this Role

getApplicationName

public java.lang.String getApplicationName()
Gets the application name this Role is defined for.

Returns:
the name of the application this Role is defined for.

getGrants

public Permissions getGrants()
Gets a set of permissions granted to this role.

Returns:
a set of permissions granted to this role.

checkPermission

public void checkPermission(Permission permission)
Assertive permission check to test if this role has the effective permission.

Parameters:
permission - the permission to check for
Throws:
java.security.AccessControlException - if the permission is not granted

hasPermission

public boolean hasPermission(java.lang.String permissionName)
Get's whether or not this Role has the permission.

Parameters:
permissionName - the permission to check for
Returns:
true if the permission is granted,false otherwise

hasPermission

public boolean hasPermission(Permission permission)
Get's whether or not this Role has the permission.

Parameters:
permission - the name of permission to check for
Returns:
true if the permission is granted,false otherwise

checkPermission

public void checkPermission(java.lang.String permissionName)
Assertive permission check to test if this role has the effective permission.

Parameters:
permissionName - the name of the permission to check for
Throws:
java.security.AccessControlException - if the permission is not granted

checkPermission

public void checkPermission(Permission permission,
                            java.lang.String message)
Assertive permission check to test if this Role has the effective permission.

Parameters:
permission - the permission to check for
message - to use for AccessControlException if it is thrown
Throws:
java.security.AccessControlException - if the permission is not granted

checkPermission

public void checkPermission(java.lang.String permissionName,
                            java.lang.String message)
Assertive permission check to test if this role has the effective permission.

Parameters:
permissionName - the permission name to check for
message - to use for AccessControlException if it is thrown
Throws:
java.security.AccessControlException - if the permission is not granted

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object that)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object that)
Specified by:
compareTo in interface java.lang.Comparable

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object