Merge GNU Classpath 0.99 into libjava.

From-SVN: r185741
This commit is contained in:
Andrew John Hughes
2012-03-23 15:19:26 +00:00
parent 21669dfe20
commit 0563022a20
516 changed files with 64503 additions and 61116 deletions
@@ -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";
@@ -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