public class LoaderSplitPolicyProvider extends Policy implements DynamicPolicy
LoaderSplitPolicyProvider
instance wraps two
underlying policy providers:
null
class loader, and
refresh()
, which applies to both policies).
Policy.Parameters
UNSUPPORTED_EMPTY_COLLECTION
Constructor and Description |
---|
LoaderSplitPolicyProvider(ClassLoader loader,
Policy loaderPolicy,
Policy defaultPolicy)
Creates a new
LoaderSplitPolicyProvider instance which
delegates to loaderPolicy any permission query/grant
operations involving protection domains or classes with the given class
loader, any child class loader of the given class loader, or the
null class loader; all other operations are delegated to
defaultPolicy (with the exception of refresh ,
which applies to both policies). |
Modifier and Type | Method and Description |
---|---|
Permission[] |
getGrants(Class cl,
Principal[] principals)
If both underlying policy providers support dynamic grants, delegates to
the
getGrants method of the underlying policy associated
with the loader of the given class (the loader-specific policy if the
class loader is null , the same as or a child of the loader
specified in the constructor for this instance, or the default loader
otherwise). |
PermissionCollection |
getPermissions(CodeSource source)
Delegates to the corresponding
getPermissions method of the
underlying default policy. |
PermissionCollection |
getPermissions(ProtectionDomain domain)
If the given protection domain is the protection domain of this class,
then a newly-created
PermissionCollection containing AllPermission is returned. |
void |
grant(Class cl,
Principal[] principals,
Permission[] permissions)
If both underlying policy providers support dynamic grants, delegates to
the
grant method of the underlying policy associated with
the loader of the given class (the loader-specific policy if the class
loader is null , the same as or a child of the loader
specified in the constructor for this instance, or the default loader
otherwise). |
boolean |
grantSupported()
Returns
true if both of the underlying policy providers
implement DynamicPolicy and return true from calls
to grantSupported ; returns false otherwise. |
boolean |
implies(ProtectionDomain domain,
Permission permission)
If the given protection domain is the protection domain of this class,
then
true is returned. |
void |
refresh()
Invokes
refresh on both the loader-specific and default
underlying policy providers. |
getInstance, getInstance, getInstance, getParameters, getPolicy, getProvider, getType, setPolicy
public LoaderSplitPolicyProvider(ClassLoader loader, Policy loaderPolicy, Policy defaultPolicy)
LoaderSplitPolicyProvider
instance which
delegates to loaderPolicy
any permission query/grant
operations involving protection domains or classes with the given class
loader, any child class loader of the given class loader, or the
null
class loader; all other operations are delegated to
defaultPolicy
(with the exception of refresh
,
which applies to both policies).loader
- class loader for which associated permission query/grant
operations should be forwarded to loaderPolicy
loaderPolicy
- class loader-specific security policy providerdefaultPolicy
- default security policy providerNullPointerException
- if loader
,
loaderPolicy
or defaultPolicy
is
null
public PermissionCollection getPermissions(CodeSource source)
getPermissions
method of the
underlying default policy.getPermissions
in class Policy
source
- code source for which to look up permissionspublic PermissionCollection getPermissions(ProtectionDomain domain)
PermissionCollection
containing AllPermission
is returned. If not, delegates to the corresponding
getPermissions
method of the underlying policy associated
with the loader of the given class (the loader-specific policy if the
class loader is null
, the same as or a child of the loader
specified in the constructor for this instance, or the default loader
otherwise).getPermissions
in class Policy
domain
- protection domain for which to look up permissionspublic boolean implies(ProtectionDomain domain, Permission permission)
true
is returned. If not, delegates to the
implies
method of the underlying policy associated with the
loader of the given class (the loader-specific policy if the class
loader is null
, the same as or a child of the loader
specified in the constructor for this instance, or the default loader
otherwise).public void refresh()
refresh
on both the loader-specific and default
underlying policy providers.public boolean grantSupported()
true
if both of the underlying policy providers
implement DynamicPolicy
and return true
from calls
to grantSupported
; returns false
otherwise.grantSupported
in interface DynamicPolicy
public void grant(Class cl, Principal[] principals, Permission[] permissions)
grant
method of the underlying policy associated with
the loader of the given class (the loader-specific policy if the class
loader is null
, 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 an
UnsupportedOperationException
.grant
in interface DynamicPolicy
cl
- principals
- permissions
- UnsupportedOperationException
SecurityException
NullPointerException
public Permission[] getGrants(Class cl, Principal[] principals)
getGrants
method of the underlying policy associated
with the loader of the given class (the loader-specific policy if the
class loader is null
, 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 an
UnsupportedOperationException
.getGrants
in interface DynamicPolicy
cl
- principals
- UnsupportedOperationException
NullPointerException
Copyright © 2016–2018. All rights reserved.