com.cafesoft.cams.access
Class AbstractPermission

java.lang.Object
  |
  +--com.cafesoft.cams.access.AbstractPermission
All Implemented Interfaces:
Comparable, Permission

public abstract class AbstractPermission
extends Object
implements Permission

Provides an abstract implementation of the Permission interface.

Since:
5/21/02

Field Summary
protected  AccessControlRule acr
          The AccessControlRule associated with this Permission.
protected  String[] actions
          An array of Permission actions.
protected  long actionsMask
          A bit mask used to hold the actions associated with this Permission.
protected  Config config
          The Config object through which configuration parameters, services, and a Logger are available.
protected  String desc
          A textual description of this Permission.
protected  Logger logger
          The Logger to which DEBUG, INFO, WARNING, ERROR, and FATAL messages are sent.
protected  ResourcePattern rp
          The ResourcePattern associated with this Permission.
protected  String securityDomainName
          The Security Domain name associated with this Permission.
protected  ResourceType type
          The ResourceType of the Permission.
 
Constructor Summary
AbstractPermission(ResourceType type)
          Create a new AbstractPermission.
AbstractPermission(ResourceType type, ResourcePattern rp, String[] actions)
          Create a new AbstractPermission.
 
Method Summary
 int compareTo(Object o)
          Compares this object with the specified object for order.
 AccessControlRule getAccessControlRule()
          Get the AccessControlRule.
 String[] getActions()
          Get the actions specified for this Permission.
 long getActionsMask()
          Get an integer mask representing the actions being requested on the Resource.
 String getDescription()
          Get a textual description.
 ResourcePattern getResourcePattern()
          Get the ResourcePattern.
 ResourceType getResourceType()
          Get the ResourceType.
 String getSecurityDomain()
          Get the name of the SecurityDomain associated with this Permission.
 void initialize(Config config)
          Initialize the AccessControlRule.
abstract  boolean match(ResourceRequest resourceReq)
          Determine if a ResourceRequest matches the ResourcePattern and one of the actions associated with this Permission.
abstract  PermissionCollection newPermissionCollection()
          Create a new PermissionCollection suitable for storing homogeneous Permission instances.
abstract  boolean overlaps(Permission permission)
          Check for an overlapping Permission.
 void setAccessControlRule(AccessControlRule acr)
          Set the AccessControlRule.
 void setActions(String[] actions)
          Set the actions associated with this Permission.
 void setDescription(String desc)
          Set a textual description.
 void setResourcePattern(ResourcePattern rp)
          Set the ResourcePattern.
 void setSecurityDomain(String securityDomainName)
          Set the name of the SecurityDomain associated with this Permission.
 String toString()
          Create a String representation of this Permission.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected ResourceType type
The ResourceType of the Permission.


desc

protected String desc
A textual description of this Permission.


rp

protected ResourcePattern rp
The ResourcePattern associated with this Permission.


acr

protected AccessControlRule acr
The AccessControlRule associated with this Permission.


securityDomainName

protected String securityDomainName
The Security Domain name associated with this Permission.


actions

protected String[] actions
An array of Permission actions.


actionsMask

protected long actionsMask
A bit mask used to hold the actions associated with this Permission.


config

protected Config config
The Config object through which configuration parameters, services, and a Logger are available.


logger

protected Logger logger
The Logger to which DEBUG, INFO, WARNING, ERROR, and FATAL messages are sent. This value is available after successful initialization.

Constructor Detail

AbstractPermission

public AbstractPermission(ResourceType type)
                   throws InvalidPermissionException
Create a new AbstractPermission.

Parameters:
type - the ResourceType of the permission.
Throws:
InvalidPermissionException - if actions contains an invalid action, or if any other error occurs creating the Permission.

AbstractPermission

public AbstractPermission(ResourceType type,
                          ResourcePattern rp,
                          String[] actions)
                   throws InvalidPermissionException
Create a new AbstractPermission.

Parameters:
type - the ResourceType of the permission.
rp - the ResourcePattern of the permission.
actions - an array of permission actions.
Throws:
InvalidPermissionException - if actions contains an invalid action, or if any other error occurs creating the Permission.
Method Detail

initialize

public void initialize(Config config)
                throws ConfigException
Initialize the AccessControlRule.

Specified by:
initialize in interface Permission
Parameters:
config - a Config object that provides access to configuration parameters and a runtime Context.
ConfigException

getResourceType

public ResourceType getResourceType()
Get the ResourceType.

Specified by:
getResourceType in interface Permission
Returns:
the ResourceType.

