harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r896308 - in /harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/org/apache/harmony/security/ test/api/java/org/apache/harmony/security/tests/java/security/ test/resources/
Date Wed, 06 Jan 2010 02:29:05 GMT
Author: regisxu
Date: Wed Jan  6 02:29:04 2010
New Revision: 896308

URL: http://svn.apache.org/viewvc?rev=896308&view=rev
Log:
Apply patch for HARMONY-6415: [classlib][Security] policy file content parcing is different
from RI

Added:
    harmony/enhanced/classlib/trunk/modules/security/src/test/resources/policyTest2.txt
Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/DefaultPolicyScanner.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessController2Test.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/DefaultPolicyScanner.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/DefaultPolicyScanner.java?rev=896308&r1=896307&r2=896308&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/DefaultPolicyScanner.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/DefaultPolicyScanner.java
Wed Jan  6 02:29:04 2010
@@ -309,7 +309,8 @@
             case StreamTokenizer.TT_WORD:
                 if (Util.equalsIgnoreCase("permission", st.sval)) { //$NON-NLS-1$
                     PermissionEntry pe = new PermissionEntry();
-                    if (st.nextToken() == StreamTokenizer.TT_WORD) {
+                    int tok = st.nextToken();
+                    if (tok == StreamTokenizer.TT_WORD || tok == '"') {
                         pe.klass = st.sval;
                         if (st.nextToken() == '"') {
                             pe.name = st.sval;

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessController2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessController2Test.java?rev=896308&r1=896307&r2=896308&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessController2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessController2Test.java
Wed Jan  6 02:29:04 2010
@@ -76,4 +76,35 @@
 
         }
     }
-}
\ No newline at end of file
+
+    /**
+     * Test method tests the policy file with one of the entrie's
+     * permission_class_name surrounded with quotes.
+     * 
+     */
+    public void test_policyFileEntry_contains_Quotes1() throws Exception{
+        System.setProperty("java.security.policy", "resources/policyTest2.txt");
+        AccessController.checkPermission(new RuntimePermission("setSecurityManager"));
+    }
+    
+    /**
+     * Test method tests the policy file, one of the entrie's
+     * permission_class_name surrounded with quotes.
+     * 
+     */
+    public void test_policyFileEntry_contains_Quotes2() throws Exception{
+        class CustomSecurityMgr extends SecurityManager{
+            CustomSecurityMgr(){ }
+        }
+
+        System.setProperty("java.security.policy", "resources/policyTest2.txt");
+        SecurityManager security = System.getSecurityManager();
+        System.setSecurityManager(security);
+
+        // Setting the CustomSecurity Manager
+        SecurityManager customsecurity = new CustomSecurityMgr();
+        System.setSecurityManager(customsecurity);
+        customsecurity = System.getSecurityManager();
+        System.setSecurityManager(security);
+    }
+}

Added: harmony/enhanced/classlib/trunk/modules/security/src/test/resources/policyTest2.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/policyTest2.txt?rev=896308&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/resources/policyTest2.txt (added)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/resources/policyTest2.txt Wed
Jan  6 02:29:04 2010
@@ -0,0 +1,10 @@
+grant {
+permission java.util.PropertyPermission "user.dir", "read";
+permission java.lang.RuntimePermission "createClassLoader";
+permission java.io.FilePermission "<<ALL FILES>>", "delete";
+permission java.io.FilePermission "<<ALL FILES>>", "read";
+permission "java.util.PropertyPermission" "java.security.policy", "write";
+permission "java.lang.RuntimePermission" "setSecurityManager";
+permission "java.util.PropertyPermission" "java.security.policy", "read";
+permission "java.lang.RuntimePermission" "setIO";
+};



Mime
View raw message