From a7f8076a5f20812eceac31f7230e4156adf74471 Mon Sep 17 00:00:00 2001 From: Abhishek Koneru Date: Mon, 25 Aug 2014 23:50:33 -0400 Subject: Fixes for tickets 1087, 1089, 1090, 1091. Addresses upstream issues in the pki key-* CLI commands. Updates the man page in all the required cases. --- base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java | 2 +- .../java-tools/src/com/netscape/cmstools/key/KeyFindCLI.java | 6 +++--- .../src/com/netscape/cmstools/key/KeyRecoverCLI.java | 9 +++++++-- .../src/com/netscape/cmstools/key/KeyTemplateFindCLI.java | 3 ++- .../src/com/netscape/cmstools/key/KeyTemplateShowCLI.java | 12 ++++++------ 5 files changed, 19 insertions(+), 13 deletions(-) (limited to 'base/java-tools/src/com/netscape') diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java index 82235d278..c6bb6933d 100644 --- a/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java @@ -88,7 +88,7 @@ public class KeyCLI extends CLI { public static void printKeyInfo(KeyInfo info) { System.out.println(" Key ID: "+info.getKeyId().toHexString()); - if (info.getClientKeyID() != null) System.out.println(" Client ID: "+info.getClientKeyID()); + if (info.getClientKeyID() != null) System.out.println(" Client Key ID: "+info.getClientKeyID()); if (info.getStatus() != null) System.out.println(" Status: "+info.getStatus()); if (info.getAlgorithm() != null) System.out.println(" Algorithm: "+info.getAlgorithm()); if (info.getSize() != null) System.out.println(" Size: "+info.getSize()); diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyFindCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyFindCLI.java index 73bad6b58..8ec7db4d9 100644 --- a/base/java-tools/src/com/netscape/cmstools/key/KeyFindCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/key/KeyFindCLI.java @@ -49,8 +49,8 @@ public class KeyFindCLI extends CLI { } public void createOptions() { - Option option = new Option(null, "client", true, "Client ID"); - option.setArgName("client ID"); + Option option = new Option(null, "clientKeyID", true, "Unique client key identifier"); + option.setArgName("client key ID"); options.addOption(option); option = new Option(null, "status", true, "Status"); @@ -101,7 +101,7 @@ public class KeyFindCLI extends CLI { System.exit(-1); } - String clientKeyID = cmd.getOptionValue("client"); + String clientKeyID = cmd.getOptionValue("clientKeyID"); String status = cmd.getOptionValue("status"); String s = cmd.getOptionValue("maxResults"); diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyRecoverCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyRecoverCLI.java index 5077330fa..b23577f53 100644 --- a/base/java-tools/src/com/netscape/cmstools/key/KeyRecoverCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/key/KeyRecoverCLI.java @@ -38,7 +38,7 @@ public class KeyRecoverCLI extends CLI { option.setArgName("Key Identifier"); options.addOption(option); - option = new Option(null, "input", true, "Location of the request template file."); + option = new Option(null, "input", true, "Location of the request file."); option.setArgName("Input file path"); options.addOption(option); } @@ -71,6 +71,7 @@ public class KeyRecoverCLI extends CLI { } String requestFile = cmd.getOptionValue("input"); + String keyID = cmd.getOptionValue("keyID"); KeyRequestResponse response = null; @@ -96,9 +97,13 @@ public class KeyRecoverCLI extends CLI { System.exit(-1); } - } else { + } else if (keyID != null) { String keyId = cmd.getOptionValue("keyID"); response = keyCLI.keyClient.recoverKey(new KeyId(keyId), null, null, null, null); + } else { + System.err.println("Error: Neither a key ID nor a request file's path is specified."); + printHelp(); + System.exit(-1); } MainCLI.printMessage("Key Recovery Request Information"); diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateFindCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateFindCLI.java index 0e76d4f1d..3303560a6 100644 --- a/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateFindCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateFindCLI.java @@ -65,11 +65,12 @@ public class KeyTemplateFindCLI extends CLI { e.printStackTrace(); System.exit(-1); } - MainCLI.printMessage("List of templates"); + MainCLI.printMessage(templates.size() + " entries matched"); for (KeyTemplate template : templates) { template.printTemplateInfo(); } System.out.println(); + MainCLI.printMessage("Number of entries returned " + templates.size()); } public void createTemplateList() throws FileNotFoundException, JAXBException { diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateShowCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateShowCLI.java index 77d0680b4..30a40390a 100644 --- a/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateShowCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateShowCLI.java @@ -31,8 +31,8 @@ public class KeyTemplateShowCLI extends CLI { } public void createOptions() { - Option option = new Option(null, "output-file", true, "Location where the template has to be stored."); - option.setArgName("File to write the template to."); + Option option = new Option(null, "output", true, "Location to store the template."); + option.setArgName("output file"); options.addOption(option); } @@ -63,7 +63,7 @@ public class KeyTemplateShowCLI extends CLI { } String templateId = cmdArgs[0]; - String writeToFile = cmd.getOptionValue("output-file"); + String writeToFile = cmd.getOptionValue("output"); String templateDir = "/usr/share/pki/key/templates/"; String templatePath = templateDir + templateId + ".xml"; ResourceMessage data = null; @@ -71,10 +71,10 @@ public class KeyTemplateShowCLI extends CLI { data = ResourceMessage.unmarshall(KeyArchivalRequest.class, templatePath); } catch (FileNotFoundException | JAXBException e2) { System.err.println("Error: " + e2.getMessage()); - if(verbose) - e2.printStackTrace(); + if (verbose) + e2.printStackTrace(); System.exit(-1); - }; + } if (writeToFile != null) { try (FileOutputStream fOS = new FileOutputStream(writeToFile)) { -- cgit