getDescription

public String getDescription()
Get a textual description.

Specified by:
getDescription in interface Permission
Returns:
a textual description of the Permission or null if none is set.

setDescription

public void setDescription(String desc)
Set a textual description.

Specified by:
setDescription in interface Permission
Parameters:
desc - a textual description of the Permission.

getResourcePattern

public ResourcePattern getResourcePattern()
Get the ResourcePattern.

Specified by:
getResourcePattern in interface Permission
Returns:
the ResourcePattern associated with this Permission.

setResourcePattern

public void setResourcePattern(ResourcePattern rp)
Set the ResourcePattern.

Specified by:
setResourcePattern in interface Permission
Parameters:
rp - the ResourcePattern associated with this Permission.

getAccessControlRule

public AccessControlRule getAccessControlRule()
Get the AccessControlRule.

Specified by:
getAccessControlRule in interface Permission
Returns:
the AccessControlRule that protects Resources matching the ResourcePattern. If null, then another SecurityDomain (not the one containing an instance of this Permission), must be associated with the ResourcePattern.

setAccessControlRule

public void setAccessControlRule(AccessControlRule acr)
Set the AccessControlRule.

The AccessControlRule protects Resources matching the ResourcePattern. If null, then another SecurityDomain (not the one containing an instance of this Permission), must be associated with the ResourcePattern so access control checks can be delegated to that SecurityDomain.

Specified by:
setAccessControlRule in interface Permission
Parameters:
acr - the AccessControlRule or null if another SecurityDomain protects the Resources associated with this Permission.

getSecurityDomain

public String getSecurityDomain()
Get the name of the SecurityDomain associated with this Permission.

Specified by:
getSecurityDomain in interface Permission
Returns:
the SecurityDomain that owns resources matching this Permission. If null, then the SecurityDomain containing this Permission owns the resources.

setSecurityDomain

public void setSecurityDomain(String securityDomainName)
Set the name of the SecurityDomain associated with this Permission.

Specified by:
setSecurityDomain in interface Permission
Parameters:
securityDomainName - the name of the SecurityDomain that owns * resources matching this Permission.

getActions

public String[] getActions()
Get the actions specified for this Permission.

Specified by:
getActions in interface Permission
Returns:
the actions for this Permission or null if no actions are specified.

setActions

public void setActions(String[] actions)
                throws UnknownActionException
Set the actions associated with this Permission.

Specified by:
setActions in interface Permission
Parameters:
actions - a String representation of the actions
Throws:
UnknownActionException - if one or more of the actions is unknown for the type of resource associated with the permission.

getActionsMask

public long getActionsMask()
Get an integer mask representing the actions being requested on the Resource. (Use of this value rather than the String actions can significantly improve performance).

Specified by:
getActionsMask in interface Permission
Returns:
an integer representing the actions being requested on the Resource.

match

public abstract boolean match(ResourceRequest resourceReq)
Determine if a ResourceRequest matches the ResourcePattern and one of the actions associated with this Permission.

Specified by:
match in interface Permission
Parameters:
resourceReq - the ResourceRequest to be checked against this Permission.
Returns:
true if the ResourceRequest's identifier matches the ResourcePattern and one of the actions specified for this Permission.

newPermissionCollection

public abstract PermissionCollection newPermissionCollection()
Create a new PermissionCollection suitable for storing homogeneous Permission instances.

Specified by:
newPermissionCollection in interface Permission
Returns:
a PermissionCollection suitable for storing a collection of Permission instances of this class.

overlaps

public abstract boolean overlaps(Permission permission)
Check for an overlapping Permission.

Two Permission instances: A and B are considered to overlap if:

  1. they are implemented by the same Class
  2. their fully-qualfied ResourcePatterns are identical
  3. they have at least one action in common or neither has any actions at all.
If any of this conditions is false, then the two Permissions do not overlap.

Specified by:
overlaps in interface Permission
Parameters:
permission - the Permission to be checked for an overlap.
Returns:
true if this PermissionCollection contains another Permission that overlaps the specified Permission.

toString

public String toString()
Create a String representation of this Permission.

Overrides:
toString in class Object
Returns:
a String representation of this Permission.

compareTo

public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

In the foregoing description, the notation sgn(expression) designates the mathematical signum function, which is defined to return one of -1, 0, or 1 according to whether the value of expression is negative, zero or positive. The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.

Finally, the implementer must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.

Note: this class has a natural ordering that is inconsistent with equals.

Specified by:
compareTo in interface Comparable
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the specified object's type prevents it from being compared to this Object.


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.