diff options
| author | gandalf <gandalf@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-23 15:19:26 +0000 |
|---|---|---|
| committer | gandalf <gandalf@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-23 15:19:26 +0000 |
| commit | 5c7411981584e487ac41794feb98a66df9fd6fcb (patch) | |
| tree | febe3d4d4c0c994db223fee8e819bde6582494c9 /libjava/classpath/java/security | |
| parent | 112dfe9f689af01c2dd00e0f153fc25d69095b6c (diff) | |
| download | ppe42-gcc-5c7411981584e487ac41794feb98a66df9fd6fcb.tar.gz ppe42-gcc-5c7411981584e487ac41794feb98a66df9fd6fcb.zip | |
Merge GNU Classpath 0.99 into libjava.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185741 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/security')
| -rw-r--r-- | libjava/classpath/java/security/KeyStore.java | 7 | ||||
| -rw-r--r-- | libjava/classpath/java/security/ProtectionDomain.java | 24 |
2 files changed, 29 insertions, 2 deletions
diff --git a/libjava/classpath/java/security/KeyStore.java b/libjava/classpath/java/security/KeyStore.java index b7a0e2ab1f1..25173e54370 100644 --- a/libjava/classpath/java/security/KeyStore.java +++ b/libjava/classpath/java/security/KeyStore.java @@ -214,7 +214,12 @@ public class KeyStore { // Security reads every property in java.security so it // will return this property if it exists. - String tmp = Security.getProperty("keystore.type"); + String tmp = AccessController.doPrivileged(new PrivilegedAction<String> () { + public String run() + { + return Security.getProperty("keystore.type"); + } + }); if (tmp == null) tmp = "gkr"; diff --git a/libjava/classpath/java/security/ProtectionDomain.java b/libjava/classpath/java/security/ProtectionDomain.java index d5d657d615f..7be5875dc72 100644 --- a/libjava/classpath/java/security/ProtectionDomain.java +++ b/libjava/classpath/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? @@ -241,7 +255,15 @@ public class ProtectionDomain sb.append(linesep); if (!staticBinding) // include all but dont force loading Policy.currentPolicy if (Policy.isLoaded()) - sb.append(Policy.getCurrentPolicy().getPermissions(this)); + try + { + sb.append(Policy.getPolicy().getPermissions(this)); + } + catch (SecurityException e) + { + // We are not allowed access to the policy. + sb.append(perms); + } else // fallback on this one's permissions sb.append(perms); else |

