Package com.sun.jini.start
Class LoaderSplitPolicyProvider
java.lang.Object
java.security.Policy
com.sun.jini.start.LoaderSplitPolicyProvider
- All Implemented Interfaces:
DynamicPolicy
Security policy provider which handles permission queries and grants by delegating to different
policy providers depending on the class loader involved. Each
LoaderSplitPolicyProvider
instance wraps two underlying policy providers: - a class-loader specific policy provider,
consulted for permission queries/grants pertaining to that class loader, any child class loaders
that delegate to it, or the
nullclass loader, and - a default policy provider,
consulted for all other operations (aside from
refresh(), which applies to both policies).
- 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
ConstructorsConstructorDescriptionLoaderSplitPolicyProvider(ClassLoader loader, Policy loaderPolicy, Policy defaultPolicy) Creates a newLoaderSplitPolicyProviderinstance which delegates toloaderPolicyany permission query/grant operations involving protection domains or classes with the given class loader, any child class loader of the given class loader, or thenullclass loader; all other operations are delegated todefaultPolicy(with the exception ofrefresh, which applies to both policies). -
Method Summary
Modifier and TypeMethodDescriptionIf both underlying policy providers support dynamic grants, delegates to thegetGrantsmethod of the underlying policy associated with the loader of the given class (the loader-specific policy if the class loader isnull, the same as or a child of the loader specified in the constructor for this instance, or the default loader otherwise).getPermissions(CodeSource source) Delegates to the correspondinggetPermissionsmethod of the underlying default policy.getPermissions(ProtectionDomain domain) If the given protection domain is the protection domain of this class, then a newly-createdPermissionCollectioncontainingAllPermissionis returned.voidgrant(Class cl, Principal[] principals, Permission[] permissions) If both underlying policy providers support dynamic grants, delegates to thegrantmethod of the underlying policy associated with the loader of the given class (the loader-specific policy if the class loader isnull, the same as or a child of the loader specified in the constructor for this instance, or the default loader otherwise).booleanReturnstrueif both of the underlying policy providers implementDynamicPolicyand returntruefrom calls tograntSupported; returnsfalseotherwise.booleanimplies(ProtectionDomain domain, Permission permission) If the given protection domain is the protection domain of this class, thentrueis returned.voidrefresh()Invokesrefreshon both the loader-specific and default underlying policy providers.Methods inherited from class java.security.Policy
getInstance, getInstance, getInstance, getParameters, getPolicy, getProvider, getType, setPolicy
-
Constructor Details
-
LoaderSplitPolicyProvider
Creates a newLoaderSplitPolicyProviderinstance which delegates toloaderPolicyany permission query/grant operations involving protection domains or classes with the given class loader, any child class loader of the given class loader, or thenullclass loader; all other operations are delegated todefaultPolicy(with the exception ofrefresh, which applies to both policies).- Parameters:
loader- class loader for which associated permission query/grant operations should be forwarded toloaderPolicyloaderPolicy- class loader-specific security policy providerdefaultPolicy- default security policy provider- Throws:
NullPointerException- ifloader,loaderPolicyordefaultPolicyisnull
-
-
Method Details
-
getPermissions
Delegates to the correspondinggetPermissionsmethod of the underlying default policy.- Overrides:
getPermissionsin classPolicy- Parameters:
source- code source for which to look up permissions- Returns:
- set of permissions allowed for the given code source
-
getPermissions
If the given protection domain is the protection domain of this class, then a newly-createdPermissionCollectioncontainingAllPermissionis returned. If not, delegates to the correspondinggetPermissionsmethod of the underlying policy associated with the loader of the given class (the loader-specific policy if the class loader isnull, the same as or a child of the loader specified in the constructor for this instance, or the default loader otherwise).- Overrides:
getPermissionsin classPolicy- Parameters:
domain- protection domain for which to look up permissions- Returns:
- set of permissions allowed for given protection domain
-
implies
If the given protection domain is the protection domain of this class, thentrueis returned. If not, delegates to theimpliesmethod of the underlying policy associated with the loader of the given class (the loader-specific policy if the class loader isnull, the same as or a child of the loader specified in the constructor for this instance, or the default loader otherwise). -
refresh
public void refresh()Invokesrefreshon both the loader-specific and default underlying policy providers. -
grantSupported
public boolean grantSupported()Returnstrueif both of the underlying policy providers implementDynamicPolicyand returntruefrom calls tograntSupported; returnsfalseotherwise.- Specified by:
grantSupportedin interfaceDynamicPolicy- Returns:
trueif policy supports dynamic permission grants under current context,falseotherwise
-
grant
If both underlying policy providers support dynamic grants, delegates to thegrantmethod of the underlying policy associated with the loader of the given class (the loader-specific policy if the class loader isnull, the same as or a child of the loader specified in the constructor for this instance, or the default loader otherwise). If at least one of the underlying policy providers does not support dynamic grants, throws anUnsupportedOperationException.- 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- Throws:
UnsupportedOperationException- if policy does not support dynamic grants, or ifclis non-nulland belongs to a protection domain with anullclass loader other than the system domainSecurityException- if a security manager is installed and the calling context does not have sufficient permissions to grant the given permissionsNullPointerException- if any element of the principals or permissions arrays isnull
-
getGrants
If both underlying policy providers support dynamic grants, delegates to thegetGrantsmethod of the underlying policy associated with the loader of the given class (the loader-specific policy if the class loader isnull, the same as or a child of the loader specified in the constructor for this instance, or the default loader otherwise). If at least one of the underlying policy providers does not support dynamic grants, throws anUnsupportedOperationException.- 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
- Throws:
UnsupportedOperationException- if policy does not support dynamic grants, or ifclis non-nulland belongs to a protection domain with anullclass loader other than the system domainNullPointerException- if any element of the principals array isnull
-