harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r828697 - in /harmony/enhanced/classlib/trunk: depends/jars/ make/depends.properties modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java support/src/test/java/tests/support/Support_PermissionCollection.java
Date Thu, 22 Oct 2009 13:57:13 GMT
Author: tellison
Date: Thu Oct 22 13:57:13 2009
New Revision: 828697

URL: http://svn.apache.org/viewvc?rev=828697&view=rev
Log:
Fix for HARMONY-6357 ([classlib][security] PermissionCollectionTest passes thanks to a bug
in bcprov.jar)

Update BouncyCastle dependency to version 1.44, and

fix the PermissionCollections test to:
 - write out the policy file in a valid format
 - assert the permissions implies correctly from the forked VM

Modified:
    harmony/enhanced/classlib/trunk/depends/jars/   (props changed)
    harmony/enhanced/classlib/trunk/make/depends.properties
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
    harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java

Propchange: harmony/enhanced/classlib/trunk/depends/jars/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Oct 22 13:57:13 2009
@@ -11,3 +11,4 @@
 asm-3.1
 icu4j_4.0
 icu4j_4.2.1
+bcprov-jdk15-144

Modified: harmony/enhanced/classlib/trunk/make/depends.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/depends.properties?rev=828697&r1=828696&r2=828697&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/make/depends.properties (original)
+++ harmony/enhanced/classlib/trunk/make/depends.properties Thu Oct 22 13:57:13 2009
@@ -90,11 +90,11 @@
 
 depends.url=http://svn.apache.org/repos/asf/harmony/standard/depends
 
-bcprov.ver=bcprov-jdk15-141
+bcprov.ver=bcprov-jdk15-144
 bcprov.dir=${depends.jars}/${bcprov.ver}
 bcprov.jar=${bcprov.dir}/bcprov.jar
 bcprov.url=${depends.url}/jars/bcprov/${bcprov.ver}/bcprov.jar
