summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com/netscape/cmstools/authority/AuthorityFindCLI.java
diff options
context:
space:
mode:
authorFraser Tweedale <ftweedal@redhat.com>2015-06-10 03:02:35 -0400
committerFraser Tweedale <ftweedal@redhat.com>2015-09-26 14:11:51 +1000
commit5cdad30b99d8c115f6b50c63bb2ecceefdd33937 (patch)
tree46525eeadf64a22b5b0070176716d08ce5df36b9 /base/java-tools/src/com/netscape/cmstools/authority/AuthorityFindCLI.java
parent2a9f56d02b4a284cda6f8b61b250e1494f19a83e (diff)
downloadpki-5cdad30b99d8c115f6b50c63bb2ecceefdd33937.tar.gz
pki-5cdad30b99d8c115f6b50c63bb2ecceefdd33937.tar.xz
pki-5cdad30b99d8c115f6b50c63bb2ecceefdd33937.zip
Lightweight CAs: add ca-authority CLI
Add CLI commands for creating, listing and showing lightweight CAs. Part of: https://fedorahosted.org/pki/ticket/1213
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/authority/AuthorityFindCLI.java')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/authority/AuthorityFindCLI.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/authority/AuthorityFindCLI.java b/base/java-tools/src/com/netscape/cmstools/authority/AuthorityFindCLI.java
new file mode 100644
index 000000000..c1aa99fc6
--- /dev/null
+++ b/base/java-tools/src/com/netscape/cmstools/authority/AuthorityFindCLI.java
@@ -0,0 +1,62 @@
+package com.netscape.cmstools.authority;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.ParseException;
+
+import com.netscape.certsrv.authority.AuthorityData;
+import com.netscape.cmstools.cli.CLI;
+import com.netscape.cmstools.cli.MainCLI;
+
+public class AuthorityFindCLI extends CLI {
+
+ public AuthorityCLI authorityCLI;
+
+ public AuthorityFindCLI(AuthorityCLI authorityCLI) {
+ super("find", "Find CAs", authorityCLI);
+ this.authorityCLI = authorityCLI;
+ }
+
+ public void printHelp() {
+ formatter.printHelp(getFullName(), options);
+ }
+
+ public void execute(String[] args) throws Exception {
+ // Always check for "--help" prior to parsing
+ if (Arrays.asList(args).contains("--help")) {
+ // Display usage
+ printHelp();
+ System.exit(0);
+ }
+
+ @SuppressWarnings("unused")
+ CommandLine cmd = null;
+
+ try {
+ cmd = parser.parse(options, args);
+ } catch (ParseException e) {
+ System.err.println("Error: " + e.getMessage());
+ printHelp();
+ System.exit(-1);
+ }
+
+ List<AuthorityData> datas = authorityCLI.authorityClient.listCAs();
+
+ MainCLI.printMessage(datas.size() + " entries matched");
+ if (datas.size() == 0) return;
+
+ boolean first = true;
+ for (AuthorityData data : datas) {
+ if (first)
+ first = false;
+ else
+ System.out.println();
+ AuthorityCLI.printAuthorityData(data);
+ }
+
+ MainCLI.printMessage("Number of entries returned " + datas.size());
+ }
+
+}