harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r586287 - in /harmony/enhanced/classlib/branches/java6/modules/security/src: main/java/common/java/security/BasicPermissionCollection.java test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java
Date Fri, 19 Oct 2007 07:12:11 GMT
Author: leoli
Date: Fri Oct 19 00:12:10 2007
New Revision: 586287

URL: http://svn.apache.org/viewvc?rev=586287&view=rev
Log:
Apply patch for ([java6][classlib][security]java.security.BasicPermissionCollection have special
treat for "exitVM" and "exitVM.*").

Modified:
    harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/BasicPermissionCollection.java
    harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/BasicPermissionCollection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/BasicPermissionCollection.java?rev=586287&r1=586286&r2=586287&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/BasicPermissionCollection.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/BasicPermissionCollection.java
Fri Oct 19 00:12:10 2007
@@ -120,6 +120,18 @@
         if (items.containsKey(checkName)) {
             return true;
         }
+        
+        //Special treat with RuntimePermission exitVM.*
+        if(items.containsKey("exitVM") || items.containsKey("exitVM.*")){
+            if(checkName.endsWith("exitVM")){
+                return true;
+            }
+            if(checkName.startsWith("exitVM.") && checkName.length() > "exitVM.".length()){
+                return true;
+            }
+        }       
+        
+        
         //now check if there are suitable wildcards
         //suppose we have "a.b.c", let's check "a.b.*" and "a.*" 
         char[] name = checkName.toCharArray();

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java?rev=586287&r1=586286&r2=586287&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java
Fri Oct 19 00:12:10 2007
@@ -78,4 +78,33 @@
         pc.setReadOnly();
         assertTrue("more calls to setReadOnly() should not harm", pc.isReadOnly());
     }
+    
+    // Regression test for "exitVM' special treatement in Java 6.
+    public void test_implies_exitVM() {
+
+        RuntimePermission runtimePermission = new RuntimePermission("exitVM");
+        PermissionCollection permissionCollection = runtimePermission
+                .newPermissionCollection();
+        permissionCollection.add(runtimePermission);
+        assertFalse(permissionCollection.implies(new RuntimePermission(
+                "exitVM.")));
+        assertTrue(permissionCollection.implies(new RuntimePermission(
+                "exitVM.1")));
+        assertTrue(permissionCollection.implies(new RuntimePermission(
+                "exitVM.teststring")));
+
+        runtimePermission = new RuntimePermission("exitVM.*");
+        permissionCollection = runtimePermission.newPermissionCollection();
+        permissionCollection.add(runtimePermission);
+        assertTrue(permissionCollection
+                .implies(new RuntimePermission("exitVM")));
+        assertFalse(permissionCollection.implies(new RuntimePermission(
+                "exitVMteststring")));
+        assertFalse(permissionCollection.implies(new RuntimePermission(
+                "exitVM.")));
+        assertTrue(permissionCollection.implies(new RuntimePermission(
+                "exitVM.1")));
+        assertTrue(permissionCollection.implies(new RuntimePermission(
+                "exitVM.teststring")));
+    }
 }



Mime
View raw message