|
|
f332ec |
From 7efc9fbd120885109eb19bfc98d6109a98751b25 Mon Sep 17 00:00:00 2001
|
|
|
f332ec |
From: "Endi S. Dewata" <edewata@redhat.com>
|
|
|
f332ec |
Date: Tue, 29 Oct 2013 10:56:15 -0400
|
|
|
f332ec |
Subject: [PATCH 5/6] Added CLI command aliases.
|
|
|
f332ec |
|
|
|
f332ec |
New aliases for some CLI commands have been added for consistency:
|
|
|
f332ec |
|
|
|
f332ec |
* client-cert-find -> client-find-cert
|
|
|
f332ec |
* client-cert-import -> client-import-cert
|
|
|
f332ec |
* client-cert-del -> client-remove-cert
|
|
|
f332ec |
* group-member-add -> group-add-member
|
|
|
f332ec |
* group-member-find -> group-find-member
|
|
|
f332ec |
* group-member-show -> group-show-member
|
|
|
f332ec |
* group-member-del -> group-remove-member
|
|
|
f332ec |
* user-cert-add -> user-add-cert
|
|
|
f332ec |
* user-cert-find -> user-find-cert
|
|
|
f332ec |
* user-cert-show -> user-show-cert
|
|
|
f332ec |
* user-cert-del -> user-remove-cert
|
|
|
f332ec |
* user-membership-add -> user-add-membership
|
|
|
f332ec |
* user-membership-find -> user-find-membership
|
|
|
f332ec |
* user-membership-show -> user-show-membership
|
|
|
f332ec |
* user-membership-del -> user-remove-membership
|
|
|
f332ec |
|
|
|
f332ec |
The original commands will continue to work as before.
|
|
|
f332ec |
---
|
|
|
f332ec |
base/java-tools/man/man1/pki.1 | 4 +-
|
|
|
f332ec |
.../src/com/netscape/cmstools/cli/CLI.java | 55 +++++++++
|
|
|
f332ec |
.../com/netscape/cmstools/client/ClientCLI.java | 24 +---
|
|
|
f332ec |
.../cmstools/client/ClientCertFindCLI.java | 89 +++++++++++++++
|
|
|
f332ec |
.../cmstools/client/ClientCertImportCLI.java | 124 +++++++++++++++++++++
|
|
|
f332ec |
.../cmstools/client/ClientCertRemoveCLI.java | 70 ++++++++++++
|
|
|
f332ec |
.../cmstools/client/ClientFindCertCLI.java | 60 +---------
|
|
|
f332ec |
.../cmstools/client/ClientImportCertCLI.java | 95 +---------------
|
|
|
f332ec |
.../cmstools/client/ClientRemoveCertCLI.java | 41 +------
|
|
|
f332ec |
.../netscape/cmstools/group/GroupAddMemberCLI.java | 32 +-----
|
|
|
f332ec |
.../src/com/netscape/cmstools/group/GroupCLI.java | 23 +---
|
|
|
f332ec |
.../cmstools/group/GroupFindMemberCLI.java | 79 +------------
|
|
|
f332ec |
.../netscape/cmstools/group/GroupMemberAddCLI.java | 61 ++++++++++
|
|
|
f332ec |
.../cmstools/group/GroupMemberFindCLI.java | 108 ++++++++++++++++++
|
|
|
f332ec |
.../cmstools/group/GroupMemberRemoveCLI.java | 58 ++++++++++
|
|
|
f332ec |
.../cmstools/group/GroupMemberShowCLI.java | 61 ++++++++++
|
|
|
f332ec |
.../cmstools/group/GroupRemoveMemberCLI.java | 29 +----
|
|
|
f332ec |
.../cmstools/group/GroupShowMemberCLI.java | 32 +-----
|
|
|
f332ec |
.../com/netscape/cmstools/user/UserAddCertCLI.java | 72 +-----------
|
|
|
f332ec |
.../cmstools/user/UserAddMembershipCLI.java | 32 +-----
|
|
|
f332ec |
.../src/com/netscape/cmstools/user/UserCLI.java | 28 ++---
|
|
|
f332ec |
.../com/netscape/cmstools/user/UserCertAddCLI.java | 105 +++++++++++++++++
|
|
|
f332ec |
.../netscape/cmstools/user/UserCertFindCLI.java | 108 ++++++++++++++++++
|
|
|
f332ec |
.../netscape/cmstools/user/UserCertRemoveCLI.java | 65 +++++++++++
|
|
|
f332ec |
.../netscape/cmstools/user/UserCertShowCLI.java | 100 +++++++++++++++++
|
|
|
f332ec |
.../netscape/cmstools/user/UserFindCertCLI.java | 79 +------------
|
|
|
f332ec |
.../cmstools/user/UserFindMembershipCLI.java | 79 +------------
|
|
|
f332ec |
.../cmstools/user/UserMembershipAddCLI.java | 61 ++++++++++
|
|
|
f332ec |
.../cmstools/user/UserMembershipFindCLI.java | 108 ++++++++++++++++++
|
|
|
f332ec |
.../cmstools/user/UserMembershipRemoveCLI.java | 58 ++++++++++
|
|
|
f332ec |
.../netscape/cmstools/user/UserRemoveCertCLI.java | 35 +-----
|
|
|
f332ec |
.../cmstools/user/UserRemoveMembershipCLI.java | 29 +----
|
|
|
f332ec |
.../netscape/cmstools/user/UserShowCertCLI.java | 71 +-----------
|
|
|
f332ec |
33 files changed, 1290 insertions(+), 785 deletions(-)
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/client/ClientCertFindCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/client/ClientCertRemoveCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/group/GroupMemberAddCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/group/GroupMemberRemoveCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/group/GroupMemberShowCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/user/UserCertAddCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/user/UserCertRemoveCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/user/UserCertShowCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/user/UserMembershipAddCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java
|
|
|
f332ec |
create mode 100644 base/java-tools/src/com/netscape/cmstools/user/UserMembershipRemoveCLI.java
|
|
|
f332ec |
|
|
|
f332ec |
diff --git a/base/java-tools/man/man1/pki.1 b/base/java-tools/man/man1/pki.1
|
|
|
f332ec |
index ec0af7c..b3c5356 100644
|
|
|
f332ec |
--- a/base/java-tools/man/man1/pki.1
|
|
|
f332ec |
+++ b/base/java-tools/man/man1/pki.1
|
|
|
f332ec |
@@ -199,11 +199,11 @@ To delete a group:
|
|
|
f332ec |
|
|
|
f332ec |
To add a user to a group:
|
|
|
f332ec |
|
|
|
f332ec |
-.B pki <admin authentication> group-add-member <group ID> <Member ID>
|
|
|
f332ec |
+.B pki <admin authentication> group-member-add <group ID> <Member ID>
|
|
|
f332ec |
|
|
|
f332ec |
To delete a user from a group:
|
|
|
f332ec |
|
|
|
f332ec |
-.B pki <admin authentication> group-remove-member <group ID> <Member ID>
|
|
|
f332ec |
+.B pki <admin authentication> group-member-del <group ID> <Member ID>
|
|
|
f332ec |
|
|
|
f332ec |
.\".SS Key Management Commands
|
|
|
f332ec |
.\"\fBpki\fP can be used with a KRA to find specific keys and key requests. This will be documented in more detail at a later time.
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/cli/CLI.java b/base/java-tools/src/com/netscape/cmstools/cli/CLI.java
|
|
|
f332ec |
index a1fc4f7..c9c3606 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/cli/CLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/cli/CLI.java
|
|
|
f332ec |
@@ -18,6 +18,8 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.cli;
|
|
|
f332ec |
|
|
|
f332ec |
+import java.util.ArrayList;
|
|
|
f332ec |
+import java.util.Collection;
|
|
|
f332ec |
import java.util.LinkedHashMap;
|
|
|
f332ec |
import java.util.Map;
|
|
|
f332ec |
|
|
|
f332ec |
@@ -25,6 +27,7 @@ import org.apache.commons.cli.CommandLineParser;
|
|
|
f332ec |
import org.apache.commons.cli.HelpFormatter;
|
|
|
f332ec |
import org.apache.commons.cli.Options;
|
|
|
f332ec |
import org.apache.commons.cli.PosixParser;
|
|
|
f332ec |
+import org.apache.commons.lang.StringUtils;
|
|
|
f332ec |
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
@@ -64,6 +67,10 @@ public class CLI {
|
|
|
f332ec |
this.description = description;
|
|
|
f332ec |
}
|
|
|
f332ec |
|
|
|
f332ec |
+ public boolean isDeprecated() {
|
|
|
f332ec |
+ return getClass().getAnnotation(Deprecated.class) != null;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
public void addModule(CLI module) {
|
|
|
f332ec |
modules.put(module.getName(), module);
|
|
|
f332ec |
}
|
|
|
f332ec |
@@ -75,7 +82,55 @@ public class CLI {
|
|
|
f332ec |
public void execute(String[] args) throws Exception {
|
|
|
f332ec |
}
|
|
|
f332ec |
|
|
|
f332ec |
+ public Collection<CLI> getDeprecatedModules() {
|
|
|
f332ec |
+ Collection<CLI> list = new ArrayList<CLI>();
|
|
|
f332ec |
+ for (CLI module : modules.values()) {
|
|
|
f332ec |
+ if (!module.isDeprecated()) continue;
|
|
|
f332ec |
+ list.add(module);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+ return list;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
public void printHelp() {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ int leftPadding = 1;
|
|
|
f332ec |
+ int rightPadding = 25;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ System.out.println("Commands:");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ for (CLI module : modules.values()) {
|
|
|
f332ec |
+ if (module.isDeprecated()) continue;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String label = name + "-" + module.getName();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ int padding = rightPadding - leftPadding - label.length();
|
|
|
f332ec |
+ if (padding < 1)
|
|
|
f332ec |
+ padding = 1;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ System.out.print(StringUtils.repeat(" ", leftPadding));
|
|
|
f332ec |
+ System.out.print(label);
|
|
|
f332ec |
+ System.out.print(StringUtils.repeat(" ", padding));
|
|
|
f332ec |
+ System.out.println(module.getDescription());
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ Collection<CLI> deprecatedModules = getDeprecatedModules();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (!deprecatedModules.isEmpty()) {
|
|
|
f332ec |
+ System.out.println();
|
|
|
f332ec |
+ System.out.println("Deprecated:");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ for (CLI module : deprecatedModules) {
|
|
|
f332ec |
+ String label = name+"-"+module.getName();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ int padding = rightPadding - leftPadding - label.length();
|
|
|
f332ec |
+ if (padding < 1) padding = 1;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ System.out.print(StringUtils.repeat(" ", leftPadding));
|
|
|
f332ec |
+ System.out.print(label);
|
|
|
f332ec |
+ System.out.print(StringUtils.repeat(" ", padding));
|
|
|
f332ec |
+ System.out.println(module.getDescription());
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+ }
|
|
|
f332ec |
}
|
|
|
f332ec |
|
|
|
f332ec |
public static boolean isVerbose() {
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java
|
|
|
f332ec |
index 34d09f3..147b4d6 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java
|
|
|
f332ec |
@@ -20,7 +20,6 @@ package com.netscape.cmstools.client;
|
|
|
f332ec |
|
|
|
f332ec |
import java.util.Arrays;
|
|
|
f332ec |
|
|
|
f332ec |
-import org.apache.commons.lang.StringUtils;
|
|
|
f332ec |
import org.mozilla.jss.crypto.X509Certificate;
|
|
|
f332ec |
|
|
|
f332ec |
import com.netscape.certsrv.dbs.certdb.CertId;
|
|
|
f332ec |
@@ -41,27 +40,10 @@ public class ClientCLI extends CLI {
|
|
|
f332ec |
addModule(new ClientFindCertCLI(this));
|
|
|
f332ec |
addModule(new ClientImportCertCLI(this));
|
|
|
f332ec |
addModule(new ClientRemoveCertCLI(this));
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
-
|
|
|
f332ec |
- System.out.println("Commands:");
|
|
|
f332ec |
-
|
|
|
f332ec |
- int leftPadding = 1;
|
|
|
f332ec |
- int rightPadding = 25;
|
|
|
f332ec |
|
|
|
f332ec |
- for (CLI module : modules.values()) {
|
|
|
f332ec |
- String label = name + "-" + module.getName();
|
|
|
f332ec |
-
|
|
|
f332ec |
- int padding = rightPadding - leftPadding - label.length();
|
|
|
f332ec |
- if (padding < 1)
|
|
|
f332ec |
- padding = 1;
|
|
|
f332ec |
-
|
|
|
f332ec |
- System.out.print(StringUtils.repeat(" ", leftPadding));
|
|
|
f332ec |
- System.out.print(label);
|
|
|
f332ec |
- System.out.print(StringUtils.repeat(" ", padding));
|
|
|
f332ec |
- System.out.println(module.getDescription());
|
|
|
f332ec |
- }
|
|
|
f332ec |
+ addModule(new ClientCertFindCLI(this));
|
|
|
f332ec |
+ addModule(new ClientCertImportCLI(this));
|
|
|
f332ec |
+ addModule(new ClientCertRemoveCLI(this));
|
|
|
f332ec |
}
|
|
|
f332ec |
|
|
|
f332ec |
public void execute(String[] args) throws Exception {
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientCertFindCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCertFindCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..c4e1aca
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCertFindCLI.java
|
|
|
f332ec |
@@ -0,0 +1,89 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2013 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.client;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
+import org.mozilla.jss.crypto.X509Certificate;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class ClientCertFindCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public ClientCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public ClientCertFindCLI(String name, ClientCLI parent) {
|
|
|
f332ec |
+ super(name, "Find certificates in client security database");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public ClientCertFindCLI(ClientCLI parent) {
|
|
|
f332ec |
+ this("cert-find", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " [OPTIONS]", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ options.addOption(null, "ca", false, "Find CA certificates only");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ CommandLine cmd = null;
|
|
|
f332ec |
+ try {
|
|
|
f332ec |
+ cmd = parser.parse(options, args);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } catch (Exception e) {
|
|
|
f332ec |
+ System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ X509Certificate[] certs;
|
|
|
f332ec |
+ if (cmd.hasOption("ca")) {
|
|
|
f332ec |
+ certs = parent.parent.client.getCACerts();
|
|
|
f332ec |
+ } else {
|
|
|
f332ec |
+ certs = parent.parent.client.getCerts();
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (certs == null || certs.length == 0) {
|
|
|
f332ec |
+ MainCLI.printMessage("No certificates found");
|
|
|
f332ec |
+ System.exit(0); // valid result
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage(certs.length + " certificate(s) found");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ boolean first = true;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ for (X509Certificate cert : certs) {
|
|
|
f332ec |
+ if (first) {
|
|
|
f332ec |
+ first = false;
|
|
|
f332ec |
+ } else {
|
|
|
f332ec |
+ System.out.println();
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ ClientCLI.printCertInfo(cert);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Number of entries returned " + certs.length);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..ffd68d9
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
|
|
|
f332ec |
@@ -0,0 +1,124 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2013 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.client;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import java.io.File;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
+import org.apache.commons.cli.Option;
|
|
|
f332ec |
+import org.apache.commons.io.FileUtils;
|
|
|
f332ec |
+import org.mozilla.jss.crypto.X509Certificate;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.certsrv.client.ClientConfig;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class ClientCertImportCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public ClientCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public ClientCertImportCLI(String name, ClientCLI parent) {
|
|
|
f332ec |
+ super(name, "Import certificate into client security database");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public ClientCertImportCLI(ClientCLI parent) {
|
|
|
f332ec |
+ this("cert-import", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " [OPTIONS]", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ Option option = new Option(null, "cert", true, "Import certificate file");
|
|
|
f332ec |
+ option.setArgName("path");
|
|
|
f332ec |
+ options.addOption(option);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ option = new Option(null, "ca-cert", true, "Import CA certificate file");
|
|
|
f332ec |
+ option.setArgName("path");
|
|
|
f332ec |
+ options.addOption(option);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ options.addOption(null, "ca-server", false, "Import CA certificate from CA server");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ CommandLine cmd = null;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ try {
|
|
|
f332ec |
+ cmd = parser.parse(options, args);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } catch (Exception e) {
|
|
|
f332ec |
+ System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ byte[] bytes = null;
|
|
|
f332ec |
+ X509Certificate cert = null;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String certPath = cmd.getOptionValue("cert");
|
|
|
f332ec |
+ String caCertPath = cmd.getOptionValue("ca-cert");
|
|
|
f332ec |
+ boolean importFromCAServer = cmd.hasOption("ca-server");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ boolean isCACert = false;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ // load the certificate
|
|
|
f332ec |
+ if (certPath != null) {
|
|
|
f332ec |
+ if (verbose) System.out.println("Loading certificate from " + certPath + ".");
|
|
|
f332ec |
+ bytes = FileUtils.readFileToByteArray(new File(certPath));
|
|
|
f332ec |
+
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } else if (caCertPath != null) {
|
|
|
f332ec |
+ if (verbose) System.out.println("Loading CA certificate from " + caCertPath + ".");
|
|
|
f332ec |
+ bytes = FileUtils.readFileToByteArray(new File(caCertPath));
|
|
|
f332ec |
+
|
|
|
f332ec |
+ isCACert = true;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } else if (importFromCAServer) {
|
|
|
f332ec |
+ ClientConfig config = parent.parent.config;
|
|
|
f332ec |
+ String caServerURI = "http://" + config.getServerURI().getHost() + ":8080/ca";
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (verbose) System.out.println("Downloading CA certificate from " + caServerURI + ".");
|
|
|
f332ec |
+ bytes = parent.parent.client.downloadCACertChain(caServerURI);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ isCACert = true;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } else {
|
|
|
f332ec |
+ System.err.println("Error: Missing certificate to import");
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ // import the certificate
|
|
|
f332ec |
+ if (isCACert) {
|
|
|
f332ec |
+ if (verbose) System.out.println("Importing CA certificate.");
|
|
|
f332ec |
+ cert = parent.parent.client.importCACertPackage(bytes);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } else {
|
|
|
f332ec |
+ if (verbose) System.out.println("Importing certificate.");
|
|
|
f332ec |
+ cert = parent.parent.client.importCertPackage(bytes, parent.parent.client.config.getCertNickname());
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Imported certificate \"" + cert.getNickname() + "\"");
|
|
|
f332ec |
+ ClientCLI.printCertInfo(cert);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientCertRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCertRemoveCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..2c05446
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCertRemoveCLI.java
|
|
|
f332ec |
@@ -0,0 +1,70 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2013 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.client;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class ClientCertRemoveCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public ClientCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public ClientCertRemoveCLI(String name, ClientCLI parent) {
|
|
|
f332ec |
+ super(name, "Remove certificate from client security database");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public ClientCertRemoveCLI(ClientCLI parent) {
|
|
|
f332ec |
+ this("cert-del", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <nickname>", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ CommandLine cmd = null;
|
|
|
f332ec |
+ try {
|
|
|
f332ec |
+ cmd = parser.parse(options, args);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } catch (Exception e) {
|
|
|
f332ec |
+ System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (cmdArgs.length != 1) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String nickname = cmdArgs[0];
|
|
|
f332ec |
+ parent.parent.client.removeCert(nickname);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Removed certificate \"" + nickname + "\"");
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java
|
|
|
f332ec |
index 80690b7..379e95a 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java
|
|
|
f332ec |
@@ -18,68 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.client;
|
|
|
f332ec |
|
|
|
f332ec |
-import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
-import org.mozilla.jss.crypto.X509Certificate;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class ClientFindCertCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public ClientCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class ClientFindCertCLI extends ClientCertFindCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public ClientFindCertCLI(ClientCLI parent) {
|
|
|
f332ec |
- super("find-cert", "Find certificates in client security database");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " [OPTIONS]", options);
|
|
|
f332ec |
+ super("find-cert", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- options.addOption(null, "ca", false, "Find CA certificates only");
|
|
|
f332ec |
-
|
|
|
f332ec |
- CommandLine cmd = null;
|
|
|
f332ec |
- try {
|
|
|
f332ec |
- cmd = parser.parse(options, args);
|
|
|
f332ec |
-
|
|
|
f332ec |
- } catch (Exception e) {
|
|
|
f332ec |
- System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- X509Certificate[] certs;
|
|
|
f332ec |
- if (cmd.hasOption("ca")) {
|
|
|
f332ec |
- certs = parent.parent.client.getCACerts();
|
|
|
f332ec |
- } else {
|
|
|
f332ec |
- certs = parent.parent.client.getCerts();
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (certs == null || certs.length == 0) {
|
|
|
f332ec |
- MainCLI.printMessage("No certificates found");
|
|
|
f332ec |
- System.exit(0); // valid result
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage(certs.length + " certificate(s) found");
|
|
|
f332ec |
-
|
|
|
f332ec |
- boolean first = true;
|
|
|
f332ec |
-
|
|
|
f332ec |
- for (X509Certificate cert : certs) {
|
|
|
f332ec |
- if (first) {
|
|
|
f332ec |
- first = false;
|
|
|
f332ec |
- } else {
|
|
|
f332ec |
- System.out.println();
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- ClientCLI.printCertInfo(cert);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Number of entries returned " + certs.length);
|
|
|
f332ec |
- }
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java
|
|
|
f332ec |
index e89f954..db0736d 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java
|
|
|
f332ec |
@@ -18,103 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.client;
|
|
|
f332ec |
|
|
|
f332ec |
-import java.io.File;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
-import org.apache.commons.cli.Option;
|
|
|
f332ec |
-import org.apache.commons.io.FileUtils;
|
|
|
f332ec |
-import org.mozilla.jss.crypto.X509Certificate;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import com.netscape.certsrv.client.ClientConfig;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class ClientImportCertCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public ClientCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class ClientImportCertCLI extends ClientCertImportCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public ClientImportCertCLI(ClientCLI parent) {
|
|
|
f332ec |
- super("import-cert", "Import certificate into client security database");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " [OPTIONS]", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- Option option = new Option(null, "cert", true, "Import certificate file");
|
|
|
f332ec |
- option.setArgName("path");
|
|
|
f332ec |
- options.addOption(option);
|
|
|
f332ec |
-
|
|
|
f332ec |
- option = new Option(null, "ca-cert", true, "Import CA certificate file");
|
|
|
f332ec |
- option.setArgName("path");
|
|
|
f332ec |
- options.addOption(option);
|
|
|
f332ec |
-
|
|
|
f332ec |
- options.addOption(null, "ca-server", false, "Import CA certificate from CA server");
|
|
|
f332ec |
-
|
|
|
f332ec |
- CommandLine cmd = null;
|
|
|
f332ec |
-
|
|
|
f332ec |
- try {
|
|
|
f332ec |
- cmd = parser.parse(options, args);
|
|
|
f332ec |
-
|
|
|
f332ec |
- } catch (Exception e) {
|
|
|
f332ec |
- System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- byte[] bytes = null;
|
|
|
f332ec |
- X509Certificate cert = null;
|
|
|
f332ec |
-
|
|
|
f332ec |
- String certPath = cmd.getOptionValue("cert");
|
|
|
f332ec |
- String caCertPath = cmd.getOptionValue("ca-cert");
|
|
|
f332ec |
- boolean importFromCAServer = cmd.hasOption("ca-server");
|
|
|
f332ec |
-
|
|
|
f332ec |
- boolean isCACert = false;
|
|
|
f332ec |
-
|
|
|
f332ec |
- // load the certificate
|
|
|
f332ec |
- if (certPath != null) {
|
|
|
f332ec |
- if (verbose) System.out.println("Loading certificate from " + certPath + ".");
|
|
|
f332ec |
- bytes = FileUtils.readFileToByteArray(new File(certPath));
|
|
|
f332ec |
-
|
|
|
f332ec |
-
|
|
|
f332ec |
- } else if (caCertPath != null) {
|
|
|
f332ec |
- if (verbose) System.out.println("Loading CA certificate from " + caCertPath + ".");
|
|
|
f332ec |
- bytes = FileUtils.readFileToByteArray(new File(caCertPath));
|
|
|
f332ec |
-
|
|
|
f332ec |
- isCACert = true;
|
|
|
f332ec |
-
|
|
|
f332ec |
- } else if (importFromCAServer) {
|
|
|
f332ec |
- ClientConfig config = parent.parent.config;
|
|
|
f332ec |
- String caServerURI = "http://" + config.getServerURI().getHost() + ":8080/ca";
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (verbose) System.out.println("Downloading CA certificate from " + caServerURI + ".");
|
|
|
f332ec |
- bytes = parent.parent.client.downloadCACertChain(caServerURI);
|
|
|
f332ec |
-
|
|
|
f332ec |
- isCACert = true;
|
|
|
f332ec |
-
|
|
|
f332ec |
- } else {
|
|
|
f332ec |
- System.err.println("Error: Missing certificate to import");
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- // import the certificate
|
|
|
f332ec |
- if (isCACert) {
|
|
|
f332ec |
- if (verbose) System.out.println("Importing CA certificate.");
|
|
|
f332ec |
- cert = parent.parent.client.importCACertPackage(bytes);
|
|
|
f332ec |
-
|
|
|
f332ec |
- } else {
|
|
|
f332ec |
- if (verbose) System.out.println("Importing certificate.");
|
|
|
f332ec |
- cert = parent.parent.client.importCertPackage(bytes, parent.parent.client.config.getCertNickname());
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Imported certificate \"" + cert.getNickname() + "\"");
|
|
|
f332ec |
- ClientCLI.printCertInfo(cert);
|
|
|
f332ec |
+ super("import-cert", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java
|
|
|
f332ec |
index fab4296..2b217ac 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java
|
|
|
f332ec |
@@ -18,49 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.client;
|
|
|
f332ec |
|
|
|
f332ec |
-import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class ClientRemoveCertCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public ClientCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class ClientRemoveCertCLI extends ClientCertRemoveCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public ClientRemoveCertCLI(ClientCLI parent) {
|
|
|
f332ec |
- super("remove-cert", "Remove certificate from client security database");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <nickname>", options);
|
|
|
f332ec |
+ super("remove-cert", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- CommandLine cmd = null;
|
|
|
f332ec |
- try {
|
|
|
f332ec |
- cmd = parser.parse(options, args);
|
|
|
f332ec |
-
|
|
|
f332ec |
- } catch (Exception e) {
|
|
|
f332ec |
- System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (cmdArgs.length != 1) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String nickname = cmdArgs[0];
|
|
|
f332ec |
- parent.parent.client.removeCert(nickname);
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Removed certificate \"" + nickname + "\"");
|
|
|
f332ec |
- }
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java
|
|
|
f332ec |
index 36d3c06..a761853 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java
|
|
|
f332ec |
@@ -18,40 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.group;
|
|
|
f332ec |
|
|
|
f332ec |
-import com.netscape.certsrv.group.GroupMemberData;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class GroupAddMemberCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public GroupCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class GroupAddMemberCLI extends GroupMemberAddCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public GroupAddMemberCLI(GroupCLI parent) {
|
|
|
f332ec |
- super("add-member", "Add group member");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (args.length != 2) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String groupID = args[0];
|
|
|
f332ec |
- String memberID = args[1];
|
|
|
f332ec |
-
|
|
|
f332ec |
- GroupMemberData groupMemberData = parent.client.addGroupMember(groupID, memberID);
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Added group member \""+memberID+"\"");
|
|
|
f332ec |
-
|
|
|
f332ec |
- GroupCLI.printGroupMember(groupMemberData);
|
|
|
f332ec |
+ super("add-member", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
|
|
|
f332ec |
index bd8cec7..bc4d573 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
|
|
|
f332ec |
@@ -51,26 +51,11 @@ public class GroupCLI extends CLI {
|
|
|
f332ec |
addModule(new GroupShowMemberCLI(this));
|
|
|
f332ec |
addModule(new GroupAddMemberCLI(this));
|
|
|
f332ec |
addModule(new GroupRemoveMemberCLI(this));
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
-
|
|
|
f332ec |
- System.out.println("Commands:");
|
|
|
f332ec |
-
|
|
|
f332ec |
- int leftPadding = 1;
|
|
|
f332ec |
- int rightPadding = 25;
|
|
|
f332ec |
|
|
|
f332ec |
- for (CLI module : modules.values()) {
|
|
|
f332ec |
- String label = name+"-"+module.getName();
|
|
|
f332ec |
-
|
|
|
f332ec |
- int padding = rightPadding - leftPadding - label.length();
|
|
|
f332ec |
- if (padding < 1) padding = 1;
|
|
|
f332ec |
-
|
|
|
f332ec |
- System.out.print(StringUtils.repeat(" ", leftPadding));
|
|
|
f332ec |
- System.out.print(label);
|
|
|
f332ec |
- System.out.print(StringUtils.repeat(" ", padding));
|
|
|
f332ec |
- System.out.println(module.getDescription());
|
|
|
f332ec |
- }
|
|
|
f332ec |
+ addModule(new GroupMemberFindCLI(this));
|
|
|
f332ec |
+ addModule(new GroupMemberShowCLI(this));
|
|
|
f332ec |
+ addModule(new GroupMemberAddCLI(this));
|
|
|
f332ec |
+ addModule(new GroupMemberRemoveCLI(this));
|
|
|
f332ec |
}
|
|
|
f332ec |
|
|
|
f332ec |
public void execute(String[] args) throws Exception {
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java
|
|
|
f332ec |
index f0498f0..4850910 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java
|
|
|
f332ec |
@@ -18,87 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.group;
|
|
|
f332ec |
|
|
|
f332ec |
-import java.util.Collection;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
-import org.apache.commons.cli.Option;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import com.netscape.certsrv.group.GroupMemberCollection;
|
|
|
f332ec |
-import com.netscape.certsrv.group.GroupMemberData;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class GroupFindMemberCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public GroupCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class GroupFindMemberCLI extends GroupMemberFindCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public GroupFindMemberCLI(GroupCLI parent) {
|
|
|
f332ec |
- super("find-member", "Find group members");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <Group ID> [OPTIONS...]", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- Option option = new Option(null, "start", true, "Page start");
|
|
|
f332ec |
- option.setArgName("start");
|
|
|
f332ec |
- options.addOption(option);
|
|
|
f332ec |
-
|
|
|
f332ec |
- option = new Option(null, "size", true, "Page size");
|
|
|
f332ec |
- option.setArgName("size");
|
|
|
f332ec |
- options.addOption(option);
|
|
|
f332ec |
-
|
|
|
f332ec |
- CommandLine cmd = null;
|
|
|
f332ec |
-
|
|
|
f332ec |
- try {
|
|
|
f332ec |
- cmd = parser.parse(options, args);
|
|
|
f332ec |
-
|
|
|
f332ec |
- } catch (Exception e) {
|
|
|
f332ec |
- System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (cmdArgs.length != 1) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String groupID = cmdArgs[0];
|
|
|
f332ec |
-
|
|
|
f332ec |
- String s = cmd.getOptionValue("start");
|
|
|
f332ec |
- Integer start = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
-
|
|
|
f332ec |
- s = cmd.getOptionValue("size");
|
|
|
f332ec |
- Integer size = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
-
|
|
|
f332ec |
- GroupMemberCollection response = parent.client.findGroupMembers(groupID, start, size);
|
|
|
f332ec |
-
|
|
|
f332ec |
- Collection<GroupMemberData> entries = response.getMembers();
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage(entries.size()+" group member(s) matched");
|
|
|
f332ec |
-
|
|
|
f332ec |
- boolean first = true;
|
|
|
f332ec |
-
|
|
|
f332ec |
- for (GroupMemberData groupMemberData : entries) {
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (first) {
|
|
|
f332ec |
- first = false;
|
|
|
f332ec |
- } else {
|
|
|
f332ec |
- System.out.println();
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- GroupCLI.printGroupMember(groupMemberData);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Number of entries returned "+entries.size());
|
|
|
f332ec |
+ super("find-member", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupMemberAddCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberAddCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..5945e21
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberAddCLI.java
|
|
|
f332ec |
@@ -0,0 +1,61 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2012 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.group;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.certsrv.group.GroupMemberData;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class GroupMemberAddCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupMemberAddCLI(String name, GroupCLI parent) {
|
|
|
f332ec |
+ super(name, "Add group member");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupMemberAddCLI(GroupCLI parent) {
|
|
|
f332ec |
+ this("member-add", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (args.length != 2) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String groupID = args[0];
|
|
|
f332ec |
+ String memberID = args[1];
|
|
|
f332ec |
+
|
|
|
f332ec |
+ GroupMemberData groupMemberData = parent.client.addGroupMember(groupID, memberID);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Added group member \""+memberID+"\"");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ GroupCLI.printGroupMember(groupMemberData);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..c36d041
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java
|
|
|
f332ec |
@@ -0,0 +1,108 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2012 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.group;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import java.util.Collection;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
+import org.apache.commons.cli.Option;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.certsrv.group.GroupMemberCollection;
|
|
|
f332ec |
+import com.netscape.certsrv.group.GroupMemberData;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class GroupMemberFindCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupMemberFindCLI(String name, GroupCLI parent) {
|
|
|
f332ec |
+ super(name, "Find group members");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupMemberFindCLI(GroupCLI parent) {
|
|
|
f332ec |
+ this("member-find", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <Group ID> [OPTIONS...]", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ Option option = new Option(null, "start", true, "Page start");
|
|
|
f332ec |
+ option.setArgName("start");
|
|
|
f332ec |
+ options.addOption(option);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ option = new Option(null, "size", true, "Page size");
|
|
|
f332ec |
+ option.setArgName("size");
|
|
|
f332ec |
+ options.addOption(option);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ CommandLine cmd = null;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ try {
|
|
|
f332ec |
+ cmd = parser.parse(options, args);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } catch (Exception e) {
|
|
|
f332ec |
+ System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (cmdArgs.length != 1) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String groupID = cmdArgs[0];
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String s = cmd.getOptionValue("start");
|
|
|
f332ec |
+ Integer start = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ s = cmd.getOptionValue("size");
|
|
|
f332ec |
+ Integer size = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ GroupMemberCollection response = parent.client.findGroupMembers(groupID, start, size);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ Collection<GroupMemberData> entries = response.getMembers();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage(entries.size()+" group member(s) matched");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ boolean first = true;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ for (GroupMemberData groupMemberData : entries) {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (first) {
|
|
|
f332ec |
+ first = false;
|
|
|
f332ec |
+ } else {
|
|
|
f332ec |
+ System.out.println();
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ GroupCLI.printGroupMember(groupMemberData);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Number of entries returned "+entries.size());
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupMemberRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberRemoveCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..db85822
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberRemoveCLI.java
|
|
|
f332ec |
@@ -0,0 +1,58 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2012 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.group;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class GroupMemberRemoveCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupMemberRemoveCLI(String name, GroupCLI parent) {
|
|
|
f332ec |
+ super(name, "Remove group member");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupMemberRemoveCLI(GroupCLI parent) {
|
|
|
f332ec |
+ this("member-del", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (args.length != 2) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String groupID = args[0];
|
|
|
f332ec |
+ String memberID = args[1];
|
|
|
f332ec |
+
|
|
|
f332ec |
+ parent.client.removeGroupMember(groupID, memberID);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Deleted group member \""+memberID+"\"");
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupMemberShowCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberShowCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..214f71d
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberShowCLI.java
|
|
|
f332ec |
@@ -0,0 +1,61 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2012 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.group;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.certsrv.group.GroupMemberData;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class GroupMemberShowCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupMemberShowCLI(String name, GroupCLI parent) {
|
|
|
f332ec |
+ super(name, "Show group member");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public GroupMemberShowCLI(GroupCLI parent) {
|
|
|
f332ec |
+ this("member-show", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (args.length != 2) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String groupID = args[0];
|
|
|
f332ec |
+ String memberID = args[1];
|
|
|
f332ec |
+
|
|
|
f332ec |
+ GroupMemberData groupMemberData = parent.client.getGroupMember(groupID, memberID);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Group member \""+memberID+"\"");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ GroupCLI.printGroupMember(groupMemberData);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java
|
|
|
f332ec |
index c12cc89..9672488 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java
|
|
|
f332ec |
@@ -18,37 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.group;
|
|
|
f332ec |
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class GroupRemoveMemberCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public GroupCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class GroupRemoveMemberCLI extends GroupMemberRemoveCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public GroupRemoveMemberCLI(GroupCLI parent) {
|
|
|
f332ec |
- super("remove-member", "Remove group member");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (args.length != 2) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String groupID = args[0];
|
|
|
f332ec |
- String memberID = args[1];
|
|
|
f332ec |
-
|
|
|
f332ec |
- parent.client.removeGroupMember(groupID, memberID);
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Deleted group member \""+memberID+"\"");
|
|
|
f332ec |
+ super("remove-member", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java
|
|
|
f332ec |
index 47ca43c..6e493d3 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java
|
|
|
f332ec |
@@ -18,40 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.group;
|
|
|
f332ec |
|
|
|
f332ec |
-import com.netscape.certsrv.group.GroupMemberData;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class GroupShowMemberCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public GroupCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class GroupShowMemberCLI extends GroupMemberShowCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public GroupShowMemberCLI(GroupCLI parent) {
|
|
|
f332ec |
- super("show-member", "Show group member");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (args.length != 2) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String groupID = args[0];
|
|
|
f332ec |
- String memberID = args[1];
|
|
|
f332ec |
-
|
|
|
f332ec |
- GroupMemberData groupMemberData = parent.client.getGroupMember(groupID, memberID);
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Group member \""+memberID+"\"");
|
|
|
f332ec |
-
|
|
|
f332ec |
- GroupCLI.printGroupMember(groupMemberData);
|
|
|
f332ec |
+ super("show-member", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java
|
|
|
f332ec |
index 7bec2ff..528d39c 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java
|
|
|
f332ec |
@@ -18,80 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.user;
|
|
|
f332ec |
|
|
|
f332ec |
-import java.io.File;
|
|
|
f332ec |
-import java.util.Scanner;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
-import org.apache.commons.cli.Option;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import com.netscape.certsrv.user.UserCertData;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class UserAddCertCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public UserCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class UserAddCertCLI extends UserCertAddCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public UserAddCertCLI(UserCLI parent) {
|
|
|
f332ec |
- super("add-cert", "Add user cert");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- Option option = new Option(null, "input", true, "Input file");
|
|
|
f332ec |
- option.setArgName("file");
|
|
|
f332ec |
- option.setRequired(true);
|
|
|
f332ec |
- options.addOption(option);
|
|
|
f332ec |
-
|
|
|
f332ec |
- CommandLine cmd = null;
|
|
|
f332ec |
-
|
|
|
f332ec |
- try {
|
|
|
f332ec |
- cmd = parser.parse(options, args);
|
|
|
f332ec |
-
|
|
|
f332ec |
- } catch (Exception e) {
|
|
|
f332ec |
- System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (cmdArgs.length != 1) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String userId = cmdArgs[0];
|
|
|
f332ec |
- String file = cmd.getOptionValue("input");
|
|
|
f332ec |
-
|
|
|
f332ec |
- // get cert from file
|
|
|
f332ec |
- if (verbose) {
|
|
|
f332ec |
- System.out.println("Reading cert from "+file+".");
|
|
|
f332ec |
- }
|
|
|
f332ec |
- String encoded = new Scanner(new File(file)).useDelimiter("\\A").next();
|
|
|
f332ec |
- if (verbose) {
|
|
|
f332ec |
- System.out.println(encoded);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- UserCertData userCertData = new UserCertData();
|
|
|
f332ec |
- userCertData.setEncoded(encoded);
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (verbose) {
|
|
|
f332ec |
- System.out.println(userCertData);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- userCertData = parent.client.addUserCert(userId, userCertData);
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Added certificate \"" + userCertData.getID() + "\"");
|
|
|
f332ec |
-
|
|
|
f332ec |
- UserCLI.printCert(userCertData, false, false);
|
|
|
f332ec |
+ super("add-cert", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java
|
|
|
f332ec |
index 224f226..43a55ea 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java
|
|
|
f332ec |
@@ -18,40 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.user;
|
|
|
f332ec |
|
|
|
f332ec |
-import com.netscape.certsrv.user.UserMembershipData;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class UserAddMembershipCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public UserCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class UserAddMembershipCLI extends UserMembershipAddCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public UserAddMembershipCLI(UserCLI parent) {
|
|
|
f332ec |
- super("add-membership", "Add user membership");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <User ID> <Group ID>", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (args.length != 2) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String userID = args[0];
|
|
|
f332ec |
- String groupID = args[1];
|
|
|
f332ec |
-
|
|
|
f332ec |
- UserMembershipData userMembershipData = parent.client.addUserMembership(userID, groupID);
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Added membership in \""+groupID+"\"");
|
|
|
f332ec |
-
|
|
|
f332ec |
- UserCLI.printUserMembership(userMembershipData);
|
|
|
f332ec |
+ super("add-membership", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
|
|
|
f332ec |
index 2343d19..be404b8 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
|
|
|
f332ec |
@@ -53,30 +53,18 @@ public class UserCLI extends CLI {
|
|
|
f332ec |
addModule(new UserAddCertCLI(this));
|
|
|
f332ec |
addModule(new UserRemoveCertCLI(this));
|
|
|
f332ec |
|
|
|
f332ec |
+ addModule(new UserCertFindCLI(this));
|
|
|
f332ec |
+ addModule(new UserCertShowCLI(this));
|
|
|
f332ec |
+ addModule(new UserCertAddCLI(this));
|
|
|
f332ec |
+ addModule(new UserCertRemoveCLI(this));
|
|
|
f332ec |
+
|
|
|
f332ec |
addModule(new UserFindMembershipCLI(this));
|
|
|
f332ec |
addModule(new UserAddMembershipCLI(this));
|
|
|
f332ec |
addModule(new UserRemoveMembershipCLI(this));
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
-
|
|
|
f332ec |
- System.out.println("Commands:");
|
|
|
f332ec |
|
|
|
f332ec |
- int leftPadding = 1;
|
|
|
f332ec |
- int rightPadding = 25;
|
|
|
f332ec |
-
|
|
|
f332ec |
- for (CLI module : modules.values()) {
|
|
|
f332ec |
- String label = name + "-" + module.getName();
|
|
|
f332ec |
-
|
|
|
f332ec |
- int padding = rightPadding - leftPadding - label.length();
|
|
|
f332ec |
- if (padding < 1)
|
|
|
f332ec |
- padding = 1;
|
|
|
f332ec |
-
|
|
|
f332ec |
- System.out.print(StringUtils.repeat(" ", leftPadding));
|
|
|
f332ec |
- System.out.print(label);
|
|
|
f332ec |
- System.out.print(StringUtils.repeat(" ", padding));
|
|
|
f332ec |
- System.out.println(module.getDescription());
|
|
|
f332ec |
- }
|
|
|
f332ec |
+ addModule(new UserMembershipFindCLI(this));
|
|
|
f332ec |
+ addModule(new UserMembershipAddCLI(this));
|
|
|
f332ec |
+ addModule(new UserMembershipRemoveCLI(this));
|
|
|
f332ec |
}
|
|
|
f332ec |
|
|
|
f332ec |
public void execute(String[] args) throws Exception {
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCertAddCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCertAddCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..6e2e5cc
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCertAddCLI.java
|
|
|
f332ec |
@@ -0,0 +1,105 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2012 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.user;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import java.io.File;
|
|
|
f332ec |
+import java.util.Scanner;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
+import org.apache.commons.cli.Option;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.certsrv.user.UserCertData;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class UserCertAddCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCertAddCLI(String name, UserCLI parent) {
|
|
|
f332ec |
+ super(name, "Add user cert");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCertAddCLI(UserCLI parent) {
|
|
|
f332ec |
+ this("cert-add", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ Option option = new Option(null, "input", true, "Input file");
|
|
|
f332ec |
+ option.setArgName("file");
|
|
|
f332ec |
+ option.setRequired(true);
|
|
|
f332ec |
+ options.addOption(option);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ CommandLine cmd = null;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ try {
|
|
|
f332ec |
+ cmd = parser.parse(options, args);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } catch (Exception e) {
|
|
|
f332ec |
+ System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (cmdArgs.length != 1) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String userId = cmdArgs[0];
|
|
|
f332ec |
+ String file = cmd.getOptionValue("input");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ // get cert from file
|
|
|
f332ec |
+ if (verbose) {
|
|
|
f332ec |
+ System.out.println("Reading cert from "+file+".");
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ UserCertData userCertData = new UserCertData();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ try (Scanner scanner = new Scanner(new File(file))) {
|
|
|
f332ec |
+ String encoded = scanner.useDelimiter("\\A").next();
|
|
|
f332ec |
+ if (verbose) {
|
|
|
f332ec |
+ System.out.println(encoded);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ userCertData.setEncoded(encoded);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (verbose) {
|
|
|
f332ec |
+ System.out.println(userCertData);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ userCertData = parent.client.addUserCert(userId, userCertData);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Added certificate \"" + userCertData.getID() + "\"");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ UserCLI.printCert(userCertData, false, false);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..c0c85a0
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java
|
|
|
f332ec |
@@ -0,0 +1,108 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2012 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.user;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import java.util.Collection;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
+import org.apache.commons.cli.Option;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.certsrv.user.UserCertCollection;
|
|
|
f332ec |
+import com.netscape.certsrv.user.UserCertData;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class UserCertFindCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCertFindCLI(String name, UserCLI parent) {
|
|
|
f332ec |
+ super(name, "Find user certs");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCertFindCLI(UserCLI parent) {
|
|
|
f332ec |
+ this("cert-find", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ Option option = new Option(null, "start", true, "Page start");
|
|
|
f332ec |
+ option.setArgName("start");
|
|
|
f332ec |
+ options.addOption(option);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ option = new Option(null, "size", true, "Page size");
|
|
|
f332ec |
+ option.setArgName("size");
|
|
|
f332ec |
+ options.addOption(option);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ CommandLine cmd = null;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ try {
|
|
|
f332ec |
+ cmd = parser.parse(options, args);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } catch (Exception e) {
|
|
|
f332ec |
+ System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (cmdArgs.length != 1) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String userID = cmdArgs[0];
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String s = cmd.getOptionValue("start");
|
|
|
f332ec |
+ Integer start = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ s = cmd.getOptionValue("size");
|
|
|
f332ec |
+ Integer size = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ UserCertCollection response = parent.client.findUserCerts(userID, start, size);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ Collection<UserCertData> entries = response.getCerts();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage(entries.size() + " user cert(s) matched");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ boolean first = true;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ for (UserCertData userCertData : entries) {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (first) {
|
|
|
f332ec |
+ first = false;
|
|
|
f332ec |
+ } else {
|
|
|
f332ec |
+ System.out.println();
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ UserCLI.printCert(userCertData, false, false);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Number of entries returned " + entries.size());
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCertRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCertRemoveCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..503e137
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCertRemoveCLI.java
|
|
|
f332ec |
@@ -0,0 +1,65 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2012 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.user;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import java.net.URLEncoder;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class UserCertRemoveCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCertRemoveCLI(String name, UserCLI parent) {
|
|
|
f332ec |
+ super(name, "Remove user cert");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCertRemoveCLI(UserCLI parent) {
|
|
|
f332ec |
+ this("cert-del", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <User ID> <Cert ID>", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (args.length != 2) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String userID = args[0];
|
|
|
f332ec |
+ String certID = args[1];
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (verbose) {
|
|
|
f332ec |
+ System.out.println("Removing cert "+certID+" from user "+userID+".");
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ parent.client.removeUserCert(userID, URLEncoder.encode(certID, "UTF-8"));
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Deleted certificate \"" + certID + "\"");
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCertShowCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCertShowCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..fcf5159
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCertShowCLI.java
|
|
|
f332ec |
@@ -0,0 +1,100 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2012 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.user;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import java.io.FileWriter;
|
|
|
f332ec |
+import java.io.PrintWriter;
|
|
|
f332ec |
+import java.net.URLEncoder;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
+import org.apache.commons.cli.Option;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.certsrv.user.UserCertData;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class UserCertShowCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCertShowCLI(String name, UserCLI parent) {
|
|
|
f332ec |
+ super(name, "Show user cert");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCertShowCLI(UserCLI parent) {
|
|
|
f332ec |
+ this("cert-show", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <User ID> <Cert ID> [OPTIONS...]", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ Option option = new Option(null, "output", true, "Output file");
|
|
|
f332ec |
+ option.setArgName("file");
|
|
|
f332ec |
+ options.addOption(option);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ options.addOption(null, "pretty", false, "Pretty print");
|
|
|
f332ec |
+ options.addOption(null, "encoded", false, "Base-64 encoded");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ CommandLine cmd = null;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ try {
|
|
|
f332ec |
+ cmd = parser.parse(options, args);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } catch (Exception e) {
|
|
|
f332ec |
+ System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ boolean showPrettyPrint = cmd.hasOption("pretty");
|
|
|
f332ec |
+ boolean showEncoded = cmd.hasOption("encoded");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (cmdArgs.length != 2) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String userID = cmdArgs[0];
|
|
|
f332ec |
+ String certID = cmdArgs[1];
|
|
|
f332ec |
+ String file = cmd.getOptionValue("output");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ UserCertData userCertData = parent.client.getUserCert(userID, URLEncoder.encode(certID, "UTF-8"));
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String encoded = userCertData.getEncoded();
|
|
|
f332ec |
+ if (encoded != null && file != null) {
|
|
|
f332ec |
+ // store cert to file
|
|
|
f332ec |
+ PrintWriter out = new PrintWriter(new FileWriter(file));
|
|
|
f332ec |
+ out.print(encoded);
|
|
|
f332ec |
+ out.close();
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Certificate \"" + userCertData.getID() + "\"");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ UserCLI.printCert(userCertData, showPrettyPrint, showEncoded);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java
|
|
|
f332ec |
index 08f6879..baf73c9 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java
|
|
|
f332ec |
@@ -18,87 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.user;
|
|
|
f332ec |
|
|
|
f332ec |
-import java.util.Collection;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
-import org.apache.commons.cli.Option;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import com.netscape.certsrv.user.UserCertCollection;
|
|
|
f332ec |
-import com.netscape.certsrv.user.UserCertData;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class UserFindCertCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public UserCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class UserFindCertCLI extends UserCertFindCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public UserFindCertCLI(UserCLI parent) {
|
|
|
f332ec |
- super("find-cert", "Find user certs");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- Option option = new Option(null, "start", true, "Page start");
|
|
|
f332ec |
- option.setArgName("start");
|
|
|
f332ec |
- options.addOption(option);
|
|
|
f332ec |
-
|
|
|
f332ec |
- option = new Option(null, "size", true, "Page size");
|
|
|
f332ec |
- option.setArgName("size");
|
|
|
f332ec |
- options.addOption(option);
|
|
|
f332ec |
-
|
|
|
f332ec |
- CommandLine cmd = null;
|
|
|
f332ec |
-
|
|
|
f332ec |
- try {
|
|
|
f332ec |
- cmd = parser.parse(options, args);
|
|
|
f332ec |
-
|
|
|
f332ec |
- } catch (Exception e) {
|
|
|
f332ec |
- System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (cmdArgs.length != 1) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String userID = cmdArgs[0];
|
|
|
f332ec |
-
|
|
|
f332ec |
- String s = cmd.getOptionValue("start");
|
|
|
f332ec |
- Integer start = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
-
|
|
|
f332ec |
- s = cmd.getOptionValue("size");
|
|
|
f332ec |
- Integer size = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
-
|
|
|
f332ec |
- UserCertCollection response = parent.client.findUserCerts(userID, start, size);
|
|
|
f332ec |
-
|
|
|
f332ec |
- Collection<UserCertData> entries = response.getCerts();
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage(entries.size() + " user cert(s) matched");
|
|
|
f332ec |
-
|
|
|
f332ec |
- boolean first = true;
|
|
|
f332ec |
-
|
|
|
f332ec |
- for (UserCertData userCertData : entries) {
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (first) {
|
|
|
f332ec |
- first = false;
|
|
|
f332ec |
- } else {
|
|
|
f332ec |
- System.out.println();
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- UserCLI.printCert(userCertData, false, false);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Number of entries returned " + entries.size());
|
|
|
f332ec |
+ super("find-cert", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java
|
|
|
f332ec |
index 494c3c3..24fb9ca 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java
|
|
|
f332ec |
@@ -18,87 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.user;
|
|
|
f332ec |
|
|
|
f332ec |
-import java.util.Collection;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
-import org.apache.commons.cli.Option;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import com.netscape.certsrv.user.UserMembershipCollection;
|
|
|
f332ec |
-import com.netscape.certsrv.user.UserMembershipData;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class UserFindMembershipCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public UserCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class UserFindMembershipCLI extends UserMembershipFindCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public UserFindMembershipCLI(UserCLI parent) {
|
|
|
f332ec |
- super("find-membership", "Find user memberships");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- Option option = new Option(null, "start", true, "Page start");
|
|
|
f332ec |
- option.setArgName("start");
|
|
|
f332ec |
- options.addOption(option);
|
|
|
f332ec |
-
|
|
|
f332ec |
- option = new Option(null, "size", true, "Page size");
|
|
|
f332ec |
- option.setArgName("size");
|
|
|
f332ec |
- options.addOption(option);
|
|
|
f332ec |
-
|
|
|
f332ec |
- CommandLine cmd = null;
|
|
|
f332ec |
-
|
|
|
f332ec |
- try {
|
|
|
f332ec |
- cmd = parser.parse(options, args);
|
|
|
f332ec |
-
|
|
|
f332ec |
- } catch (Exception e) {
|
|
|
f332ec |
- System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (cmdArgs.length != 1) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String userID = cmdArgs[0];
|
|
|
f332ec |
-
|
|
|
f332ec |
- String s = cmd.getOptionValue("start");
|
|
|
f332ec |
- Integer start = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
-
|
|
|
f332ec |
- s = cmd.getOptionValue("size");
|
|
|
f332ec |
- Integer size = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
-
|
|
|
f332ec |
- UserMembershipCollection response = parent.client.findUserMemberships(userID, start, size);
|
|
|
f332ec |
-
|
|
|
f332ec |
- Collection<UserMembershipData> entries = response.getMemberships();
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage(entries.size()+" membership(s) matched");
|
|
|
f332ec |
-
|
|
|
f332ec |
- boolean first = true;
|
|
|
f332ec |
-
|
|
|
f332ec |
- for (UserMembershipData userMembershipData : entries) {
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (first) {
|
|
|
f332ec |
- first = false;
|
|
|
f332ec |
- } else {
|
|
|
f332ec |
- System.out.println();
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- UserCLI.printUserMembership(userMembershipData);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Number of entries returned "+entries.size());
|
|
|
f332ec |
+ super("find-membership", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserMembershipAddCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipAddCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..44cb578
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipAddCLI.java
|
|
|
f332ec |
@@ -0,0 +1,61 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2013 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.user;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.certsrv.user.UserMembershipData;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class UserMembershipAddCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserMembershipAddCLI(String name, UserCLI parent) {
|
|
|
f332ec |
+ super(name, "Add user membership");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserMembershipAddCLI(UserCLI parent) {
|
|
|
f332ec |
+ this("membership-add", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <User ID> <Group ID>", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (args.length != 2) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String userID = args[0];
|
|
|
f332ec |
+ String groupID = args[1];
|
|
|
f332ec |
+
|
|
|
f332ec |
+ UserMembershipData userMembershipData = parent.client.addUserMembership(userID, groupID);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Added membership in \""+groupID+"\"");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ UserCLI.printUserMembership(userMembershipData);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..beca5f4
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java
|
|
|
f332ec |
@@ -0,0 +1,108 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2013 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.user;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import java.util.Collection;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
+import org.apache.commons.cli.Option;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.certsrv.user.UserMembershipCollection;
|
|
|
f332ec |
+import com.netscape.certsrv.user.UserMembershipData;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class UserMembershipFindCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserMembershipFindCLI(String name, UserCLI parent) {
|
|
|
f332ec |
+ super(name, "Find user memberships");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserMembershipFindCLI(UserCLI parent) {
|
|
|
f332ec |
+ this("membership-find", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ Option option = new Option(null, "start", true, "Page start");
|
|
|
f332ec |
+ option.setArgName("start");
|
|
|
f332ec |
+ options.addOption(option);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ option = new Option(null, "size", true, "Page size");
|
|
|
f332ec |
+ option.setArgName("size");
|
|
|
f332ec |
+ options.addOption(option);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ CommandLine cmd = null;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ try {
|
|
|
f332ec |
+ cmd = parser.parse(options, args);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ } catch (Exception e) {
|
|
|
f332ec |
+ System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (cmdArgs.length != 1) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String userID = cmdArgs[0];
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String s = cmd.getOptionValue("start");
|
|
|
f332ec |
+ Integer start = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ s = cmd.getOptionValue("size");
|
|
|
f332ec |
+ Integer size = s == null ? null : Integer.valueOf(s);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ UserMembershipCollection response = parent.client.findUserMemberships(userID, start, size);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ Collection<UserMembershipData> entries = response.getMemberships();
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage(entries.size()+" membership(s) matched");
|
|
|
f332ec |
+
|
|
|
f332ec |
+ boolean first = true;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ for (UserMembershipData userMembershipData : entries) {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (first) {
|
|
|
f332ec |
+ first = false;
|
|
|
f332ec |
+ } else {
|
|
|
f332ec |
+ System.out.println();
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ UserCLI.printUserMembership(userMembershipData);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Number of entries returned "+entries.size());
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserMembershipRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipRemoveCLI.java
|
|
|
f332ec |
new file mode 100644
|
|
|
f332ec |
index 0000000..ba43b05
|
|
|
f332ec |
--- /dev/null
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipRemoveCLI.java
|
|
|
f332ec |
@@ -0,0 +1,58 @@
|
|
|
f332ec |
+// --- BEGIN COPYRIGHT BLOCK ---
|
|
|
f332ec |
+// This program is free software; you can redistribute it and/or modify
|
|
|
f332ec |
+// it under the terms of the GNU General Public License as published by
|
|
|
f332ec |
+// the Free Software Foundation; version 2 of the License.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// This program is distributed in the hope that it will be useful,
|
|
|
f332ec |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f332ec |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f332ec |
+// GNU General Public License for more details.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// You should have received a copy of the GNU General Public License along
|
|
|
f332ec |
+// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
f332ec |
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
f332ec |
+//
|
|
|
f332ec |
+// (C) 2013 Red Hat, Inc.
|
|
|
f332ec |
+// All rights reserved.
|
|
|
f332ec |
+// --- END COPYRIGHT BLOCK ---
|
|
|
f332ec |
+
|
|
|
f332ec |
+package com.netscape.cmstools.user;
|
|
|
f332ec |
+
|
|
|
f332ec |
+import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
+import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
+
|
|
|
f332ec |
+/**
|
|
|
f332ec |
+ * @author Endi S. Dewata
|
|
|
f332ec |
+ */
|
|
|
f332ec |
+public class UserMembershipRemoveCLI extends CLI {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserCLI parent;
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserMembershipRemoveCLI(String name, UserCLI parent) {
|
|
|
f332ec |
+ super(name, "Remove user membership");
|
|
|
f332ec |
+ this.parent = parent;
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public UserMembershipRemoveCLI(UserCLI parent) {
|
|
|
f332ec |
+ this("membership-del", parent);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void printHelp() {
|
|
|
f332ec |
+ formatter.printHelp(parent.name + "-" + name + " <User ID> <Group ID>", options);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ public void execute(String[] args) throws Exception {
|
|
|
f332ec |
+
|
|
|
f332ec |
+ if (args.length != 2) {
|
|
|
f332ec |
+ printHelp();
|
|
|
f332ec |
+ System.exit(1);
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+
|
|
|
f332ec |
+ String userID = args[0];
|
|
|
f332ec |
+ String groupID = args[1];
|
|
|
f332ec |
+
|
|
|
f332ec |
+ parent.client.removeUserMembership(userID, groupID);
|
|
|
f332ec |
+
|
|
|
f332ec |
+ MainCLI.printMessage("Deleted membership in group \""+groupID+"\"");
|
|
|
f332ec |
+ }
|
|
|
f332ec |
+}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java
|
|
|
f332ec |
index 264458b..58fd57e 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java
|
|
|
f332ec |
@@ -18,44 +18,15 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.user;
|
|
|
f332ec |
|
|
|
f332ec |
-import java.net.URLEncoder;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class UserRemoveCertCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public UserCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class UserRemoveCertCLI extends UserCertRemoveCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public UserRemoveCertCLI(UserCLI parent) {
|
|
|
f332ec |
- super("remove-cert", "Remove user cert");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <User ID> <Cert ID>", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (args.length != 2) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String userID = args[0];
|
|
|
f332ec |
- String certID = args[1];
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (verbose) {
|
|
|
f332ec |
- System.out.println("Removing cert "+certID+" from user "+userID+".");
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- parent.client.removeUserCert(userID, URLEncoder.encode(certID, "UTF-8"));
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Deleted certificate \"" + certID + "\"");
|
|
|
f332ec |
+ super("remove-cert", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java
|
|
|
f332ec |
index 26a5a6e..4cafcec 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java
|
|
|
f332ec |
@@ -18,37 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.user;
|
|
|
f332ec |
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class UserRemoveMembershipCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public UserCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class UserRemoveMembershipCLI extends UserMembershipRemoveCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public UserRemoveMembershipCLI(UserCLI parent) {
|
|
|
f332ec |
- super("remove-membership", "Remove user membership");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <User ID> <Group ID>", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (args.length != 2) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String userID = args[0];
|
|
|
f332ec |
- String groupID = args[1];
|
|
|
f332ec |
-
|
|
|
f332ec |
- parent.client.removeUserMembership(userID, groupID);
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Deleted membership in group \""+groupID+"\"");
|
|
|
f332ec |
+ super("remove-membership", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java
|
|
|
f332ec |
index f30c723..5177281 100644
|
|
|
f332ec |
--- a/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java
|
|
|
f332ec |
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java
|
|
|
f332ec |
@@ -18,79 +18,14 @@
|
|
|
f332ec |
|
|
|
f332ec |
package com.netscape.cmstools.user;
|
|
|
f332ec |
|
|
|
f332ec |
-import java.io.FileWriter;
|
|
|
f332ec |
-import java.io.PrintWriter;
|
|
|
f332ec |
-import java.net.URLEncoder;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import org.apache.commons.cli.CommandLine;
|
|
|
f332ec |
-import org.apache.commons.cli.Option;
|
|
|
f332ec |
-
|
|
|
f332ec |
-import com.netscape.certsrv.user.UserCertData;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.CLI;
|
|
|
f332ec |
-import com.netscape.cmstools.cli.MainCLI;
|
|
|
f332ec |
|
|
|
f332ec |
/**
|
|
|
f332ec |
* @author Endi S. Dewata
|
|
|
f332ec |
*/
|
|
|
f332ec |
-public class UserShowCertCLI extends CLI {
|
|
|
f332ec |
-
|
|
|
f332ec |
- public UserCLI parent;
|
|
|
f332ec |
+@Deprecated
|
|
|
f332ec |
+public class UserShowCertCLI extends UserCertShowCLI {
|
|
|
f332ec |
|
|
|
f332ec |
public UserShowCertCLI(UserCLI parent) {
|
|
|
f332ec |
- super("show-cert", "Show user cert");
|
|
|
f332ec |
- this.parent = parent;
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void printHelp() {
|
|
|
f332ec |
- formatter.printHelp(parent.name + "-" + name + " <User ID> <Cert ID> [OPTIONS...]", options);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- public void execute(String[] args) throws Exception {
|
|
|
f332ec |
-
|
|
|
f332ec |
- Option option = new Option(null, "output", true, "Output file");
|
|
|
f332ec |
- option.setArgName("file");
|
|
|
f332ec |
- options.addOption(option);
|
|
|
f332ec |
-
|
|
|
f332ec |
- options.addOption(null, "pretty", false, "Pretty print");
|
|
|
f332ec |
- options.addOption(null, "encoded", false, "Base-64 encoded");
|
|
|
f332ec |
-
|
|
|
f332ec |
- CommandLine cmd = null;
|
|
|
f332ec |
-
|
|
|
f332ec |
- try {
|
|
|
f332ec |
- cmd = parser.parse(options, args);
|
|
|
f332ec |
-
|
|
|
f332ec |
- } catch (Exception e) {
|
|
|
f332ec |
- System.err.println("Error: " + e.getMessage());
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- boolean showPrettyPrint = cmd.hasOption("pretty");
|
|
|
f332ec |
- boolean showEncoded = cmd.hasOption("encoded");
|
|
|
f332ec |
-
|
|
|
f332ec |
- String[] cmdArgs = cmd.getArgs();
|
|
|
f332ec |
-
|
|
|
f332ec |
- if (cmdArgs.length != 2) {
|
|
|
f332ec |
- printHelp();
|
|
|
f332ec |
- System.exit(1);
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- String userID = cmdArgs[0];
|
|
|
f332ec |
- String certID = cmdArgs[1];
|
|
|
f332ec |
- String file = cmd.getOptionValue("output");
|
|
|
f332ec |
-
|
|
|
f332ec |
- UserCertData userCertData = parent.client.getUserCert(userID, URLEncoder.encode(certID, "UTF-8"));
|
|
|
f332ec |
-
|
|
|
f332ec |
- String encoded = userCertData.getEncoded();
|
|
|
f332ec |
- if (encoded != null && file != null) {
|
|
|
f332ec |
- // store cert to file
|
|
|
f332ec |
- PrintWriter out = new PrintWriter(new FileWriter(file));
|
|
|
f332ec |
- out.print(encoded);
|
|
|
f332ec |
- out.close();
|
|
|
f332ec |
- }
|
|
|
f332ec |
-
|
|
|
f332ec |
- MainCLI.printMessage("Certificate \"" + userCertData.getID() + "\"");
|
|
|
f332ec |
-
|
|
|
f332ec |
- UserCLI.printCert(userCertData, showPrettyPrint, showEncoded);
|
|
|
f332ec |
+ super("show-cert", parent);
|
|
|
f332ec |
}
|
|
|
f332ec |
}
|
|
|
f332ec |
--
|
|
|
f332ec |
1.8.3.1
|
|
|
f332ec |
|