From 8aa540d2f783474d1d2e06f16744bf67b9c1facc Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 10 Mar 2006 21:46:48 +0000 Subject: Imported GNU Classpath 0.90 Imported GNU Classpath 0.90 * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore. * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant. * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5. * java/lang/Math.java: New override file. * java/lang/Character.java: Merged from Classpath. (start, end): Now 'int's. (canonicalName): New field. (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants. (UnicodeBlock): Added argument. (of): New overload. (forName): New method. Updated unicode blocks. (sets): Updated. * sources.am: Regenerated. * Makefile.in: Likewise. From-SVN: r111942 --- libjava/classpath/java/security/Policy.java | 175 +++++++++++++--------------- 1 file changed, 81 insertions(+), 94 deletions(-) (limited to 'libjava/classpath/java/security/Policy.java') diff --git a/libjava/classpath/java/security/Policy.java b/libjava/classpath/java/security/Policy.java index 03d9bbb4ed6..de1ab80ef19 100644 --- a/libjava/classpath/java/security/Policy.java +++ b/libjava/classpath/java/security/Policy.java @@ -43,49 +43,43 @@ import java.util.LinkedHashMap; import java.util.Map; /** - *

This is an abstract class for representing the system security policy for - * a Java application environment (specifying which permissions are available - * for code from various sources). That is, the security policy is represented - * by a Policy subclass providing an implementation of the abstract - * methods in this Policy class.

- * - *

There is only one Policy object in effect at any given time. - *

- * - *

The source location for the policy information utilized by the - * Policy object is up to the Policy implementation. - * The policy configuration may be stored, for example, as a flat ASCII file, as - * a serialized binary file of the Policy class, or as a database. - *

- * - *

The currently-installed Policy object can be obtained by - * calling the getPolicy() method, and it can be changed by a call - * to the setPolicy() method (by code with permission to reset the - * Policy).

- * - *

The refresh() method causes the policy object to refresh / - * reload its current configuration.

- * - *

This is implementation-dependent. For example, if the policy object stores - * its policy in configuration files, calling refresh() will cause - * it to re-read the configuration policy files. The refreshed policy may not - * have an effect on classes in a particular {@link ProtectionDomain}. This is - * dependent on the Policy provider's implementation of the - * implies() method and the {@link PermissionCollection} caching - * strategy.

- * + * Policy is an abstract class for managing the system security + * policy for the Java application environment. It specifies which permissions + * are available for code from various sources. The security policy is + * represented through a subclass of Policy. + * + *

Only one Policy is in effect at any time. A + * {@link ProtectionDomain} initializes itself with information from this class + * on the set of permssions to grant.

+ * + *

The location for the actual Policy could be anywhere in any + * form because it depends on the Policy implementation. The default system is + * in a flat ASCII file or it could be in a database.

+ * + *

The current installed Policy can be accessed with + * {@link #getPolicy()} and changed with {@link #setPolicy(Policy)} if the code + * has the correct permissions.

+ * + *

The {@link #refresh()} method causes the Policy instance to + * refresh/reload its configuration. The method used to refresh depends on the + * Policy implementation.

+ * + *

When a protection domain initializes its permissions, it uses code like + * the following:

+ * + * + * policy = Policy.getPolicy(); + * PermissionCollection perms = policy.getPermissions(myCodeSource); + * + * + *

The protection domain passes the Policy handler a + * {@link CodeSource} instance which contains the codebase URL and a public key. + * The Policy implementation then returns the proper set of + * permissions for that {@link CodeSource}.

+ * *

The default Policy implementation can be changed by setting - * the value of the "policy.provider" security property (in the - * Java security properties file) to the fully qualified name of the desired - * Policy implementation class. The Java security properties file - * is located in the file named <JAVA_HOME>/lib/security/java.security - * , where <JAVA_HOME> refers to the directory where the - * SDK was installed.

- * - *

IMPLEMENTATION NOTE: This implementation attempts to read the - * System property named policy.provider to find the concrete - * implementation of the Policy. If/when this fails, it falls back - * to a default implementation, which allows everything. + * the "policy.provider" security provider in the "java.security" file to the + * correct Policy implementation class.

* * @author Mark Benvenuto * @see CodeSource @@ -106,18 +100,14 @@ public abstract class Policy } /** - * Returns the installed Policy object. This value should not be - * cached, as it may be changed by a call to setPolicy(). This - * method first calls {@link SecurityManager#checkPermission(Permission)} with - * a SecurityPermission("getPolicy") permission to ensure it's ok - * to get the Policy object. - * - * @return the installed Policy. - * @throws SecurityException if a security manager exists and its - * checkPermission() method doesn't allow getting the - * Policy object. - * @see SecurityManager#checkPermission(Permission) - * @see #setPolicy(Policy) + * Returns the currently installed Policy handler. The value + * should not be cached as it can be changed any time by + * {@link #setPolicy(Policy)}. + * + * @return the current Policy. + * @throws SecurityException + * if a {@link SecurityManager} is installed which disallows this + * operation. */ public static Policy getPolicy() { @@ -129,17 +119,13 @@ public abstract class Policy } /** - * Sets the system-wide Policy object. This method first calls - * {@link SecurityManager#checkPermission(Permission)} with a - * SecurityPermission("setPolicy") permission to ensure it's ok - * to set the Policy. - * - * @param policy the new system Policy object. - * @throws SecurityException if a security manager exists and its - * checkPermission() method doesn't allow setting the - * Policy. - * @see SecurityManager#checkPermission(Permission) - * @see #getPolicy() + * Sets the Policy handler to a new value. + * + * @param policy + * the new Policy to use. + * @throws SecurityException + * if a {@link SecurityManager} is installed which disallows this + * operation. */ public static void setPolicy(Policy policy) { @@ -213,28 +199,27 @@ public abstract class Policy } /** - * Evaluates the global policy and returns a {@link PermissionCollection} - * object specifying the set of permissions allowed for code from the - * specified code source. - * - * @param codesource the {@link 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. - * @return 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 {@link Permission} types. + * Returns the set of Permissions allowed for a given {@link CodeSource}. + * + * @param codesource + * the {@link CodeSource} for which, the caller needs to find the + * set of granted permissions. + * @return a set of permissions for {@link CodeSource} specified by the + * current Policy. + * @throws SecurityException + * if a {@link SecurityManager} is installed which disallows this + * operation. */ public abstract PermissionCollection getPermissions(CodeSource codesource); /** - * Evaluates the global policy and returns a {@link PermissionCollection} - * object specifying the set of permissions allowed given the characteristics - * of the protection domain. - * - * @param domain the {@link ProtectionDomain} associated with the caller. - * @return 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 {@link Permission} types. + * Returns the set of Permissions allowed for a given {@link ProtectionDomain}. + * + * @param domain + * the {@link ProtectionDomain} for which, the caller needs to find + * the set of granted permissions. + * @return a set of permissions for {@link ProtectionDomain} specified by the + * current Policy.. * @since 1.4 * @see ProtectionDomain * @see SecureClassLoader @@ -270,14 +255,16 @@ public abstract class Policy } /** - * Evaluates the global policy for the permissions granted to the {@link - * ProtectionDomain} and tests whether the permission is granted. - * - * @param domain the {@link ProtectionDomain} to test. - * @param permission the {@link Permission} object to be tested for - * implication. - * @return true if permission is a proper subset of - * a permission granted to this {@link ProtectionDomain}. + * Checks if the designated {@link Permission} is granted to a designated + * {@link ProtectionDomain}. + * + * @param domain + * the {@link ProtectionDomain} to test. + * @param permission + * the {@link Permission} to check. + * @return true if permission is implied by a + * permission granted to this {@link ProtectionDomain}. Returns + * false otherwise. * @since 1.4 * @see ProtectionDomain */ @@ -302,9 +289,9 @@ public abstract class Policy } /** - * Refreshes/reloads the policy configuration. The behavior of this method - * depends on the implementation. For example, calling refresh on a file-based - * policy will cause the file to be re-read. + * Causes this Policy instance to refresh / reload its + * configuration. The method used to refresh depends on the concrete + * implementation. */ public abstract void refresh(); } -- cgit v1.2.3