org.ow2.jonas.lib.security.jacc
Class JPolicyConfiguration

java.lang.Object
  extended by org.ow2.jonas.lib.security.jacc.JPolicyConfiguration
All Implemented Interfaces:
PolicyConfiguration

public class JPolicyConfiguration
extends Object
implements PolicyConfiguration

Defines the PolicyConfiguration implementation class of JACC

Author:
Florent Benoit

Constructor Summary
JPolicyConfiguration(String contextID)
          Constructor of a new PolicyConfiguration object
 
Method Summary
 void addToExcludedPolicy(Permission permission)
          Used to add a single excluded policy statement to this PolicyConfiguration.
 void addToExcludedPolicy(PermissionCollection permissions)
          Used to add excluded policy statements to this PolicyConfiguration.
 void addToRole(String roleName, Permission permission)
          Used to add a single permission to a named role in this PolicyConfiguration.
 void addToRole(String roleName, PermissionCollection permissions)
          Used to add permissions to a named role in this PolicyConfiguration.
 void addToUncheckedPolicy(Permission permission)
          Used to add a single unchecked policy statement to this PolicyConfiguration.
 void addToUncheckedPolicy(PermissionCollection permissions)
          Used to add unchecked policy statements to this PolicyConfiguration.
 void commit()
          This method is used to set to "inService" the state of the policy context whose interface is this PolicyConfiguration Object.
 void delete()
          Causes all policy statements to be deleted from this PolicyConfiguration and sets its internal state such that calling any method, other than delete, getContextID, or inService on the PolicyConfiguration will be rejected and cause an UnsupportedOperationException to be thrown.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 String getContextID()
          This method returns this object's policy context identifier.
 PermissionCollection getExcludedPermissions()
          Gets the excluded permission
 PermissionCollection getPermissionsForPrincipal(Principal principal)
          Gets the permissions for a given principal
 PermissionCollection getUncheckedPermissions()
          Gets the excluded permission
 int hashCode()
          Gets a hash code value for the object.
 boolean inService()
          This method is used to determine if the policy context whose interface is this PolicyConfiguration Object is in the "inService" state.
 void linkConfiguration(PolicyConfiguration link)
          Creates a relationship between this configuration and another such that they share the same principal-to-role mappings.
 void removeExcludedPolicy()
          Used to remove any excluded policy statements from this PolicyConfiguration.
 void removeRole(String roleName)
          Used to remove a role and all its permissions from this PolicyConfiguration.
 void removeUncheckedPolicy()
          Used to remove any unchecked policy statements from this PolicyConfiguration.
protected  void resetState()
          Reset to OPEN state (Used by PolicyConfigurationFactory)
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPolicyConfiguration

public JPolicyConfiguration(String contextID)
Constructor of a new PolicyConfiguration object

Parameters:
contextID - Identifier of this PolicyConfiguration object
Method Detail

addToExcludedPolicy

public void addToExcludedPolicy(Permission permission)
                         throws PolicyContextException,
                                SecurityException,
                                UnsupportedOperationException
Used to add a single excluded policy statement to this PolicyConfiguration.

Specified by:
addToExcludedPolicy in interface PolicyConfiguration
Parameters:
permission - the permission to be added to the excluded policy statements.
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" or "inService" when this method is called.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the addToExcludedPolicy method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

addToExcludedPolicy

public void addToExcludedPolicy(PermissionCollection permissions)
                         throws PolicyContextException,
                                SecurityException,
                                UnsupportedOperationException
Used to add excluded policy statements to this PolicyConfiguration.

Specified by:
addToExcludedPolicy in interface PolicyConfiguration
Parameters:
permissions - the collection of permissions to be added to the excluded policy statements. The collection may be either a homogenous or heterogenous collection.
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" or "inService" when this method is called.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the addToExcludedPolicy method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

addToRole

public void addToRole(String roleName,
                      Permission permission)
               throws PolicyContextException,
                      SecurityException,
                      UnsupportedOperationException
Used to add a single permission to a named role in this PolicyConfiguration.

Specified by:
addToRole in interface PolicyConfiguration
Parameters:
roleName - the name of the Role to which the permission is to be added.
permission - the permission to be added to the role.
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" or "inService" when this method is called.
PolicyContextException - - if the implementation throws a checked exception that has not been accounted for by the addToRole method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

addToRole

public void addToRole(String roleName,
                      PermissionCollection permissions)
               throws PolicyContextException,
                      SecurityException,
                      UnsupportedOperationException
Used to add permissions to a named role in this PolicyConfiguration.

Specified by:
addToRole in interface PolicyConfiguration
Parameters:
roleName - the name of the Role to which the permissions are to be added.
permissions - the collection of permissions to be added to the role. The collection may be either a homogenous or heterogenous collection.
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" or inService" when this method is called.
PolicyContextException - - if the implementation throws a checked exception that has not been accounted for by the addToRole method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

addToUncheckedPolicy

public void addToUncheckedPolicy(Permission permission)
                          throws PolicyContextException,
                                 SecurityException,
                                 UnsupportedOperationException
Used to add a single unchecked policy statement to this PolicyConfiguration.

Specified by:
addToUncheckedPolicy in interface PolicyConfiguration
Parameters:
permission - the permission to be added to the unchecked policy statements.
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" or "inService" when this method is called.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the addToUncheckedPolicy method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

addToUncheckedPolicy

public void addToUncheckedPolicy(PermissionCollection permissions)
                          throws PolicyContextException,
                                 SecurityException,
                                 UnsupportedOperationException
