|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.6.0
java.security
|
Nested Class Summary | |
---|---|
static interface |
Policy.Parameters
This represents a marker interface for Policy parameters. |
Field Summary | |
---|---|
static PermissionCollection |
UNSUPPORTED_EMPTY_COLLECTION
A read-only empty PermissionCollection instance. |
Constructor Summary | |
---|---|
Policy()
|
Method Summary | |
---|---|
static Policy |
getInstance(String type,
Policy.Parameters params)
Returns a Policy object of the specified type. |
static Policy |
getInstance(String type,
Policy.Parameters params,
Provider provider)
Returns a Policy object of the specified type. |
static Policy |
getInstance(String type,
Policy.Parameters params,
String provider)
Returns a Policy object of the specified type. |
Policy.Parameters |
getParameters()
Return Policy parameters. |
PermissionCollection |
getPermissions(CodeSource codesource)
Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource. |
PermissionCollection |
getPermissions(ProtectionDomain domain)
Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain. |
static Policy |
getPolicy()
Returns the installed Policy object. |
Provider |
getProvider()
Return the Provider of this Policy. |
String |
getType()
Return the type of this Policy. |
boolean |
implies(ProtectionDomain domain,
Permission permission)
Evaluates the global policy for the permissions granted to the ProtectionDomain and tests whether the permission is granted. |
void |
refresh()
Refreshes/reloads the policy configuration. |
static void |
setPolicy(Policy p)
Sets the system-wide Policy object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final PermissionCollection UNSUPPORTED_EMPTY_COLLECTION
Constructor Detail |
---|
public Policy()
Method Detail |
---|
public static Policy getPolicy()
setPolicy
.
This method first calls
SecurityManager.checkPermission
with a
SecurityPermission("getPolicy")
permission
to ensure it's ok to get the Policy object..
SecurityException
- if a security manager exists and its
checkPermission
method doesn't allow
getting the Policy object.SecurityManager.checkPermission(Permission)
,
setPolicy(java.security.Policy)
public static void setPolicy(Policy p)
SecurityManager.checkPermission
with a
SecurityPermission("setPolicy")
permission to ensure it's ok to set the Policy.
p
- the new system Policy object.
SecurityException
- if a security manager exists and its
checkPermission
method doesn't allow
setting the Policy.SecurityManager.checkPermission(Permission)
,
getPolicy()
public static Policy getInstance(String type, Policy.Parameters params) throws NoSuchAlgorithmException
This method traverses the list of registered security providers, starting with the most preferred Provider. A new Policy object encapsulating the PolicySpi implementation from the first Provider that supports the specified type is returned.
Note that the list of registered providers may be retrieved via
the Security.getProviders()
method.
type
- the specified Policy type. See Appendix A in the
Java Cryptography Architecture API Specification & Reference
for a list of standard Policy types.params
- parameters for the Policy, which may be null.
SecurityException
- if the caller does not have permission
to get a Policy instance for the specified type.
NullPointerException
- if the specified type is null.
IllegalArgumentException
- if the specified parameters
are not understood by the PolicySpi implementation
from the selected Provider.
NoSuchAlgorithmException
- if no Provider supports a PolicySpi
implementation for the specified type.Provider
public static Policy getInstance(String type, Policy.Parameters params, String provider) throws NoSuchProviderException, NoSuchAlgorithmException
A new Policy object encapsulating the PolicySpi implementation from the specified provider is returned. The specified provider must be registered in the provider list.
Note that the list of registered providers may be retrieved via
the Security.getProviders()
method.
type
- the specified Policy type. See Appendix A in the
Java Cryptography Architecture API Specification & Reference
for a list of standard Policy types.params
- parameters for the Policy, which may be null.provider
- the provider.
SecurityException
- if the caller does not have permission
to get a Policy instance for the specified type.
NullPointerException
- if the specified type is null.
IllegalArgumentException
- if the specified provider
is null or empty,
or if the specified parameters are not understood by
the PolicySpi implementation from the specified provider.
NoSuchProviderException
- if the specified provider is not
registered in the security provider list.
NoSuchAlgorithmException
- if the specified provider does not
support a PolicySpi implementation for the specified type.Provider
public static Policy getInstance(String type, Policy.Parameters params, Provider provider) throws NoSuchAlgorithmException
A new Policy object encapsulating the PolicySpi implementation from the specified Provider object is returned. Note that the specified Provider object does not have to be registered in the provider list.
type
- the specified Policy type. See Appendix A in the
Java Cryptography Architecture API Specification & Reference
for a list of standard Policy types.params
- parameters for the Policy, which may be null.provider
- the Provider.
SecurityException
- if the caller does not have permission
to get a Policy instance for the specified type.
NullPointerException
- if the specified type is null.
IllegalArgumentException
- if the specified Provider is null,
or if the specified parameters are not understood by
the PolicySpi implementation from the specified Provider.
NoSuchAlgorithmException
- if the specified Provider does not
support a PolicySpi implementation for the specified type.Provider
public Provider getProvider()
This Policy instance will only have a Provider if it
was obtained via a call to Policy.getInstance
.
Otherwise this method returns null.
public String getType()
This Policy instance will only have a type if it
was obtained via a call to Policy.getInstance
.
Otherwise this method returns null.
public Policy.Parameters getParameters()
This Policy instance will only have parameters if it
was obtained via a call to Policy.getInstance
.
Otherwise this method returns null.
public PermissionCollection getPermissions(CodeSource codesource)
Applications are discouraged from calling this method
since this operation may not be supported by all policy implementations.
Applications should solely rely on the implies
method
to perform policy checks. If an application absolutely must call
a getPermissions method, it should call
getPermissions(ProtectionDomain)
.
The default implementation of this method returns Policy.UNSUPPORTED_EMPTY_COLLECTION. This method can be overridden if the policy implementation can return a set of permissions granted to a CodeSource.
codesource
- the CodeSource to which the returned
PermissionCollection has been granted.
public PermissionCollection getPermissions(ProtectionDomain domain)
Applications are discouraged from calling this method
since this operation may not be supported by all policy implementations.
Applications should rely on the implies
method
to perform policy checks.
The default implementation of this method first retrieves
the permissions returned via getPermissions(CodeSource)
(the CodeSource is taken from the specified ProtectionDomain),
as well as the permissions located inside the specified ProtectionDomain.
All of these permissions are then combined and returned in a new
PermissionCollection object. If getPermissions(CodeSource)
returns Policy.UNSUPPORTED_EMPTY_COLLECTION, then this method
returns the permissions contained inside the specified ProtectionDomain
in a new PermissionCollection object.
This method can be overridden if the policy implementation supports returning a set of permissions granted to a ProtectionDomain.
domain
- the ProtectionDomain to which the returned
PermissionCollection has been granted.
public boolean implies(ProtectionDomain domain, Permission permission)
domain
- the ProtectionDomain to testpermission
- the Permission object to be tested for implication.
ProtectionDomain
public void refresh()
refresh
on a file-based policy will cause the file to be re-read.
The default implementation of this method does nothing. This method should be overridden if a refresh operation is supported by the policy implementation.