harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r988045 - in /harmony/enhanced/java/trunk/jdktools/modules: jdktools/src/main/java/org/apache/harmony/tools/keytool/ jretools/src/main/java/org/apache/harmony/jretools/keytool/ jretools/src/test/java/org/apache/harmony/jretools/tests/keytool/
Date Mon, 23 Aug 2010 09:37:57 GMT
Author: odeakin
Date: Mon Aug 23 09:37:56 2010
New Revision: 988045

URL: http://svn.apache.org/viewvc?rev=988045&view=rev
Log:
Commit slightly modified patch for HARMONY-6631 ([jdktools][keytool] All interactive input
is truncated by one character on linux).

Modified:
    harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java
    harmony/enhanced/java/trunk/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/ArgumentsParser.java
    harmony/enhanced/java/trunk/jdktools/modules/jretools/src/test/java/org/apache/harmony/jretools/tests/keytool/GenKeyTest.java

Modified: harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java?rev=988045&r1=988044&r2=988045&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java
(original)
+++ harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java
Mon Aug 23 09:37:56 2010
@@ -49,9 +49,10 @@ class ArgumentsParser {
     // maximum number of attempts to set the password
     static int maxNrOfAttempts = 3;
 
-    // length of the "\r\n" which is added to the end of the line,
-    // when ENTER is pressed.
-    private static int newLineLength = 2;
+    // length of the newline which is added to the end of the line
+    // when ENTER is pressed - on windows this is "\r\n", otherwise "\n"
+    private static int newLineLength = 
+        (File.separatorChar == '\\') ? 2 : 1;
 
     // options names to compare to //
     // commands
@@ -316,10 +317,18 @@ class ArgumentsParser {
                 }
                 if (args[i].compareToIgnoreCase(sStorepass) == 0) {
                     param.setStorePass(args[++i].toCharArray());
+                    if (param.getStorePass().length < minPwdLength) {
+                        throw new KeytoolException("The password must be at least "
+                                + minPwdLength + " characters");
+                    }
                     continue;
                 }
                 if (args[i].compareToIgnoreCase(sKeypass) == 0) {
                     param.setKeyPass(args[++i].toCharArray());
+                    if (param.getKeyPass().length < minPwdLength) {
+                        throw new KeytoolException("The password must be at least "
+                                + minPwdLength + " characters");
+                    }
                     continue;
                 }
                 if (args[i].compareToIgnoreCase(sIssuerPass) == 0) {

Modified: harmony/enhanced/java/trunk/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/ArgumentsParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/ArgumentsParser.java?rev=988045&r1=988044&r2=988045&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/ArgumentsParser.java
(original)
+++ harmony/enhanced/java/trunk/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/ArgumentsParser.java
Mon Aug 23 09:37:56 2010
@@ -49,9 +49,10 @@ class ArgumentsParser {
     // maximum number of attempts to set the password
     static int maxNrOfAttempts = 3;
 
-    // length of the "\r\n" which is added to the end of the line,
-    // when ENTER is pressed.
-    private static int newLineLength = 2;
+    // length of the newline which is added to the end of the line
+    // when ENTER is pressed - on windows this is "\r\n", otherwise "\n"
+    private static int newLineLength = 
+        (File.separatorChar == '\\') ? 2 : 1;
 
     // options names to compare to //
     // commands
@@ -316,10 +317,18 @@ class ArgumentsParser {
                 }
                 if (args[i].compareToIgnoreCase(sStorepass) == 0) {
                     param.setStorePass(args[++i].toCharArray());
+                    if (param.getStorePass().length < minPwdLength) {
+                        throw new KeytoolException("The password must be at least "
+                                + minPwdLength + " characters");
+                    }
                     continue;
                 }
                 if (args[i].compareToIgnoreCase(sKeypass) == 0) {
                     param.setKeyPass(args[++i].toCharArray());
+                    if (param.getKeyPass().length < minPwdLength) {
+                        throw new KeytoolException("The password must be at least "
+                                + minPwdLength + " characters");
+                    }
                     continue;
                 }
                 if (args[i].compareToIgnoreCase(sIssuerPass) == 0) {

Modified: harmony/enhanced/java/trunk/jdktools/modules/jretools/src/test/java/org/apache/harmony/jretools/tests/keytool/GenKeyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/jdktools/modules/jretools/src/test/java/org/apache/harmony/jretools/tests/keytool/GenKeyTest.java?rev=988045&r1=988044&r2=988045&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/jdktools/modules/jretools/src/test/java/org/apache/harmony/jretools/tests/keytool/GenKeyTest.java
(original)
+++ harmony/enhanced/java/trunk/jdktools/modules/jretools/src/test/java/org/apache/harmony/jretools/tests/keytool/GenKeyTest.java
Mon Aug 23 09:37:56 2010
@@ -238,6 +238,32 @@ public class GenKeyTest extends TestCase
             }
             // set normal issuer alias back
             args[26] = issuerAlias;
+            
+            // bad store password length
+            args[4] = "12345";
+            try {
+                Main.run(args);
+                fail(excNotThrown);
+            } catch (KeytoolException ok) {
+                assertNotNull(ok.getMessage());
+                assertTrue("Expected password length error, got: " + 
+                        ok.getMessage(), 
+                        ok.getMessage().contains("The password must be at least"));
+            }
+            args[4] = TestUtils.ksPass;
+            
+            // bad key password length
+            args[10] = "12345";
+            try {
+                Main.run(args);
+                fail(excNotThrown);
+            } catch (KeytoolException ok) {
+                assertNotNull(ok.getMessage());
+                assertTrue("Expected password length error, got: " + 
+                        ok.getMessage(), 
+                        ok.getMessage().contains("The password must be at least"));
+            }
+            args[10] = TestUtils.keyPass;
         } finally {
             keyStoreFile.delete();
         }



Mime
View raw message