Used to add unchecked policy statements to this PolicyConfiguration.

Specified by:
addToUncheckedPolicy in interface PolicyConfiguration
Parameters:
permissions - the collection of permissions to be added as unchecked policy statements. The collection may be either a homogenous or heterogenous collection.
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" or "inService" when this method is called.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the addToUncheckedPolicy method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

commit

public void commit()
            throws PolicyContextException,
                   SecurityException,
                   UnsupportedOperationException
This method is used to set to "inService" the state of the policy context whose interface is this PolicyConfiguration Object. Only those policy contexts whose state is "inService" will be included in the policy contexts processed by the Policy.refresh method. A policy context whose state is "inService" may be returned to the "open" state by calling the getPolicyConfiguration method of the PolicyConfiguration factory with the policy context identifier of the policy context. When the state of a policy context is "inService", calling any method other than commit, delete, getContextID, or inService on its PolicyConfiguration Object will cause an UnsupportedOperationException to be thrown.

Specified by:
commit in interface PolicyConfiguration
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" when this method is called.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the commit method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

delete

public void delete()
            throws PolicyContextException,
                   SecurityException
Causes all policy statements to be deleted from this PolicyConfiguration and sets its internal state such that calling any method, other than delete, getContextID, or inService on the PolicyConfiguration will be rejected and cause an UnsupportedOperationException to be thrown. This operation has no affect on any linked PolicyConfigurations other than removing any links involving the deleted PolicyConfiguration.

Specified by:
delete in interface PolicyConfiguration
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the delete method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

getContextID

public String getContextID()
                    throws PolicyContextException,
                           SecurityException
This method returns this object's policy context identifier.

Specified by:
getContextID in interface PolicyConfiguration
Returns:
this object's policy context identifier.
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the getContextID method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

inService

public boolean inService()
                  throws PolicyContextException,
                         SecurityException
This method is used to determine if the policy context whose interface is this PolicyConfiguration Object is in the "inService" state.

Specified by:
inService in interface PolicyConfiguration
Returns:
true if the state of the associated policy context is "inService"; false otherwise.
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the inService method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

linkConfiguration

public void linkConfiguration(PolicyConfiguration link)
                       throws IllegalArgumentException,
                              PolicyContextException,
                              SecurityException,
                              UnsupportedOperationException
Creates a relationship between this configuration and another such that they share the same principal-to-role mappings. PolicyConfigurations are linked to apply a common principal-to-role mapping to multiple seperately manageable PolicyConfigurations, as is required when an application is composed of multiple modules. Note that the policy statements which comprise a role, or comprise the excluded or unchecked policy collections in a PolicyConfiguration are unaffected by the configuration being linked to another.

Specified by:
linkConfiguration in interface PolicyConfiguration
Parameters:
link - a reference to a different PolicyConfiguration than this PolicyConfiguration. The relationship formed by this method is symetric, transitive and idempotent. If the argument PolicyConfiguration does not have a different Policy context identifier than this PolicyConfiguration no relationship is formed, and an exception, as described below, is thrown.
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" or "inService" when this method is called.
IllegalArgumentException - if called with an argument PolicyConfiguration whose Policy context is equivalent to that of this PolicyConfiguration.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the linkConfiguration method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

removeExcludedPolicy

public void removeExcludedPolicy()
                          throws PolicyContextException,
                                 SecurityException,
                                 UnsupportedOperationException
Used to remove any excluded policy statements from this PolicyConfiguration.

Specified by:
removeExcludedPolicy in interface PolicyConfiguration
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" or "inService" when this method is called.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the removeExcludedPolicy method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

removeRole

public void removeRole(String roleName)
                throws PolicyContextException,
                       SecurityException,
                       UnsupportedOperationException
Used to remove a role and all its permissions from this PolicyConfiguration.

Specified by:
removeRole in interface PolicyConfiguration
Parameters:
roleName - the name of the Role to remove from this PolicyConfiguration.
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" or "inService" when this method is called.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the removeRole method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

removeUncheckedPolicy

public void removeUncheckedPolicy()
                           throws PolicyContextException,
                                  SecurityException,
                                  UnsupportedOperationException
Used to remove any unchecked policy statements from this PolicyConfiguration.

Specified by:
removeUncheckedPolicy in interface PolicyConfiguration
Throws:
SecurityException - if called by an AccessControlContext that has not been granted the "setPolicy" SecurityPermission.
UnsupportedOperationException - if the state of the policy context whose interface is this PolicyConfiguration Object is "deleted" or "inService" when this method is called.
PolicyContextException - if the implementation throws a checked exception that has not been accounted for by the removeUncheckedPolicy method signature. The exception thrown by the implementation class will be encapsulated (during construction) in the thrown PolicyContextException.

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.

hashCode

public int hashCode()
Gets a hash code value for the object.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.

resetState

protected void resetState()
Reset to OPEN state (Used by PolicyConfigurationFactory)


getExcludedPermissions

public PermissionCollection getExcludedPermissions()
Gets the excluded permission

Returns:
the excluded permission

getUncheckedPermissions

public PermissionCollection getUncheckedPermissions()
Gets the excluded permission

Returns:
the excluded permission

getPermissionsForPrincipal

public PermissionCollection getPermissionsForPrincipal(Principal principal)
Gets the permissions for a given principal

Parameters:
principal - given principal
Returns:
the permissions for a given principal


Copyright © 2010 OW2 Consortium. All Rights Reserved.