New switch for jdk keytool command

Rich Midwinter rich.midwinter at gmail.com
Sun Dec 14 19:01:55 UTC 2014


Hi

I'd like to see a new switch added to keytool to initialise an empty
keystore, for which I've attached a first shot at a patch.

Could someone point me in the right direction to see if this can be
included (on the assumption this email alone isn't sufficient).

Thanks
Rich
-------------- next part --------------
diff --git a/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/src/java.base/share/classes/sun/security/tools/keytool/Main.java
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java
@@ -204,6 +204,7 @@
             SRCALIAS, DESTALIAS, SRCKEYPASS, DESTKEYPASS,
             NOPROMPT, PROVIDERCLASS, PROVIDERARG, PROVIDERPATH,
             V),
+        INIT("Creates.an.initial.empty.keystore", KEYSTORE, STOREPASS),
         KEYPASSWD("Changes.the.key.password.of.an.entry",
             ALIAS, KEYPASS, NEW, KEYSTORE, STOREPASS,
             STORETYPE, PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
@@ -784,6 +785,7 @@
                         command != IMPORTCERT &&
                         command != IMPORTPASS &&
                         command != IMPORTKEYSTORE &&
+                        command != INIT &&
                         command != PRINTCRL) {
                         throw new Exception(rb.getString
                                 ("Keystore.file.does.not.exist.") + ksfname);
@@ -1067,6 +1069,8 @@
         } else if (command == IMPORTKEYSTORE) {
             doImportKeyStore();
             kssave = true;
+        } else if (command == INIT) {
+            kssave = true;
         } else if (command == KEYCLONE) {
             keyPassNew = newPass;
 
diff --git a/src/java.base/share/classes/sun/security/tools/keytool/Resources.java b/src/java.base/share/classes/sun/security/tools/keytool/Resources.java
--- a/src/java.base/share/classes/sun/security/tools/keytool/Resources.java
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Resources.java
@@ -78,6 +78,8 @@
                 "Imports a password"}, //-importpass
         {"Imports.one.or.all.entries.from.another.keystore",
                 "Imports one or all entries from another keystore"}, //-importkeystore
+        {"Creates.an.initial.empty.keystore",
+                "Creates an initial empty keystore"}, //-init
         {"Clones.a.key.entry",
                 "Clones a key entry"}, //-keyclone
         {"Changes.the.key.password.of.an.entry",


More information about the jdk9-dev mailing list