summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--java/security/ProtectionDomain.java14
2 files changed, 25 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 18c60b24f..8144de577 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-12-24 Andrew John Hughes <ahughes@redhat.com>
+
+ * java/security/ProtectionDomain.java,
+ (hasAllPermissions): Add new field.
+ (ProtectionDomain(CodeSource,PermissionCollection,
+ ClassLoader,Principal,boolean)): Check if permission
+ collection includes AllPermission and, if so, set
+ hasAllPermissions.
+ (implies(Permission)): Immediately return true if
+ hasAllPermissions is set.
+
2006-07-21 Tom Tromey <tromey@redhat.com>
* vm/reference/java/lang/VMClass.java:
diff --git a/java/security/ProtectionDomain.java b/java/security/ProtectionDomain.java
index d5d657d61..9af87c64a 100644
--- a/java/security/ProtectionDomain.java
+++ b/java/security/ProtectionDomain.java
@@ -41,6 +41,8 @@ import gnu.classpath.SystemProperties;
import gnu.java.lang.CPStringBuilder;
+import java.util.Enumeration;
+
/**
* This class represents a group of classes, along with their granted
* permissions. The classes are identified by a {@link CodeSource}. Thus, any
@@ -71,6 +73,9 @@ public class ProtectionDomain
/** Post 1.4 the policy may be refreshed! use false for pre 1.4. */
private boolean staticBinding;
+ /** True if this protection domain has all permissions */
+ private boolean hasAllPermissions;
+
/**
* Initializes a new instance of <code>ProtectionDomain</code> representing
* the specified {@link CodeSource} and set of permissions. No permissions
@@ -128,6 +133,13 @@ public class ProtectionDomain
{
perms = permissions;
perms.setReadOnly();
+ /* Check if this protection domain has all permissions */
+ Enumeration<Permission> e = permissions.elements();
+ while (e.hasMoreElements())
+ {
+ if (e.nextElement() instanceof AllPermission)
+ hasAllPermissions = true;
+ }
}
this.classloader = classloader;
@@ -190,6 +202,8 @@ public class ProtectionDomain
*/
public boolean implies(Permission permission)
{
+ if (hasAllPermissions)
+ return true;
if (staticBinding)
return (perms == null ? false : perms.implies(permission));
// Else dynamically bound. Do we have it?