com.cafesoft.cams.access
Class AbstractPermissionCollection

java.lang.Object
  |
  +--com.cafesoft.cams.access.AbstractPermissionCollection
All Implemented Interfaces:
Debuggable, PermissionCollection

public abstract class AbstractPermissionCollection
extends Object
implements PermissionCollection

Abstract implementation of the PermissionCollection interface.

Since:
8/25/03
See Also:
PermissionCollection

Field Summary
protected  Config config
          The Config object passed in at initialization through which configuration parameters, services, and a Logger are available.
protected  boolean debug
          A flag that enables/disables DEBUG-level messages.
protected  Logger logger
          The Logger to which DEBUG, INFO, WARNING, ERROR, and FATAL messages are written.
protected  List permissionList
          The List of Permissions in this collection.
 
Constructor Summary
AbstractPermissionCollection()
          Create a new AbstractPermissionCollection.
 
Method Summary
 void addPermission(Permission permission)
          Add a Permission.
 boolean containsOverlapping(Permission permission)
          Check for an overlapping Permission.
 Permission getOverlapping(Permission permission)
          Get an overlapping Permission.
 Permission getPermission(ResourceRequest resourceReq)
          Get the Permission best matching a ResourceRequest.
 PermissionIterator getPermissions()
          Get all Permissions.
 void initialize(Config config)
          Initialize the AccessControlRule.
 void removePermission(Permission permission)
          Remove a Permission.
 boolean setDebug(boolean enable)
          Enable or disable debugging.
 String toString()
          Get a String representation of the PermissionCollection object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

permissionList

protected List permissionList
The List of Permissions in this collection.


config

protected Config config
The Config object passed in at initialization 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 written.


debug

protected boolean debug
A flag that enables/disables DEBUG-level messages.

Constructor Detail

AbstractPermissionCollection

public AbstractPermissionCollection()
Create a new AbstractPermissionCollection.

Method Detail

initialize

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

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

setDebug

public boolean setDebug(boolean enable)
Enable or disable debugging.

Specified by:
setDebug in interface Debuggable
Parameters:
enable - if true, enable debugging, else disable debugging.
Returns:
the previous value of the debug flag, which is useful for restoring the debug state if temporarily changed.

addPermission

public void addPermission(Permission permission)
                   throws OverlappingPermissionsException
Add a Permission.

Specified by:
addPermission in interface PermissionCollection
Parameters:
permission - the Permission to be added.
OverlappingPermissionsException

removePermission

public void removePermission(Permission permission)
Remove a Permission.

Specified by:
removePermission in interface PermissionCollection
Parameters:
permission - the Permission to be removed.

getPermission

public Permission getPermission(ResourceRequest resourceReq)
Get the Permission best matching a ResourceRequest.

Specified by:
getPermission in interface PermissionCollection
Parameters:
resourceReq - the ResourceRequest
Returns:
the Permission best matching the ResourceRequest or null if no match.

getPermissions

public PermissionIterator getPermissions()
Get all Permissions.

Specified by:
getPermissions in interface PermissionCollection
Returns:
a PermissionIterator through which all Permissions may be accessed.

containsOverlapping

public boolean containsOverlapping(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:
containsOverlapping in interface PermissionCollection
Parameters:
permission - the Permission to be checked for an overlap.
Returns:
true if this PermissionCollection contains another Permission that overlaps the specified Permission.
See Also:
getOverlapping(com.cafesoft.cams.access.Permission)

getOverlapping

public Permission getOverlapping(Permission permission)
Get an overlapping Permission.

Specified by:
getOverlapping in interface PermissionCollection
Parameters:
permission - the Permission that overlaps the one to be retrieved.
Returns:
the overlapping Permission or null if no Permission overlaps.

toString

public String toString()
Get a String representation of the PermissionCollection object.

Overrides:
toString in class Object
Returns:
a String representation of the PermissionCollection object.


Generated on 8:41:50 AM June 06, 2005, © 1996-2005 Cafésoft LLC. All rights reserved.