diff options
Diffstat (limited to 'libjava/java/security')
-rw-r--r-- | libjava/java/security/Permissions.java | 11 | ||||
-rw-r--r-- | libjava/java/security/SecureClassLoader.java | 26 |
2 files changed, 33 insertions, 4 deletions
diff --git a/libjava/java/security/Permissions.java b/libjava/java/security/Permissions.java index d44341c..ce63cc2 100644 --- a/libjava/java/security/Permissions.java +++ b/libjava/java/security/Permissions.java @@ -228,9 +228,18 @@ class PermissionsHash extends PermissionCollection * @param perm the permission to check * @return true if it is implied */ + // FIXME: Should this method be synchronized? public boolean implies(Permission perm) { - return perms.get(perm) != null; + Enumeration elements = elements(); + + while (elements.hasMoreElements()) + { + Permission p = (Permission)elements.nextElement(); + if (p.implies(perm)) + return true; + } + return false; } /** diff --git a/libjava/java/security/SecureClassLoader.java b/libjava/java/security/SecureClassLoader.java index 7546edc..89b5e4e 100644 --- a/libjava/java/security/SecureClassLoader.java +++ b/libjava/java/security/SecureClassLoader.java @@ -48,6 +48,8 @@ package java.security; */ public class SecureClassLoader extends ClassLoader { + java.util.WeakHashMap protectionDomainCache = new java.util.WeakHashMap(); + protected SecureClassLoader(ClassLoader parent) { super(parent); @@ -80,11 +82,29 @@ public class SecureClassLoader extends ClassLoader protected final Class defineClass(String name, byte[] b, int off, int len, CodeSource cs) { - // FIXME: Need to cache ProtectionDomains according to 1.3 docs. if (cs != null) { - ProtectionDomain protectionDomain - = new ProtectionDomain(cs, getPermissions(cs), this, null); + ProtectionDomain protectionDomain; + + synchronized (protectionDomainCache) + { + protectionDomain = (ProtectionDomain)protectionDomainCache.get(cs); + } + + if (protectionDomain == null) + { + protectionDomain + = new ProtectionDomain(cs, getPermissions(cs), this, null); + synchronized (protectionDomainCache) + { + ProtectionDomain domain + = (ProtectionDomain)protectionDomainCache.get(cs); + if (domain == null) + protectionDomainCache.put(cs, protectionDomain); + else + protectionDomain = domain; + } + } return super.defineClass(name, b, off, len, protectionDomain); } else |