harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r463203 - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/KeyStore.java test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java
Date Thu, 12 Oct 2006 11:27:23 GMT
Author: mloenko
Date: Thu Oct 12 04:27:23 2006
New Revision: 463203

URL: http://svn.apache.org/viewvc?view=rev&rev=463203
Log:
applied patch from HARMONY-1539
[classlib][security] unexpected IllegalStateException for KeyStore.PasswordProtection(null).getPassword()

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyStore.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyStore.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyStore.java?view=diff&rev=463203&r1=463202&r2=463203
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyStore.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyStore.java
Thu Oct 12 04:27:23 2006
@@ -825,6 +825,8 @@
         // Store password
         private char[] password;
 
+        private boolean isDestroyed = false;
+
         /**
          * 
          *  
@@ -838,7 +840,7 @@
          *  
          */
         public synchronized char[] getPassword() {
-            if (password == null) {
+            if (isDestroyed) {
                 throw new IllegalStateException(Messages.getString("security.36")); //$NON-NLS-1$
             }
             return password;
@@ -849,8 +851,11 @@
          *  
          */
         public synchronized void destroy() throws DestroyFailedException {
-            Arrays.fill(password, '\u0000');
-            password = null;
+            isDestroyed = true;
+            if (password != null) {
+                Arrays.fill(password, '\u0000');
+                password = null;
+            }
         }
 
         /**
@@ -858,7 +863,7 @@
          *  
          */
         public synchronized boolean isDestroyed() {
-            return (password == null);
+            return isDestroyed;
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.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/KeyStoreTest.java?view=diff&rev=463203&r1=463202&r2=463203
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java
Thu Oct 12 04:27:23 2006
@@ -230,6 +230,15 @@
         }
     }
 
+    /**
+     * @test java.security.KeyStore.PasswordProtectionn.getPassword()
+     */
+    public void testKeyStorePPGetPassword() {
+        // Regression for HARMONY-1539
+        // no exception expected
+        assertNull(new KeyStore.PasswordProtection(null).getPassword());
+    }
+
 
     /*
      * @tests java.security.KeyStoreSpi.engineEntryInstanceOf(String, Class<? extends
Entry>)



Mime
View raw message