-bcprov.md5=f7cd7e1dcfe4b84d820b3a0937dc13f4
+bcprov.md5=0d6f0b31730db6fd1f8360cf1f7666d4
 
 icu4j.ver=icu4j_4.2.1
 icu4j.dir=${depends.jars}/${icu4j.ver}

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java?rev=828697&r1=828696&r2=828697&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
Thu Oct 22 13:57:13 2009
@@ -56,16 +56,17 @@
     public void test_impliesLjava_security_Permission() throws Exception{
 
         // Look for the tests classpath
-        URL classURL = this.getClass().getProtectionDomain().getCodeSource()
-                .getLocation();
+        URL classURL = this.getClass().getProtectionDomain().getCodeSource().getLocation();
         assertNotNull("Could not get this class' location", classURL);
 
         File policyFile = Support_GetLocal.createTempFile(".policy");
         policyFile.deleteOnExit();
 
         URL signedBKS = getResourceURL("PermissionCollection/signedBKS.jar");
+        String signedBKSPath = new File(signedBKS.getFile()).getCanonicalPath();
+        signedBKSPath = signedBKSPath.replace('\\', '/');
         URL keystoreBKS = getResourceURL("PermissionCollection/keystore.bks");
-        
+
         // Create the policy file (and save the existing one if any)
         FileOutputStream fileOut = null;
         try {
@@ -74,45 +75,50 @@
             StringBuilder towrite = new StringBuilder();
             towrite.append("grant {");
             towrite.append(linebreak);
-            towrite.append("permission java.io.FilePermission \"");
-            towrite.append(signedBKS.getFile());
+            towrite.append("    permission java.io.FilePermission \"");
+            towrite.append(signedBKSPath);
             towrite.append("\", \"read\";");
             towrite.append(linebreak);
-            towrite.append("permission java.lang.RuntimePermission \"getProtectionDomain\";");
+            towrite.append("    permission java.lang.RuntimePermission \"getProtectionDomain\";");
             towrite.append(linebreak);
-            towrite.append("permission java.security.SecurityPermission \"getPolicy\";");
+            towrite.append("    permission java.security.SecurityPermission \"getPolicy\";");
             towrite.append(linebreak);
             towrite.append("};");
             towrite.append(linebreak);
+            towrite.append(linebreak);
             towrite.append("grant codeBase \"");
             towrite.append(signedBKS.toExternalForm());
             towrite.append("\" signedBy \"eleanor\" {");
             towrite.append(linebreak);
-            towrite.append("permission java.io.FilePermission \"test1.txt\", \"write\";");
+            towrite.append("    permission java.io.FilePermission \"test1.txt\", \"write\";");
             towrite.append(linebreak);
-            towrite.append("permission mypackage.MyPermission \"essai\", signedBy \"eleanor,dylan\";");
+            towrite.append("    permission mypackage.MyPermission \"essai\", signedBy \"eleanor,dylan\";");
             towrite.append(linebreak);
             towrite.append("};");
             towrite.append(linebreak);
+            towrite.append(linebreak);
             towrite.append("grant codeBase \"");
             towrite.append(signedBKS.toExternalForm());
             towrite.append("\" signedBy \"eleanor\" {");
             towrite.append(linebreak);
-            towrite.append("permission java.io.FilePermission \"test2.txt\", \"write\";");
+            towrite.append("    permission java.io.FilePermission \"test2.txt\", \"write\";");
             towrite.append(linebreak);
             towrite.append("};");
             towrite.append(linebreak);
+            towrite.append(linebreak);
             towrite.append("grant codeBase \"");
             towrite.append(classURL.toExternalForm());
             towrite.append("\" {");
             towrite.append(linebreak);
-            towrite.append("permission java.security.AllPermission;");
+            towrite.append("    permission java.security.AllPermission;");
             towrite.append(linebreak);
             towrite.append("};");
             towrite.append(linebreak);
+            towrite.append(linebreak);
             towrite.append("keystore \"");
             towrite.append(keystoreBKS.toExternalForm());
-            towrite.append("\",\"BKS\";");            
+            towrite.append("\",\"BKS\";");
+            towrite.append(linebreak);
             fileOut.write(towrite.toString().getBytes());
             fileOut.flush();
         } finally {
@@ -122,14 +128,12 @@
         }
 
         // Copy mypermissionBKS.jar to the user directory so that it can be put
-        // in
-        // the classpath
+        // in the classpath.
         File jarFile = null;
         FileOutputStream fout = null;
         InputStream jis = null;
         try {
-            jis = Support_Resources
-                    .getResourceStream("PermissionCollection/mypermissionBKS.jar");
+            jis = Support_Resources.getResourceStream("PermissionCollection/mypermissionBKS.jar");
             jarFile = Support_GetLocal.createTempFile(".jar");
             jarFile.deleteOnExit();
             fout = new FileOutputStream(jarFile);
@@ -163,12 +167,10 @@
         StringTokenizer resultTokenizer = new StringTokenizer(result, ",");
 
         // Check the test result from the new VM process
-        assertEquals("Permission should be granted", "false", resultTokenizer
-                .nextToken());
-        assertEquals("signed Permission should be granted", "false",
-                resultTokenizer.nextToken());
-        assertEquals("Permission should not be granted", "false",
-                resultTokenizer.nextToken());
+        assertEquals("Permission should be granted for test1.txt", "true", resultTokenizer.nextToken());
+        assertEquals("Signed Permission should be granted for my permission", "true", resultTokenizer.nextToken());
+        assertEquals("signed Permission should be granted for text2.txt", "true", resultTokenizer.nextToken());
+        assertEquals("Permission should not be granted for text3.txt", "false", resultTokenizer.nextToken());
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java?rev=828697&r1=828696&r2=828697&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java
(original)
+++ harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java
Thu Oct 22 13:57:13 2009
@@ -43,13 +43,14 @@
 		PermissionCollection coll = Policy.getPolicy().getPermissions(pd);
 		Class<?> myPermission = Class.forName("mypackage.MyPermission");
 		BasicPermission myperm = (BasicPermission) myPermission.newInstance();
-		System.out.println(coll.implies(new java.io.FilePermission("test1.txt",
-				"write"))
+		System.out.println(
+		        coll.implies(new java.io.FilePermission("test1.txt", "write"))
 				+ ","
 				+ coll.implies(myperm)
+                + ","
+                + coll.implies(new java.io.FilePermission("test2.txt", "write"))
 				+ ","
-				+ coll
-						.implies(new java.io.FilePermission("test2.txt",
-								"write")) + ",");
+				+ coll.implies(new java.io.FilePermission("test3.txt", "read"))
+				+ ",");
 	}
 }
\ No newline at end of file



Mime
View raw message