org.objectweb.easybeans.security.jacc.provider
Class JPolicy

java.lang.Object
  extended by java.security.Policy
      extended by org.objectweb.easybeans.security.jacc.provider.JPolicy

public class JPolicy
extends java.security.Policy

Defines the "delegating Policy provider" / JACC 2.5 In J2SE 1.4 new methods can be used for dynamic permissions implies() and getPermissions() methods on Policy class were added. A replacement Policy object may accomplish this by delegating non-javax.security.jacc policy decisions to the corresponding default system Policy implementation class. A replacement Policy object that relies in this way on the corresponding default Policy implementation class must identify itself in its installation instructions as a "delegating Policy provider"
EasyBeans uses delegating model

Author:
Florent Benoit

Field Summary
private static java.security.Policy initialPolicy
          Bootstrap Policy provider use for delegating non-jacc decisions.
private static JLog logger
          Logger.
private static javax.security.jacc.PolicyConfigurationFactory policyConfigurationFactory
          Reference to the EasyBeans PolicyConfigurationFactory.
private static JPolicy unique
          Unique instance of JPolicy.
 
Constructor Summary
JPolicy()
          Constructor : build a policy which manage JACC permissions.
 
Method Summary
static JPolicy getInstance()
          Gets the unique instance of the JACC delegating policy provider.
 java.security.PermissionCollection getPermissions(java.security.CodeSource codeSource)
          Evaluates the global policy and returns a PermissionCollection object specifying the set of permissions allowed for code from the specified code source.
 java.security.PermissionCollection getPermissions(java.security.ProtectionDomain domain)
          Evaluates the global policy and returns a PermissionCollection object specifying the set of permissions allowed given the characteristics of the protection domain.
 boolean implies(java.security.ProtectionDomain domain, java.security.Permission permission)
          Evaluates the global policy for the permissions granted to the ProtectionDomain and tests whether the permission is granted.
private  void initPolicyConfigurationFactory()
          Init the PolicyConfiguration factory object used in Policy configuration.
private  boolean isImpliedPermissionForPrincipals(JPolicyConfiguration jPolicyConfiguration, java.security.Permission permission, java.security.Principal[] principals)
          Check for each principal permission if the given permission is implied.
 void refresh()
          Refreshes/reloads the policy configuration.
 
Methods inherited from class java.security.Policy
getPolicy, setPolicy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static JLog logger
Logger.


unique

private static JPolicy unique
Unique instance of JPolicy.


initialPolicy

private static java.security.Policy initialPolicy
Bootstrap Policy provider use for delegating non-jacc decisions.


policyConfigurationFactory

private static javax.security.jacc.PolicyConfigurationFactory policyConfigurationFactory
Reference to the EasyBeans PolicyConfigurationFactory. Used for retrieve parameters with interfaces not in javax.security.jacc.PolicyConfigurationFactory

Constructor Detail

JPolicy

public JPolicy()
Constructor : build a policy which manage JACC permissions. The non-jacc permissions are delegated to the initial Policy class

Method Detail

initPolicyConfigurationFactory

private void initPolicyConfigurationFactory()
                                     throws JPolicyException
Init the PolicyConfiguration factory object used in Policy configuration.

Throws:
JPolicyException - if some methods on PolicyConfigurationFactory fail

getInstance

public static JPolicy getInstance()
Gets the unique instance of the JACC delegating policy provider.

Returns:
unique instance of the JACC delegating policy provider

implies

public boolean implies(java.security.ProtectionDomain domain,
                       java.security.Permission permission)
Evaluates the global policy for the permissions granted to the ProtectionDomain and tests whether the permission is granted.

Overrides:
implies in class java.security.Policy
Parameters:
domain - the ProtectionDomain to test.
permission - the Permission object to be tested for implication.
Returns:
true if "permission" is a proper subset of a permission granted to this ProtectionDomain.

getPermissions

public java.security.PermissionCollection getPermissions(java.security.ProtectionDomain domain)
Evaluates the global policy and returns a PermissionCollection object specifying the set of permissions allowed given the characteristics of the protection domain.

Overrides:
getPermissions in class java.security.Policy
Parameters:
domain - the ProtectionDomain associated with the caller.
Returns:
the set of permissions allowed for the domain according to the policy.The returned set of permissions must be a new mutable instance and it must support heterogeneous Permission types.

getPermissions

public java.security.PermissionCollection getPermissions(java.security.CodeSource codeSource)
Evaluates the global policy and returns a PermissionCollection object specifying the set of permissions allowed for code from the specified code source.

Specified by:
getPermissions in class java.security.Policy
Parameters:
codeSource - the CodeSource associated with the caller. This encapsulates the original location of the code (where the code came from) and the public key(s) of its signer.
Returns:
the set of permissions allowed for code from codesource according to the policy.The returned set of permissions must be a new mutable instance and it must support heterogeneous Permission types.

refresh

public void refresh()
Refreshes/reloads the policy configuration.

Specified by:
refresh in class java.security.Policy

isImpliedPermissionForPrincipals

private boolean isImpliedPermissionForPrincipals(JPolicyConfiguration jPolicyConfiguration,
                                                 java.security.Permission permission,
                                                 java.security.Principal[] principals)
Check for each principal permission if the given permission is implied.

Parameters:
jPolicyConfiguration - EasyBeans JACC PolicyConfiguration object
permission - the permission to check
principals - the array of principals on which we must retrieve permissions
Returns:
true if the given permission is implied by a role's permission