8156007: Refix: TestPolicy should extend the default security policy
Reviewed-by: mchung, joehw
This commit is contained in:
parent
88bfcfc1cb
commit
c3a6242368
@ -36,6 +36,7 @@ import java.util.Enumeration;
|
|||||||
import java.util.PropertyPermission;
|
import java.util.PropertyPermission;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple Policy class that supports the required Permissions to validate the
|
* Simple Policy class that supports the required Permissions to validate the
|
||||||
* JAXP concrete classes.
|
* JAXP concrete classes.
|
||||||
@ -45,6 +46,8 @@ import java.util.StringJoiner;
|
|||||||
public class TestPolicy extends Policy {
|
public class TestPolicy extends Policy {
|
||||||
protected final PermissionCollection permissions = new Permissions();
|
protected final PermissionCollection permissions = new Permissions();
|
||||||
|
|
||||||
|
private static Policy defaultPolicy = Policy.getPolicy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor which sets the minimum permissions by default allowing testNG
|
* Constructor which sets the minimum permissions by default allowing testNG
|
||||||
* to work with a SecurityManager.
|
* to work with a SecurityManager.
|
||||||
@ -87,11 +90,8 @@ public class TestPolicy extends Policy {
|
|||||||
"read"));
|
"read"));
|
||||||
permissions.add(new PropertyPermission("user.dir", "read"));
|
permissions.add(new PropertyPermission("user.dir", "read"));
|
||||||
permissions.add(new PropertyPermission("test.src", "read"));
|
permissions.add(new PropertyPermission("test.src", "read"));
|
||||||
permissions.add(new PropertyPermission("file.separator", "read"));
|
|
||||||
permissions.add(new PropertyPermission("line.separator", "read"));
|
|
||||||
permissions.add(new PropertyPermission("fileStringBuffer", "read"));
|
permissions.add(new PropertyPermission("fileStringBuffer", "read"));
|
||||||
permissions.add(new PropertyPermission("dataproviderthreadcount", "read"));
|
permissions.add(new PropertyPermission("dataproviderthreadcount", "read"));
|
||||||
permissions.add(new RuntimePermission("charsetProvider"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -145,6 +145,9 @@ public class TestPolicy extends Policy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean implies(ProtectionDomain domain, Permission perm) {
|
public boolean implies(ProtectionDomain domain, Permission perm) {
|
||||||
|
if (defaultPolicy.implies(domain, perm))
|
||||||
|
return true;
|
||||||
|
|
||||||
return permissions.implies(perm);
|
return permissions.implies(perm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user