harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r469592 - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/ test/api/java/org/apache/harmony/security/tests/java/security/
Date Tue, 31 Oct 2006 18:15:51 GMT
Author: pyang
Date: Tue Oct 31 10:15:49 2006
New Revision: 469592

URL: http://svn.apache.org/viewvc?view=rev&rev=469592
Log:
Fix two compability issues:
1. CodeSource.getCodeSigner() should not throw NPE but return null when certs field is null
2. IdentityScope.getSystemScope() should read security property "system.scope" to find the
implementation class

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/CodeSource.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/IdentityScope.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/CodeSource.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/CodeSource.java?view=diff&rev=469592&r1=469591&r2=469592
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/CodeSource.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/CodeSource.java
Tue Oct 31 10:15:49 2006
@@ -177,14 +177,12 @@
     }
 
     public final CodeSigner[] getCodeSigners() {
-
         if (signers != null) {
             CodeSigner[] tmp = new CodeSigner[signers.length];
             System.arraycopy(signers, 0, tmp, 0, tmp.length);
             return tmp;
         }
-
-        if (factory != null) {
+        if(certs == null || factory != null){
             // factory != null means we've done this exercise already.
             return null;
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/IdentityScope.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/IdentityScope.java?view=diff&rev=469592&r1=469591&r2=469592
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/IdentityScope.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/IdentityScope.java
Tue Oct 31 10:15:49 2006
@@ -67,9 +67,24 @@
      * @com.intel.drl.spec_ref 
      */
     public static IdentityScope getSystemScope() {
-
+        /* 
+         * Test shows that the implementation class name is read from security property
+         * "system.scope", and the class is only loaded from boot classpath. No default
+         * implementation as fallback, i.e., return null if fails to init an instance. 
+         */
         if (systemScope == null) {
-            systemScope = new SystemScope("System Scope"); //$NON-NLS-1$
+            String className = AccessController.doPrivileged(new PrivilegedAction<String>(){
+                public String run() {
+                    return Security.getProperty("system.scope"); //$NON-NLS-1$
+                }
+            });
+            if(className != null){
+                try {
+                    systemScope = (IdentityScope) Class.forName(className).newInstance();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
         }
         return systemScope;
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java?view=diff&rev=469592&r1=469591&r2=469592
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java
Tue Oct 31 10:15:49 2006
@@ -340,6 +340,10 @@
             assertTrue(found);
         }
     }
+    
+    public void testGetCoderSignersNull() throws Exception{
+        assertNull(new CodeSource(new URL("http://url"), (Certificate[])null).getCodeSigners());
//$NON-NLS-1$
+    }
 
     /**
      * Tests CodeSource.getLocation()

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java?view=diff&rev=469592&r1=469591&r2=469592
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java
Tue Oct 31 10:15:49 2006
@@ -93,7 +93,11 @@
      * just call IdentityScope.getSystemScope()
      */
     public final void testGetSystemScope() {
-        assertNotNull(IdentityScope.getSystemScope());
+        String name = Security.getProperty("system.scope");
+        assertNotNull(name);
+        IdentityScope scope = IdentityScope.getSystemScope(); 
+        assertNotNull(scope);
+        assertEquals(name, scope.getClass().getName());
     }
 
     /**
@@ -103,7 +107,9 @@
      */
     
     public final void testSetSystemScope() {
+//      default implementation is specified by security property system.scope
         IdentityScope systemScope = IdentityScope.getSystemScope();
+        
         try {
             // all permissions are granted - sm is not installed
             is = new IdentityScopeStub("Aleksei Semenov");
@@ -133,6 +139,7 @@
             IdentityScopeStub.mySetSystemScope(systemScope);
         }
     }
+    
 
     /**
      * Class under test for Identity getIdentity(Principal)



Mime
View raw message