8156007: Refix: TestPolicy should extend the default security policy
authorfyuan
Thu, 05 May 2016 20:01:18 -0700
changeset 37841 2082ebf00d57
parent 37840 5b003787481f
child 37842 e62ce0da6263
8156007: Refix: TestPolicy should extend the default security policy Reviewed-by: mchung, joehw Contributed-by: Frank Yuan <frank.yuan@oracle.com>
jaxp/test/javax/xml/jaxp/libs/jaxp/library/TestPolicy.java
--- a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/TestPolicy.java	Thu May 05 19:10:31 2016 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/TestPolicy.java	Thu May 05 20:01:18 2016 -0700
@@ -36,6 +36,7 @@
 import java.util.PropertyPermission;
 import java.util.StringJoiner;
 
+
 /*
  * Simple Policy class that supports the required Permissions to validate the
  * JAXP concrete classes.
@@ -45,6 +46,8 @@
 public class TestPolicy extends Policy {
     protected final PermissionCollection permissions = new Permissions();
 
+    private static Policy defaultPolicy = Policy.getPolicy();
+
     /**
      * Constructor which sets the minimum permissions by default allowing testNG
      * to work with a SecurityManager.
@@ -87,11 +90,8 @@
                 "read"));
         permissions.add(new PropertyPermission("user.dir", "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("dataproviderthreadcount", "read"));
-        permissions.add(new RuntimePermission("charsetProvider"));
     }
 
     /*
@@ -145,6 +145,9 @@
 
     @Override
     public boolean implies(ProtectionDomain domain, Permission perm) {
+        if (defaultPolicy.implies(domain, perm))
+            return true;
+
         return permissions.implies(perm);
     }
 }