summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com/netscape
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2015-05-13 00:27:27 -0400
committerEndi S. Dewata <edewata@redhat.com>2015-05-14 11:12:34 -0400
commit8e350c3d765ab0ac1922dd814952fca9ff3f1e02 (patch)
tree5a634380a90baaa33cef10b654be47940288fdde /base/java-tools/src/com/netscape
parent7f5e5076d6e88d096b69b8269f638e8dd7e3ee63 (diff)
downloadpki-8e350c3d765ab0ac1922dd814952fca9ff3f1e02.tar.gz
pki-8e350c3d765ab0ac1922dd814952fca9ff3f1e02.tar.xz
pki-8e350c3d765ab0ac1922dd814952fca9ff3f1e02.zip
Added key-show option.
The key-show CLI has been modified to provide an option to find the active key info using the client key ID.
Diffstat (limited to 'base/java-tools/src/com/netscape')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java15
-rw-r--r--base/java-tools/src/com/netscape/cmstools/key/KeyShowCLI.java28
2 files changed, 30 insertions, 13 deletions
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 e9790b985..fb324be25 100644
--- a/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java
@@ -39,18 +39,21 @@ public class KeyCLI extends CLI {
public KeyCLI(CLI parent) {
super("key", "Key management commands", parent);
- addModule(new KeyFindCLI(this));
+ addModule(new KeyTemplateFindCLI(this));
+ addModule(new KeyTemplateShowCLI(this));
+
addModule(new KeyRequestFindCLI(this));
- addModule(new KeyShowCLI(this));
addModule(new KeyRequestShowCLI(this));
+ addModule(new KeyRequestReviewCLI(this));
+
+ addModule(new KeyFindCLI(this));
+ addModule(new KeyShowCLI(this));
addModule(new KeyModifyCLI(this));
- addModule(new KeyTemplateFindCLI(this));
- addModule(new KeyTemplateShowCLI(this));
+
+ addModule(new KeyGenerateCLI(this));
addModule(new KeyArchiveCLI(this));
addModule(new KeyRetrieveCLI(this));
- addModule(new KeyGenerateCLI(this));
addModule(new KeyRecoverCLI(this));
- addModule(new KeyRequestReviewCLI(this));
}
public String getFullName() {
diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyShowCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyShowCLI.java
index 4e1c50d1e..ebc5741b6 100644
--- a/base/java-tools/src/com/netscape/cmstools/key/KeyShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/key/KeyShowCLI.java
@@ -21,6 +21,7 @@ package com.netscape.cmstools.key;
import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
import org.apache.commons.cli.ParseException;
import com.netscape.certsrv.dbs.keydb.KeyId;
@@ -34,12 +35,20 @@ public class KeyShowCLI extends CLI {
public KeyShowCLI(KeyCLI keyCLI) {
super("show", "Get key", keyCLI);
this.keyCLI = keyCLI;
+
+ createOptions();
}
public void printHelp() {
formatter.printHelp(getFullName() + " <Key ID> [OPTIONS...]", options);
}
+ public void createOptions() {
+ Option option = new Option(null, "clientKeyID", true, "Unique client key identifier.");
+ option.setArgName("Client Key Identifier");
+ options.addOption(option);
+ }
+
public void execute(String[] args) {
// Always check for "--help" prior to parsing
if (Arrays.asList(args).contains("--help")) {
@@ -60,18 +69,23 @@ public class KeyShowCLI extends CLI {
}
String[] cmdArgs = cmd.getArgs();
+ String clientKeyId = cmd.getOptionValue("clientKeyID");
+ KeyInfo keyInfo;
+
+ if (cmdArgs.length == 1) {
+ KeyId keyId = new KeyId(cmdArgs[0]);
+ keyInfo = keyCLI.keyClient.getKeyInfo(keyId);
- if (cmdArgs.length != 1) {
- System.err.println("Error: No Key ID specified.");
+ } else if (clientKeyId != null) {
+ keyInfo = keyCLI.keyClient.getActiveKeyInfo(clientKeyId);
+
+ } else {
+ System.err.println("Error: Missing Key ID or Client Key ID.");
printHelp();
System.exit(-1);
+ return;
}
- KeyId keyId = new KeyId(args[0].trim());
-
- KeyInfo keyInfo = keyCLI.keyClient.getKeyInfo(keyId);
-
KeyCLI.printKeyInfo(keyInfo);
}
-
}