Class DynamicPolicyProvider
- All Implemented Interfaces:
DynamicPolicy
DynamicPolicy
interface, then its permission mappings are assumed to change only when its refresh method is called. Permissions are granted on the granularity of class loader; granting
a permission requires (of the calling context) GrantPermission for that permission.- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.security.Policy
Policy.Parameters -
Field Summary
Fields inherited from class java.security.Policy
UNSUPPORTED_EMPTY_COLLECTION -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newDynamicPolicyProviderinstance that wraps a default underlying policy.DynamicPolicyProvider(Policy basePolicy) Creates a newDynamicPolicyProviderinstance that wraps around the given non-nullbase policy object. -
Method Summary
Modifier and TypeMethodDescriptionIf this security policy provider supports dynamic permission grants, returns a new array containing the cumulative set of permissions dynamically granted to protection domains (including ones not yet created) that are associated with the class loader of the given class and possess at least the given set of principals.getPermissions(CodeSource source) Behaves as specified byPolicy.getPermissions(CodeSource).getPermissions(ProtectionDomain domain) Behaves as specified byPolicy.getPermissions(ProtectionDomain).voidgrant(Class cl, Principal[] principals, Permission[] permissions) If this security policy provider supports dynamic permission grants, grants the specified permissions to all protection domains (including ones not yet created) that are associated with the class loader of the given class and possess at least the given set of principals.booleanReturnstrueif this policy provider supports dynamic permission grants; returnsfalseotherwise.booleanimplies(ProtectionDomain domain, Permission permission) Behaves as specified byPolicy.implies(java.security.ProtectionDomain, java.security.Permission).voidrefresh()Behaves as specified byPolicy.refresh().Methods inherited from class java.security.Policy
getInstance, getInstance, getInstance, getParameters, getPolicy, getProvider, getType, setPolicy
-
Constructor Details
-
DynamicPolicyProvider
Creates a newDynamicPolicyProviderinstance that wraps a default underlying policy. The underlying policy is created as follows: if thenet.jini.security.policy.DynamicPolicyProvider.basePolicyClasssecurity property is set, then its value is interpreted as the class name of the base (underlying) policy provider; otherwise, a default class name of"net.jini.security.policy.PolicyFileProvider"is used. The base policy is then instantiated using the no-arg public constructor of the named class. If the base policy class is not found, is not instantiable via a public no-arg constructor, or if invocation of its constructor fails, then aPolicyInitializationExceptionis thrown.Note that this constructor requires the appropriate
"getProperty"SecurityPermissionto read thenet.jini.security.policy.DynamicPolicyProvider.basePolicyClasssecurity property, and may require"accessClassInPackage.*"RuntimePermissions, depending on the package of the base policy class.- Throws:
PolicyInitializationException- if unable to construct the base policySecurityException- if there is a security manager and the calling context does not have adequate permissions to read thenet.jini.security.policy.DynamicPolicyProvider.basePolicyClasssecurity property, or if the calling context does not have adequate permissions to access the base policy class
-
DynamicPolicyProvider
Creates a newDynamicPolicyProviderinstance that wraps around the given non-nullbase policy object.- Parameters:
basePolicy- base policy object containing information about non-dynamic grants- Throws:
NullPointerException- ifbasePolicyisnull
-
-
Method Details
-
getPermissions
Behaves as specified byPolicy.getPermissions(CodeSource).- Overrides:
getPermissionsin classPolicy
-
getPermissions
Behaves as specified byPolicy.getPermissions(ProtectionDomain).- Overrides:
getPermissionsin classPolicy
-
implies
Behaves as specified byPolicy.implies(java.security.ProtectionDomain, java.security.Permission). -
refresh
public void refresh()Behaves as specified byPolicy.refresh(). -
grantSupported
public boolean grantSupported()Description copied from interface:DynamicPolicyReturnstrueif this policy provider supports dynamic permission grants; returnsfalseotherwise. Note that this method may return different values for a givenDynamicPolicyinstance, depending on context. For example, a policy provider that delegates to different underlying policy implementations depending on thread state would returntruefrom this method when the current delegate supports dynamic permission grants, but returnfalsewhen another delegate lacking such support is in effect.- Specified by:
grantSupportedin interfaceDynamicPolicy- Returns:
trueif policy supports dynamic permission grants under current context,falseotherwise
-
grant
Description copied from interface:DynamicPolicyIf this security policy provider supports dynamic permission grants, grants the specified permissions to all protection domains (including ones not yet created) that are associated with the class loader of the given class and possess at least the given set of principals. If the given class isnull, then the grant applies across all protection domains that possess at least the specified principals. If the list of principals isnullor empty, then principals are effectively ignored in determining the protection domains to which the grant applies. If this policy provider does not support dynamic permission grants, then no permissions are granted and anUnsupportedOperationExceptionis thrown.The given class, if non-
null, must belong to either the system domain or a protection domain whose associated class loader is non-null. If the class does not belong to such a protection domain, then no permissions are granted and anUnsupportedOperationExceptionis thrown.If a security manager is installed, its
checkPermissionmethod is called with aGrantPermissioncontaining the permissions to grant; if the permission check fails, then no permissions are granted and the resultingSecurityExceptionis thrown. The principals and permissions arrays passed in are neither modified nor retained; subsequent changes to the arrays have no effect on the grant operation.- Specified by:
grantin interfaceDynamicPolicy- Parameters:
cl- class to grant permissions to the class loader of, ornullif granting across all class loadersprincipals- if non-null, minimum set of principals to which grants applypermissions- if non-null, permissions to grant
-
getGrants
Description copied from interface:DynamicPolicyIf this security policy provider supports dynamic permission grants, returns a new array containing the cumulative set of permissions dynamically granted to protection domains (including ones not yet created) that are associated with the class loader of the given class and possess at least the given set of principals. If the given class isnull, then this method returns the cumulative set of permissions dynamically granted across all protection domains that possess at least the specified principals (i.e., through calls to the grant method where the specified class wasnull). If the list of principals isnullor empty, then the permissions returned reflect only grants not qualified by principals (i.e., those performed through calls to the grant method where the specified principals array wasnullor empty). If this policy provider does not support dynamic permission grants, then anUnsupportedOperationExceptionis thrown.The given class, if non-
null, must belong to either the system domain or a protection domain whose associated class loader is non-null. If the class does not belong to such a protection domain, then anUnsupportedOperationExceptionis thrown.- Specified by:
getGrantsin interfaceDynamicPolicy- Parameters:
cl- class to query the permissions dynamically granted to the class loader of, ornullif querying permissions granted across all class loadersprincipals- if non-null, principals to query dynamic grants for- Returns:
- new array containing the permissions dynamically granted to the indicated class loader (if any) and principals
-