com.cafesoft.cams.access
Interface Permission

All Superinterfaces:
Comparable
All Known Implementing Classes:
AbstractPermission

public interface Permission
extends Comparable

Represents an entitlement or authorization to a access a set of Resources. Specifically, classes that implement a Permission associate a ResourcePattern, and zero or more actions on a matching ResourceRequest and an AccessControlRule or a SecurityDomain that controls access to the associated Resource.

Each Permission implementation has a "type", which is a String token used to associate the type of ResourceRequests that can match it. Rather than base the type entirely on the Java class implementing the Permission, use of a String token enables additional flexibility.

Since:
3/5/02

Method Summary
 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 Permission.
 boolean match(ResourceRequest resourceReq)
          Determine if a ResourceRequest matches the ResourcePattern and one of the actions associated with this Permission.
 PermissionCollection newPermissionCollection()
          Create a new PermissionCollection suitable for storing homogeneous Permission instances.
 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.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

initialize

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

Parameters:
config - a Config object that provides access to configuration parameters and a runtime Context.
ConfigException

getResourceType

public ResourceType getResourceType()
Get the ResourceType.

Returns:
the ResourceType.

getDescription

public String getDescription()
Get a textual description.

Returns:
a textual description of the Permission or null if none is set.

setDescription

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

Parameters:
desc - a textual description of the Permission.

getResourcePattern

public ResourcePattern getResourcePattern()
Get the ResourcePattern.

Returns:
the ResourcePattern associated with this Permission.

setResourcePattern

public void setResourcePattern(ResourcePattern rp)
Set the ResourcePattern.

Parameters:
rp - the ResourcePattern associated with this Permission.

getAccessControlRule

public AccessControlRule getAccessControlRule()
Get the AccessControlRule.

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.

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.

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.

Parameters:
securityDomainName - the name of the SecurityDomain that owns * resources matching this Permission.

getActions

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

Returns:
an array of actions for this Permission or an empty array if no actions are specified.

setActions

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

Parameters:
actions - a String array of 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).

Returns:
an integer representing the actions being requested on the Resource.

match

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

Parameters:
resourceReq - the ResourceRequest to be checked against this Permission.
Returns:
true if the Resource matches the ResourcePattern and one of the actions specified for this Permission.

newPermissionCollection

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

Returns:
a PermissionCollection suitable for storing a collection of Permission instances of this class.

overlaps

public 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.

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


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