harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r570639 - in /harmony/enhanced/classlib/trunk/modules/auth/src: main/java/common/org/apache/harmony/auth/module/LoginModuleUtils.java test/java/common/org/apache/harmony/auth/tests/module/LoginModuleUtilsTest.java
Date Wed, 29 Aug 2007 05:20:00 GMT
Author: leoli
Date: Tue Aug 28 22:19:59 2007
New Revision: 570639

URL: http://svn.apache.org/viewvc?rev=570639&view=rev
Log:
[classlib][auth]Add clearPassword method in org.apache.harmony.auth.module.LoginModuleUtils.

Modified:
    harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/LoginModuleUtils.java
    harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/module/LoginModuleUtilsTest.java

Modified: harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/LoginModuleUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/LoginModuleUtils.java?rev=570639&r1=570638&r2=570639&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/LoginModuleUtils.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/LoginModuleUtils.java
Tue Aug 28 22:19:59 2007
@@ -19,6 +19,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Arrays;
 
 public class LoginModuleUtils {
 
@@ -76,5 +77,18 @@
         }
         dest[position] = c;
         return dest;
+    }
+    
+    /**
+     * Cleans the password stored in one char array.
+     * 
+     * @param password
+     *            the char array which contains password.
+     */
+    public static void clearPassword(char[] password) {
+        if (password == null || password.length == 0) {
+            return;
+        }
+        Arrays.fill(password, '\0');
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/module/LoginModuleUtilsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/module/LoginModuleUtilsTest.java?rev=570639&r1=570638&r2=570639&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/module/LoginModuleUtilsTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/module/LoginModuleUtilsTest.java
Tue Aug 28 22:19:59 2007
@@ -58,5 +58,20 @@
         String expectedString = PASSWORD_AS_STRING + "\r";
         assertTrue(Arrays.equals(expectedString.toCharArray(), password));
     }
+    
+    public void testClearPassword() throws Exception {
+        final String PASSWORD_AS_STRING = "TESTPASSWORD";
+
+        char[] password = PASSWORD_AS_STRING.toCharArray();
+        LoginModuleUtils.clearPassword(password);
+        for (char c : password) {
+            assertEquals('\0', c);
+        }
+
+        password = null;
+        LoginModuleUtils.clearPassword(password);
+        password = new char[0];
+        LoginModuleUtils.clearPassword(password);
+    }
 
 }



Mime
View raw message