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 --- .../classpath/java/security/ProtectionDomain.java | 137 +++++++++------------ 1 file changed, 58 insertions(+), 79 deletions(-) (limited to 'libjava/classpath/java/security/ProtectionDomain.java') diff --git a/libjava/classpath/java/security/ProtectionDomain.java b/libjava/classpath/java/security/ProtectionDomain.java index a8a09392504..33af8fdb843 100644 --- a/libjava/classpath/java/security/ProtectionDomain.java +++ b/libjava/classpath/java/security/ProtectionDomain.java @@ -40,17 +40,14 @@ package java.security; import gnu.classpath.SystemProperties; /** - *

This ProtectionDomain class encapsulates the characteristics - * of a domain, which encloses a set of classes whose instances are granted a - * set of permissions when being executed on behalf of a given set of - * Principals. - * - *

A static set of permissions can be bound to a ProtectionDomain - * when it is constructed; such permissions are granted to the domain regardless - * of the {@link Policy} in force. However, to support dynamic security - * policies, a ProtectionDomain can also be constructed such that - * it is dynamically mapped to a set of permissions by the current {@link - * Policy} whenever a permission is checked.

+ * This class represents a group of classes, along with their granted + * permissions. The classes are identified by a {@link CodeSource}. Thus, any + * class loaded from the specified {@link CodeSource} is treated as part of + * this domain. The set of permissions is represented by an instance of + * {@link PermissionCollection}. + * + *

Every class in the system will belong to one and only one + * ProtectionDomain.

* * @author Aaron M. Renn (arenn@urbanophile.com) * @version 0.0 @@ -73,15 +70,17 @@ public class ProtectionDomain private boolean staticBinding; /** - * Creates a new ProtectionDomain with the given {@link - * CodeSource} and {@link Permissions}. If the permissions object is not - * null, then setReadOnly() will be called on the - * passed in {@link Permissions} object. The only permissions granted to this - * domain are the ones specified; the current {@link Policy} will not be - * consulted. - * - * @param codesource the codesource associated with this domain. - * @param permissions the permissions granted to this domain + * Initializes a new instance of ProtectionDomain representing + * the specified {@link CodeSource} and set of permissions. No permissions + * can be added later to the {@link PermissionCollection} and this contructor + * will call the setReadOnly method on the specified set of + * permissions. + * + * @param codesource + * The {@link CodeSource} for this domain. + * @param permissions + * The set of permissions for this domain. + * @see PermissionCollection#setReadOnly() */ public ProtectionDomain(CodeSource codesource, PermissionCollection permissions) { @@ -89,28 +88,25 @@ public class ProtectionDomain } /** - *

Creates a new ProtectionDomain qualified by the given CodeSource, - * Permissions, ClassLoader and array of Principals. If the permissions - * object is not null, then setReadOnly() will be called on the - * passed in Permissions object. The permissions granted to this domain are - * dynamic; they include both the static permissions passed to this - * constructor, and any permissions granted to this domain by the current - * Policy at the time a permission is checked.

- * - *

This constructor is typically used by {@link ClassLoader}s and {@link - * DomainCombiner}s which delegate to Policy to actively - * associate the permissions granted to this domain. This constructor affords - * the Policy provider the opportunity to augment the supplied - * PermissionCollection to reflect policy changes.

- * - * @param codesource the CodeSource associated with this domain. - * @param permissions the permissions granted to this domain. - * @param classloader the ClassLoader associated with this domain. - * @param principals the array of Principals associated with this domain. + * This method initializes a new instance of ProtectionDomain + * given its {@link CodeSource}, granted permissions, associated + * {@link ClassLoader} and {@link Principal}s. + * + *

Similar to the previous constructor, if the designated set of + * permissions is not null, the setReadOnly method + * is called on that set.

+ * + * @param codesource + * The {@link CodeSource} for this domain. + * @param permissions + * The permission set for this domain. + * @param classloader + * the ClassLoader associated with this domain. + * @param principals + * the array of {@link Principal}s associated with this domain. * @since 1.4 - * @see Policy#refresh() - * @see Policy#getPermissions(ProtectionDomain) - */ + * @see PermissionCollection#setReadOnly() + */ public ProtectionDomain(CodeSource codesource, PermissionCollection permissions, ClassLoader classloader, Principal[] principals) @@ -140,8 +136,8 @@ public class ProtectionDomain /** * Returns the {@link CodeSource} of this domain. - * - * @return the {@link CodeSource} of this domain which may be null. + * + * @return the {@link CodeSource} of this domain. * @since 1.2 */ public final CodeSource getCodeSource() @@ -151,9 +147,8 @@ public class ProtectionDomain /** * Returns the {@link ClassLoader} of this domain. - * - * @return the {@link ClassLoader} of this domain which may be - * null. + * + * @return the {@link ClassLoader} of this domain. * @since 1.4 */ public final ClassLoader getClassLoader() @@ -162,10 +157,9 @@ public class ProtectionDomain } /** - * Returns an array of principals for this domain. - * - * @return returns a non-null array of principals for this domain. Changes to - * this array will have no impact on the ProtectionDomain. + * Returns a clone of the {@link Principal}s of this domain. + * + * @return a clone of the {@link Principal}s of this domain. * @since 1.4 */ public final Principal[] getPrincipals() @@ -174,12 +168,9 @@ public class ProtectionDomain } /** - * Returns the static permissions granted to this domain. - * - * @return the static set of permissions for this domain which may be - * null. - * @see Policy#refresh() - * @see Policy#getPermissions(ProtectionDomain) + * Returns the {@link PermissionCollection} of this domain. + * + * @return The {@link PermissionCollection} of this domain. */ public final PermissionCollection getPermissions() { @@ -187,26 +178,13 @@ public class ProtectionDomain } /** - *

Check and see if this ProtectionDomain implies the - * permissions expressed in the Permission object.

- * - *

The set of permissions evaluated is a function of whether the - * ProtectionDomain was constructed with a static set of - * permissions or it was bound to a dynamically mapped set of permissions.

- * - *

If the ProtectionDomain was constructed to a statically - * bound {@link PermissionCollection} then the permission will only be checked - * against the {@link PermissionCollection} supplied at construction.

- * - *

However, if the ProtectionDomain was constructed with the - * constructor variant which supports dynamically binding permissions, then - * the permission will be checked against the combination of the - * {@link PermissionCollection} supplied at construction and the current - * {@link Policy} binding. - * - * @param permission the {@link Permission} object to check. - * @return true if permission is implicit to this - * ProtectionDomain. + * Tests whether or not the specified {@link Permission} is implied by the + * set of permissions granted to this domain. + * + * @param permission + * the {@link Permission} to test. + * @return true if the specified {@link Permission} is implied + * for this domain, false otherwise. */ public boolean implies(Permission permission) { @@ -218,9 +196,10 @@ public class ProtectionDomain } /** - * Convert a ProtectionDomain to a String. - * - * @return a string representation of the object. + * Returns a string representation of this object. It will include the + * {@link CodeSource} and set of permissions associated with this domain. + * + * @return A string representation of this object. */ public String toString() { -- cgit v1.2.3