From 523bb36b7bca1560debf6a9bedc131eb05c6b7f9 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Tue, 29 Oct 2013 10:56:15 -0400
Subject: [PATCH] Added CLI command aliases.

New aliases for some CLI commands have been added for consistency:

* client-cert-find       -> client-find-cert
* client-cert-import     -> client-import-cert
* client-cert-del        -> client-remove-cert
* group-member-add       -> group-add-member
* group-member-find      -> group-find-member
* group-member-show      -> group-show-member
* group-member-del       -> group-remove-member
* user-cert-add          -> user-add-cert
* user-cert-find         -> user-find-cert
* user-cert-show         -> user-show-cert
* user-cert-del          -> user-remove-cert
* user-membership-add    -> user-add-membership
* user-membership-find   -> user-find-membership
* user-membership-show   -> user-show-membership
* user-membership-del    -> user-remove-membership

The original commands will continue to work as before.
---
 .../com/netscape/cmstools/client/ClientCLI.java    |  4 +
 ...ientFindCertCLI.java => ClientCertFindCLI.java} | 10 ++-
 ...ImportCertCLI.java => ClientCertImportCLI.java} | 10 ++-
 ...RemoveCertCLI.java => ClientCertRemoveCLI.java} | 10 ++-
 .../cmstools/client/ClientFindCertCLI.java         | 59 +-------------
 .../cmstools/client/ClientImportCertCLI.java       | 94 +---------------------
 .../cmstools/client/ClientRemoveCertCLI.java       | 40 +--------
 .../netscape/cmstools/group/GroupAddMemberCLI.java | 31 +------
 .../src/com/netscape/cmstools/group/GroupCLI.java  |  5 ++
 .../cmstools/group/GroupFindMemberCLI.java         | 78 +-----------------
 ...oupAddMemberCLI.java => GroupMemberAddCLI.java} | 10 ++-
 ...pFindMemberCLI.java => GroupMemberFindCLI.java} | 10 ++-
 ...oveMemberCLI.java => GroupMemberRemoveCLI.java} | 10 ++-
 ...pShowMemberCLI.java => GroupMemberShowCLI.java} | 10 ++-
 .../cmstools/group/GroupRemoveMemberCLI.java       | 28 +------
 .../cmstools/group/GroupShowMemberCLI.java         | 31 +------
 .../com/netscape/cmstools/user/UserAddCertCLI.java | 71 +---------------
 .../cmstools/user/UserAddMembershipCLI.java        | 31 +------
 .../src/com/netscape/cmstools/user/UserCLI.java    |  9 +++
 .../{UserAddCertCLI.java => UserCertAddCLI.java}   | 24 ++++--
 .../{UserFindCertCLI.java => UserCertFindCLI.java} | 10 ++-
 ...erRemoveCertCLI.java => UserCertRemoveCLI.java} | 10 ++-
 .../{UserShowCertCLI.java => UserCertShowCLI.java} | 10 ++-
 .../netscape/cmstools/user/UserFindCertCLI.java    | 78 +-----------------
 .../cmstools/user/UserFindMembershipCLI.java       | 78 +-----------------
 ...embershipCLI.java => UserMembershipAddCLI.java} | 10 ++-
 ...mbershipCLI.java => UserMembershipFindCLI.java} | 10 ++-
 ...ershipCLI.java => UserMembershipRemoveCLI.java} | 10 ++-
 .../netscape/cmstools/user/UserRemoveCertCLI.java  | 34 +-------
 .../cmstools/user/UserRemoveMembershipCLI.java     | 28 +------
 .../netscape/cmstools/user/UserShowCertCLI.java    | 70 +---------------
 specs/pki-core.spec                                |  1 +
 32 files changed, 154 insertions(+), 770 deletions(-)
 copy base/java-tools/src/com/netscape/cmstools/client/{ClientFindCertCLI.java => ClientCertFindCLI.java} (89%)
 copy base/java-tools/src/com/netscape/cmstools/client/{ClientImportCertCLI.java => ClientCertImportCLI.java} (93%)
 copy base/java-tools/src/com/netscape/cmstools/client/{ClientRemoveCertCLI.java => ClientCertRemoveCLI.java} (86%)
 copy base/java-tools/src/com/netscape/cmstools/group/{GroupAddMemberCLI.java => GroupMemberAddCLI.java} (87%)
 copy base/java-tools/src/com/netscape/cmstools/group/{GroupFindMemberCLI.java => GroupMemberFindCLI.java} (92%)
 copy base/java-tools/src/com/netscape/cmstools/group/{GroupRemoveMemberCLI.java => GroupMemberRemoveCLI.java} (85%)
 copy base/java-tools/src/com/netscape/cmstools/group/{GroupShowMemberCLI.java => GroupMemberShowCLI.java} (87%)
 copy base/java-tools/src/com/netscape/cmstools/user/{UserAddCertCLI.java => UserCertAddCLI.java} (83%)
 copy base/java-tools/src/com/netscape/cmstools/user/{UserFindCertCLI.java => UserCertFindCLI.java} (92%)
 copy base/java-tools/src/com/netscape/cmstools/user/{UserRemoveCertCLI.java => UserCertRemoveCLI.java} (87%)
 copy base/java-tools/src/com/netscape/cmstools/user/{UserShowCertCLI.java => UserCertShowCLI.java} (92%)
 copy base/java-tools/src/com/netscape/cmstools/user/{UserAddMembershipCLI.java => UserMembershipAddCLI.java} (86%)
 copy base/java-tools/src/com/netscape/cmstools/user/{UserFindMembershipCLI.java => UserMembershipFindCLI.java} (92%)
 copy base/java-tools/src/com/netscape/cmstools/user/{UserRemoveMembershipCLI.java => UserMembershipRemoveCLI.java} (85%)

diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java
index 34d09f33ca442d888285e00703c6016084ab76bc..6e291d3e426a374a2605d33bec7eba449b633c3c 100644
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java
@@ -41,6 +41,10 @@ public class ClientCLI extends CLI {
         addModule(new ClientFindCertCLI(this));
         addModule(new ClientImportCertCLI(this));
         addModule(new ClientRemoveCertCLI(this));
+
+        addModule(new ClientCertFindCLI(this));
+        addModule(new ClientCertImportCLI(this));
+        addModule(new ClientCertRemoveCLI(this));
     }
 
     public void printHelp() {
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCertFindCLI.java
similarity index 89%
copy from base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java
copy to base/java-tools/src/com/netscape/cmstools/client/ClientCertFindCLI.java
index 80690b7d09874740ee96b818a6c9258eee067565..c4e1aca828b8310e378862f07289ba0bc443371f 100644
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCertFindCLI.java
@@ -27,15 +27,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class ClientFindCertCLI extends CLI {
+public class ClientCertFindCLI extends CLI {
 
     public ClientCLI parent;
 
-    public ClientFindCertCLI(ClientCLI parent) {
-        super("find-cert", "Find certificates in client security database");
+    public ClientCertFindCLI(String name, ClientCLI parent) {
+        super(name, "Find certificates in client security database");
         this.parent = parent;
     }
 
+    public ClientCertFindCLI(ClientCLI parent) {
+        this("cert-find", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " [OPTIONS]", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
similarity index 93%
copy from base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java
copy to base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
index e89f954bb5fc4a4b54cd811d730d82a217e00b27..ffd68d9c6e21ffa8371535e80f767ad985282d2d 100644
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
@@ -32,15 +32,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class ClientImportCertCLI extends CLI {
+public class ClientCertImportCLI extends CLI {
 
     public ClientCLI parent;
 
-    public ClientImportCertCLI(ClientCLI parent) {
-        super("import-cert", "Import certificate into client security database");
+    public ClientCertImportCLI(String name, ClientCLI parent) {
+        super(name, "Import certificate into client security database");
         this.parent = parent;
     }
 
+    public ClientCertImportCLI(ClientCLI parent) {
+        this("cert-import", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " [OPTIONS]", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCertRemoveCLI.java
similarity index 86%
copy from base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java
copy to base/java-tools/src/com/netscape/cmstools/client/ClientCertRemoveCLI.java
index fab4296314243c21ad6f718452d357c4dec1799f..2c054469e6ec806f62c12c55364ba1af1c66c662 100644
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCertRemoveCLI.java
@@ -26,15 +26,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class ClientRemoveCertCLI extends CLI {
+public class ClientCertRemoveCLI extends CLI {
 
     public ClientCLI parent;
 
-    public ClientRemoveCertCLI(ClientCLI parent) {
-        super("remove-cert", "Remove certificate from client security database");
+    public ClientCertRemoveCLI(String name, ClientCLI parent) {
+        super(name, "Remove certificate from client security database");
         this.parent = parent;
     }
 
+    public ClientCertRemoveCLI(ClientCLI parent) {
+        this("cert-del", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <nickname>", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java
index 80690b7d09874740ee96b818a6c9258eee067565..37f5ec8b39a6650730ad4d738162206f340bb8aa 100644
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientFindCertCLI.java
@@ -18,68 +18,13 @@
 
 package com.netscape.cmstools.client;
 
-import org.apache.commons.cli.CommandLine;
-import org.mozilla.jss.crypto.X509Certificate;
-
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class ClientFindCertCLI extends CLI {
-
-    public ClientCLI parent;
+public class ClientFindCertCLI extends ClientCertFindCLI {
 
     public ClientFindCertCLI(ClientCLI parent) {
-        super("find-cert", "Find certificates in client security database");
-        this.parent = parent;
+        super("find-cert", parent);
     }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " [OPTIONS]", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        options.addOption(null, "ca", false, "Find CA certificates only");
-
-        CommandLine cmd = null;
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(1);
-        }
-
-        X509Certificate[] certs;
-        if (cmd.hasOption("ca")) {
-            certs = parent.parent.client.getCACerts();
-        } else {
-            certs = parent.parent.client.getCerts();
-        }
-
-        if (certs == null || certs.length == 0) {
-            MainCLI.printMessage("No certificates found");
-            System.exit(0); // valid result
-        }
-
-        MainCLI.printMessage(certs.length + " certificate(s) found");
-
-        boolean first = true;
-
-        for (X509Certificate cert : certs) {
-            if (first) {
-                first = false;
-            } else {
-                System.out.println();
-            }
-
-            ClientCLI.printCertInfo(cert);
-        }
-
-        MainCLI.printMessage("Number of entries returned " + certs.length);
-   }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java
index e89f954bb5fc4a4b54cd811d730d82a217e00b27..dd42d92baf8875e1fb130428160c4d0cb1b53bf3 100644
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientImportCertCLI.java
@@ -18,103 +18,13 @@
 
 package com.netscape.cmstools.client;
 
-import java.io.File;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.io.FileUtils;
-import org.mozilla.jss.crypto.X509Certificate;
-
-import com.netscape.certsrv.client.ClientConfig;
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class ClientImportCertCLI extends CLI {
-
-    public ClientCLI parent;
+public class ClientImportCertCLI extends ClientCertImportCLI {
 
     public ClientImportCertCLI(ClientCLI parent) {
-        super("import-cert", "Import certificate into client security database");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " [OPTIONS]", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        Option option = new Option(null, "cert", true, "Import certificate file");
-        option.setArgName("path");
-        options.addOption(option);
-
-        option = new Option(null, "ca-cert", true, "Import CA certificate file");
-        option.setArgName("path");
-        options.addOption(option);
-
-        options.addOption(null, "ca-server", false, "Import CA certificate from CA server");
-
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(1);
-        }
-
-        byte[] bytes = null;
-        X509Certificate cert = null;
-
-        String certPath = cmd.getOptionValue("cert");
-        String caCertPath = cmd.getOptionValue("ca-cert");
-        boolean importFromCAServer = cmd.hasOption("ca-server");
-
-        boolean isCACert = false;
-
-        // load the certificate
-        if (certPath != null) {
-            if (verbose) System.out.println("Loading certificate from " + certPath + ".");
-            bytes = FileUtils.readFileToByteArray(new File(certPath));
-
-
-        } else if (caCertPath != null) {
-            if (verbose) System.out.println("Loading CA certificate from " + caCertPath + ".");
-            bytes = FileUtils.readFileToByteArray(new File(caCertPath));
-
-            isCACert = true;
-
-        } else if (importFromCAServer) {
-            ClientConfig config = parent.parent.config;
-            String caServerURI = "http://" + config.getServerURI().getHost() + ":8080/ca";
-
-            if (verbose) System.out.println("Downloading CA certificate from " + caServerURI + ".");
-            bytes = parent.parent.client.downloadCACertChain(caServerURI);
-
-            isCACert = true;
-
-        } else {
-            System.err.println("Error: Missing certificate to import");
-            printHelp();
-            System.exit(1);
-        }
-
-        // import the certificate
-        if (isCACert) {
-            if (verbose) System.out.println("Importing CA certificate.");
-            cert = parent.parent.client.importCACertPackage(bytes);
-
-        } else {
-            if (verbose) System.out.println("Importing certificate.");
-            cert = parent.parent.client.importCertPackage(bytes, parent.parent.client.config.getCertNickname());
-        }
-
-        MainCLI.printMessage("Imported certificate \"" + cert.getNickname() + "\"");
-        ClientCLI.printCertInfo(cert);
+        super("import-cert", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java
index fab4296314243c21ad6f718452d357c4dec1799f..34f31f9ccf4603cd1864d9417c1c03fd55e983e8 100644
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientRemoveCertCLI.java
@@ -18,49 +18,13 @@
 
 package com.netscape.cmstools.client;
 
-import org.apache.commons.cli.CommandLine;
-
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class ClientRemoveCertCLI extends CLI {
-
-    public ClientCLI parent;
+public class ClientRemoveCertCLI extends ClientCertRemoveCLI {
 
     public ClientRemoveCertCLI(ClientCLI parent) {
-        super("remove-cert", "Remove certificate from client security database");
-        this.parent = parent;
+        super("remove-cert", parent);
     }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <nickname>", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        CommandLine cmd = null;
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(1);
-        }
-
-        String[] cmdArgs = cmd.getArgs();
-
-        if (cmdArgs.length != 1) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String nickname = cmdArgs[0];
-        parent.parent.client.removeCert(nickname);
-
-        MainCLI.printMessage("Removed certificate \"" + nickname + "\"");
-   }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java
index 36d3c06fd2f87f860ac26b1d5a5fb83960187059..c4528cf180ccba4293b020728166927945f71f7b 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java
@@ -18,40 +18,13 @@
 
 package com.netscape.cmstools.group;
 
-import com.netscape.certsrv.group.GroupMemberData;
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class GroupAddMemberCLI extends CLI {
-
-    public GroupCLI parent;
+public class GroupAddMemberCLI extends GroupMemberAddCLI {
 
     public GroupAddMemberCLI(GroupCLI parent) {
-        super("add-member", "Add group member");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        if (args.length != 2) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String groupID = args[0];
-        String memberID = args[1];
-
-        GroupMemberData groupMemberData = parent.client.addGroupMember(groupID, memberID);
-
-        MainCLI.printMessage("Added group member \""+memberID+"\"");
-
-        GroupCLI.printGroupMember(groupMemberData);
+        super("add-member", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
index bd8cec7735f8802328d99ae07cbbda3bdbfd8637..cf91b0ff87fdd2391b700d9b809bdd84976101fc 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
@@ -51,6 +51,11 @@ public class GroupCLI extends CLI {
         addModule(new GroupShowMemberCLI(this));
         addModule(new GroupAddMemberCLI(this));
         addModule(new GroupRemoveMemberCLI(this));
+
+        addModule(new GroupMemberFindCLI(this));
+        addModule(new GroupMemberShowCLI(this));
+        addModule(new GroupMemberAddCLI(this));
+        addModule(new GroupMemberRemoveCLI(this));
     }
 
     public void printHelp() {
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java
index f0498f0d274227b8b0835a5d6e9895cc32c4f079..0f61de76d85d64c812d0037bc589bde896110976 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java
@@ -18,87 +18,13 @@
 
 package com.netscape.cmstools.group;
 
-import java.util.Collection;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-
-import com.netscape.certsrv.group.GroupMemberCollection;
-import com.netscape.certsrv.group.GroupMemberData;
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class GroupFindMemberCLI extends CLI {
-
-    public GroupCLI parent;
+public class GroupFindMemberCLI extends GroupMemberFindCLI {
 
     public GroupFindMemberCLI(GroupCLI parent) {
-        super("find-member", "Find group members");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <Group ID> [OPTIONS...]", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        Option option = new Option(null, "start", true, "Page start");
-        option.setArgName("start");
-        options.addOption(option);
-
-        option = new Option(null, "size", true, "Page size");
-        option.setArgName("size");
-        options.addOption(option);
-
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(1);
-        }
-
-        String[] cmdArgs = cmd.getArgs();
-
-        if (cmdArgs.length != 1) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String groupID = cmdArgs[0];
-
-        String s = cmd.getOptionValue("start");
-        Integer start = s == null ? null : Integer.valueOf(s);
-
-        s = cmd.getOptionValue("size");
-        Integer size = s == null ? null : Integer.valueOf(s);
-
-        GroupMemberCollection response = parent.client.findGroupMembers(groupID, start, size);
-
-        Collection<GroupMemberData> entries = response.getMembers();
-
-        MainCLI.printMessage(entries.size()+" group member(s) matched");
-
-        boolean first = true;
-
-        for (GroupMemberData groupMemberData : entries) {
-
-            if (first) {
-                first = false;
-            } else {
-                System.out.println();
-            }
-
-            GroupCLI.printGroupMember(groupMemberData);
-        }
-
-        MainCLI.printMessage("Number of entries returned "+entries.size());
+        super("find-member", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberAddCLI.java
similarity index 87%
copy from base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java
copy to base/java-tools/src/com/netscape/cmstools/group/GroupMemberAddCLI.java
index 36d3c06fd2f87f860ac26b1d5a5fb83960187059..5945e21dc743a3e7dfee89cb213491fbbfed1a0c 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupAddMemberCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberAddCLI.java
@@ -25,15 +25,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class GroupAddMemberCLI extends CLI {
+public class GroupMemberAddCLI extends CLI {
 
     public GroupCLI parent;
 
-    public GroupAddMemberCLI(GroupCLI parent) {
-        super("add-member", "Add group member");
+    public GroupMemberAddCLI(String name, GroupCLI parent) {
+        super(name, "Add group member");
         this.parent = parent;
     }
 
+    public GroupMemberAddCLI(GroupCLI parent) {
+        this("member-add", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java
similarity index 92%
copy from base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java
copy to base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java
index f0498f0d274227b8b0835a5d6e9895cc32c4f079..c36d04113627576a8f229714361ac6f800d96dcf 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupFindMemberCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java
@@ -31,15 +31,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class GroupFindMemberCLI extends CLI {
+public class GroupMemberFindCLI extends CLI {
 
     public GroupCLI parent;
 
-    public GroupFindMemberCLI(GroupCLI parent) {
-        super("find-member", "Find group members");
+    public GroupMemberFindCLI(String name, GroupCLI parent) {
+        super(name, "Find group members");
         this.parent = parent;
     }
 
+    public GroupMemberFindCLI(GroupCLI parent) {
+        this("member-find", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <Group ID> [OPTIONS...]", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberRemoveCLI.java
similarity index 85%
copy from base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java
copy to base/java-tools/src/com/netscape/cmstools/group/GroupMemberRemoveCLI.java
index c12cc892e5d0f0fdef107571c51c7b4b0a8c7d02..db8582253e54794ffb2616f1c549b0b3b64bc49a 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberRemoveCLI.java
@@ -24,15 +24,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class GroupRemoveMemberCLI extends CLI {
+public class GroupMemberRemoveCLI extends CLI {
 
     public GroupCLI parent;
 
-    public GroupRemoveMemberCLI(GroupCLI parent) {
-        super("remove-member", "Remove group member");
+    public GroupMemberRemoveCLI(String name, GroupCLI parent) {
+        super(name, "Remove group member");
         this.parent = parent;
     }
 
+    public GroupMemberRemoveCLI(GroupCLI parent) {
+        this("member-del", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberShowCLI.java
similarity index 87%
copy from base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java
copy to base/java-tools/src/com/netscape/cmstools/group/GroupMemberShowCLI.java
index 47ca43c8f1a8d42a6261001c6b5d62cdc4240329..214f71dbc9c25efc19876847c2d42bea56ea8774 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberShowCLI.java
@@ -25,15 +25,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class GroupShowMemberCLI extends CLI {
+public class GroupMemberShowCLI extends CLI {
 
     public GroupCLI parent;
 
-    public GroupShowMemberCLI(GroupCLI parent) {
-        super("show-member", "Show group member");
+    public GroupMemberShowCLI(String name, GroupCLI parent) {
+        super(name, "Show group member");
         this.parent = parent;
     }
 
+    public GroupMemberShowCLI(GroupCLI parent) {
+        this("member-show", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java
index c12cc892e5d0f0fdef107571c51c7b4b0a8c7d02..690806d70188366fbcc87767c0eca188b153a8d4 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupRemoveMemberCLI.java
@@ -18,37 +18,13 @@
 
 package com.netscape.cmstools.group;
 
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class GroupRemoveMemberCLI extends CLI {
-
-    public GroupCLI parent;
+public class GroupRemoveMemberCLI extends GroupMemberRemoveCLI {
 
     public GroupRemoveMemberCLI(GroupCLI parent) {
-        super("remove-member", "Remove group member");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        if (args.length != 2) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String groupID = args[0];
-        String memberID = args[1];
-
-        parent.client.removeGroupMember(groupID, memberID);
-
-        MainCLI.printMessage("Deleted group member \""+memberID+"\"");
+        super("remove-member", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java
index 47ca43c8f1a8d42a6261001c6b5d62cdc4240329..af4d15b49fc0eac6a09835f27f48bf951408ee2a 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupShowMemberCLI.java
@@ -18,40 +18,13 @@
 
 package com.netscape.cmstools.group;
 
-import com.netscape.certsrv.group.GroupMemberData;
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class GroupShowMemberCLI extends CLI {
-
-    public GroupCLI parent;
+public class GroupShowMemberCLI extends GroupMemberShowCLI {
 
     public GroupShowMemberCLI(GroupCLI parent) {
-        super("show-member", "Show group member");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <Group ID> <Member ID>", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        if (args.length != 2) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String groupID = args[0];
-        String memberID = args[1];
-
-        GroupMemberData groupMemberData = parent.client.getGroupMember(groupID, memberID);
-
-        MainCLI.printMessage("Group member \""+memberID+"\"");
-
-        GroupCLI.printGroupMember(groupMemberData);
+        super("show-member", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java
index 7bec2ff19905438070ca86a3f56bffc86d74f2e8..78da04313717694c31b71bfe205e6e63defd5f94 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java
@@ -18,80 +18,13 @@
 
 package com.netscape.cmstools.user;
 
-import java.io.File;
-import java.util.Scanner;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-
-import com.netscape.certsrv.user.UserCertData;
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class UserAddCertCLI extends CLI {
-
-    public UserCLI parent;
+public class UserAddCertCLI extends UserCertAddCLI {
 
     public UserAddCertCLI(UserCLI parent) {
-        super("add-cert", "Add user cert");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        Option option = new Option(null, "input", true, "Input file");
-        option.setArgName("file");
-        option.setRequired(true);
-        options.addOption(option);
-
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(1);
-        }
-
-        String[] cmdArgs = cmd.getArgs();
-
-        if (cmdArgs.length != 1) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String userId = cmdArgs[0];
-        String file = cmd.getOptionValue("input");
-
-        // get cert from file
-        if (verbose) {
-            System.out.println("Reading cert from "+file+".");
-        }
-        String encoded = new Scanner(new File(file)).useDelimiter("\\A").next();
-        if (verbose) {
-            System.out.println(encoded);
-        }
-
-        UserCertData userCertData = new UserCertData();
-        userCertData.setEncoded(encoded);
-
-        if (verbose) {
-            System.out.println(userCertData);
-        }
-
-        userCertData = parent.client.addUserCert(userId, userCertData);
-
-        MainCLI.printMessage("Added certificate \"" + userCertData.getID() + "\"");
-
-        UserCLI.printCert(userCertData, false, false);
+        super("add-cert", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java
index 224f2266d319a788dc9c47eccffced9c68a07cb7..43cde733ad38032827280a887b3f9ec2e945f5cd 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java
@@ -18,40 +18,13 @@
 
 package com.netscape.cmstools.user;
 
-import com.netscape.certsrv.user.UserMembershipData;
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class UserAddMembershipCLI extends CLI {
-
-    public UserCLI parent;
+public class UserAddMembershipCLI extends UserMembershipAddCLI {
 
     public UserAddMembershipCLI(UserCLI parent) {
-        super("add-membership", "Add user membership");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> <Group ID>", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        if (args.length != 2) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String userID = args[0];
-        String groupID = args[1];
-
-        UserMembershipData userMembershipData = parent.client.addUserMembership(userID, groupID);
-
-        MainCLI.printMessage("Added membership in \""+groupID+"\"");
-
-        UserCLI.printUserMembership(userMembershipData);
+        super("add-membership", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
index 2343d1989e412b7d06102cbb6773a4dde2a0b319..f0bf9d97033811e637249d26deebef89148ed494 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
@@ -53,9 +53,18 @@ public class UserCLI extends CLI {
         addModule(new UserAddCertCLI(this));
         addModule(new UserRemoveCertCLI(this));
 
+        addModule(new UserCertFindCLI(this));
+        addModule(new UserCertShowCLI(this));
+        addModule(new UserCertAddCLI(this));
+        addModule(new UserCertRemoveCLI(this));
+
         addModule(new UserFindMembershipCLI(this));
         addModule(new UserAddMembershipCLI(this));
         addModule(new UserRemoveMembershipCLI(this));
+
+        addModule(new UserMembershipFindCLI(this));
+        addModule(new UserMembershipAddCLI(this));
+        addModule(new UserMembershipRemoveCLI(this));
     }
 
     public void printHelp() {
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCertAddCLI.java
similarity index 83%
copy from base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java
copy to base/java-tools/src/com/netscape/cmstools/user/UserCertAddCLI.java
index 7bec2ff19905438070ca86a3f56bffc86d74f2e8..6e2e5cc127968f2e55b4c5dccc075c972d060fa9 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCertAddCLI.java
@@ -31,15 +31,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class UserAddCertCLI extends CLI {
+public class UserCertAddCLI extends CLI {
 
     public UserCLI parent;
 
-    public UserAddCertCLI(UserCLI parent) {
-        super("add-cert", "Add user cert");
+    public UserCertAddCLI(String name, UserCLI parent) {
+        super(name, "Add user cert");
         this.parent = parent;
     }
 
+    public UserCertAddCLI(UserCLI parent) {
+        this("cert-add", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
     }
@@ -76,13 +80,17 @@ public class UserAddCertCLI extends CLI {
         if (verbose) {
             System.out.println("Reading cert from "+file+".");
         }
-        String encoded = new Scanner(new File(file)).useDelimiter("\\A").next();
-        if (verbose) {
-            System.out.println(encoded);
-        }
 
         UserCertData userCertData = new UserCertData();
-        userCertData.setEncoded(encoded);
+
+        try (Scanner scanner = new Scanner(new File(file))) {
+            String encoded = scanner.useDelimiter("\\A").next();
+            if (verbose) {
+                System.out.println(encoded);
+            }
+
+            userCertData.setEncoded(encoded);
+        }
 
         if (verbose) {
             System.out.println(userCertData);
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java
similarity index 92%
copy from base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java
copy to base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java
index 08f6879331f389b78fc0df4126967da6f293d7ed..c0c85a04c4202a28f443702c71ea6a457e398553 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java
@@ -31,15 +31,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class UserFindCertCLI extends CLI {
+public class UserCertFindCLI extends CLI {
 
     public UserCLI parent;
 
-    public UserFindCertCLI(UserCLI parent) {
-        super("find-cert", "Find user certs");
+    public UserCertFindCLI(String name, UserCLI parent) {
+        super(name, "Find user certs");
         this.parent = parent;
     }
 
+    public UserCertFindCLI(UserCLI parent) {
+        this("cert-find", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCertRemoveCLI.java
similarity index 87%
copy from base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java
copy to base/java-tools/src/com/netscape/cmstools/user/UserCertRemoveCLI.java
index 264458b7f38a2fd150df30b2dc4dd6de49236dfa..503e1377a93ff66ef1139fadb8b7c8236d67aa55 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCertRemoveCLI.java
@@ -27,15 +27,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class UserRemoveCertCLI extends CLI {
+public class UserCertRemoveCLI extends CLI {
 
     public UserCLI parent;
 
-    public UserRemoveCertCLI(UserCLI parent) {
-        super("remove-cert", "Remove user cert");
+    public UserCertRemoveCLI(String name, UserCLI parent) {
+        super(name, "Remove user cert");
         this.parent = parent;
     }
 
+    public UserCertRemoveCLI(UserCLI parent) {
+        this("cert-del", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <User ID> <Cert ID>", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCertShowCLI.java
similarity index 92%
copy from base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java
copy to base/java-tools/src/com/netscape/cmstools/user/UserCertShowCLI.java
index f30c72327410dc9552a9999011029d772abf2c4b..fcf5159de39dfe231cf96187777ad4217b3b4879 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCertShowCLI.java
@@ -32,15 +32,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class UserShowCertCLI extends CLI {
+public class UserCertShowCLI extends CLI {
 
     public UserCLI parent;
 
-    public UserShowCertCLI(UserCLI parent) {
-        super("show-cert", "Show user cert");
+    public UserCertShowCLI(String name, UserCLI parent) {
+        super(name, "Show user cert");
         this.parent = parent;
     }
 
+    public UserCertShowCLI(UserCLI parent) {
+        this("cert-show", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <User ID> <Cert ID> [OPTIONS...]", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java
index 08f6879331f389b78fc0df4126967da6f293d7ed..22b9d0bf0ff641a655bbb2af904b4093bc9ba416 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java
@@ -18,87 +18,13 @@
 
 package com.netscape.cmstools.user;
 
-import java.util.Collection;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-
-import com.netscape.certsrv.user.UserCertCollection;
-import com.netscape.certsrv.user.UserCertData;
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class UserFindCertCLI extends CLI {
-
-    public UserCLI parent;
+public class UserFindCertCLI extends UserCertFindCLI {
 
     public UserFindCertCLI(UserCLI parent) {
-        super("find-cert", "Find user certs");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        Option option = new Option(null, "start", true, "Page start");
-        option.setArgName("start");
-        options.addOption(option);
-
-        option = new Option(null, "size", true, "Page size");
-        option.setArgName("size");
-        options.addOption(option);
-
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(1);
-        }
-
-        String[] cmdArgs = cmd.getArgs();
-
-        if (cmdArgs.length != 1) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String userID = cmdArgs[0];
-
-        String s = cmd.getOptionValue("start");
-        Integer start = s == null ? null : Integer.valueOf(s);
-
-        s = cmd.getOptionValue("size");
-        Integer size = s == null ? null : Integer.valueOf(s);
-
-        UserCertCollection response = parent.client.findUserCerts(userID, start, size);
-
-        Collection<UserCertData> entries = response.getCerts();
-
-        MainCLI.printMessage(entries.size() + " user cert(s) matched");
-
-        boolean first = true;
-
-        for (UserCertData userCertData : entries) {
-
-            if (first) {
-                first = false;
-            } else {
-                System.out.println();
-            }
-
-            UserCLI.printCert(userCertData, false, false);
-        }
-
-        MainCLI.printMessage("Number of entries returned " + entries.size());
+        super("find-cert", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java
index 494c3c323ba7fdf717636eb93ebf764e9246d114..86d0848f8ef2fecb9bcf4510b568f9f89bd77791 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java
@@ -18,87 +18,13 @@
 
 package com.netscape.cmstools.user;
 
-import java.util.Collection;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-
-import com.netscape.certsrv.user.UserMembershipCollection;
-import com.netscape.certsrv.user.UserMembershipData;
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class UserFindMembershipCLI extends CLI {
-
-    public UserCLI parent;
+public class UserFindMembershipCLI extends UserMembershipFindCLI {
 
     public UserFindMembershipCLI(UserCLI parent) {
-        super("find-membership", "Find user memberships");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        Option option = new Option(null, "start", true, "Page start");
-        option.setArgName("start");
-        options.addOption(option);
-
-        option = new Option(null, "size", true, "Page size");
-        option.setArgName("size");
-        options.addOption(option);
-
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(1);
-        }
-
-        String[] cmdArgs = cmd.getArgs();
-
-        if (cmdArgs.length != 1) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String userID = cmdArgs[0];
-
-        String s = cmd.getOptionValue("start");
-        Integer start = s == null ? null : Integer.valueOf(s);
-
-        s = cmd.getOptionValue("size");
-        Integer size = s == null ? null : Integer.valueOf(s);
-
-        UserMembershipCollection response = parent.client.findUserMemberships(userID, start, size);
-
-        Collection<UserMembershipData> entries = response.getMemberships();
-
-        MainCLI.printMessage(entries.size()+" membership(s) matched");
-
-        boolean first = true;
-
-        for (UserMembershipData userMembershipData : entries) {
-
-            if (first) {
-                first = false;
-            } else {
-                System.out.println();
-            }
-
-            UserCLI.printUserMembership(userMembershipData);
-        }
-
-        MainCLI.printMessage("Number of entries returned "+entries.size());
+        super("find-membership", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipAddCLI.java
similarity index 86%
copy from base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java
copy to base/java-tools/src/com/netscape/cmstools/user/UserMembershipAddCLI.java
index 224f2266d319a788dc9c47eccffced9c68a07cb7..44cb578232df1e4635a0d6c179103013f5e7fe96 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipAddCLI.java
@@ -25,15 +25,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class UserAddMembershipCLI extends CLI {
+public class UserMembershipAddCLI extends CLI {
 
     public UserCLI parent;
 
-    public UserAddMembershipCLI(UserCLI parent) {
-        super("add-membership", "Add user membership");
+    public UserMembershipAddCLI(String name, UserCLI parent) {
+        super(name, "Add user membership");
         this.parent = parent;
     }
 
+    public UserMembershipAddCLI(UserCLI parent) {
+        this("membership-add", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <User ID> <Group ID>", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java
similarity index 92%
copy from base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java
copy to base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java
index 494c3c323ba7fdf717636eb93ebf764e9246d114..beca5f40e5e621f1a6c5c8cdbb85920977340737 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java
@@ -31,15 +31,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class UserFindMembershipCLI extends CLI {
+public class UserMembershipFindCLI extends CLI {
 
     public UserCLI parent;
 
-    public UserFindMembershipCLI(UserCLI parent) {
-        super("find-membership", "Find user memberships");
+    public UserMembershipFindCLI(String name, UserCLI parent) {
+        super(name, "Find user memberships");
         this.parent = parent;
     }
 
+    public UserMembershipFindCLI(UserCLI parent) {
+        this("membership-find", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipRemoveCLI.java
similarity index 85%
copy from base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java
copy to base/java-tools/src/com/netscape/cmstools/user/UserMembershipRemoveCLI.java
index 26a5a6eec5222b98718df1f5a524d364970ac3ed..ba43b05f45d575aad8a262a0b5ffae8be1727680 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipRemoveCLI.java
@@ -24,15 +24,19 @@ import com.netscape.cmstools.cli.MainCLI;
 /**
  * @author Endi S. Dewata
  */
-public class UserRemoveMembershipCLI extends CLI {
+public class UserMembershipRemoveCLI extends CLI {
 
     public UserCLI parent;
 
-    public UserRemoveMembershipCLI(UserCLI parent) {
-        super("remove-membership", "Remove user membership");
+    public UserMembershipRemoveCLI(String name, UserCLI parent) {
+        super(name, "Remove user membership");
         this.parent = parent;
     }
 
+    public UserMembershipRemoveCLI(UserCLI parent) {
+        this("membership-del", parent);
+    }
+
     public void printHelp() {
         formatter.printHelp(parent.name + "-" + name + " <User ID> <Group ID>", options);
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java
index 264458b7f38a2fd150df30b2dc4dd6de49236dfa..8652199841f86c7c4b8c65185e76c5391775f3a8 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java
@@ -18,44 +18,14 @@
 
 package com.netscape.cmstools.user;
 
-import java.net.URLEncoder;
-
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 
 /**
  * @author Endi S. Dewata
  */
-public class UserRemoveCertCLI extends CLI {
-
-    public UserCLI parent;
+public class UserRemoveCertCLI extends UserCertRemoveCLI {
 
     public UserRemoveCertCLI(UserCLI parent) {
-        super("remove-cert", "Remove user cert");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> <Cert ID>", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        if (args.length != 2) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String userID = args[0];
-        String certID = args[1];
-
-        if (verbose) {
-            System.out.println("Removing cert "+certID+" from user "+userID+".");
-        }
-
-        parent.client.removeUserCert(userID, URLEncoder.encode(certID, "UTF-8"));
-
-        MainCLI.printMessage("Deleted certificate \"" + certID + "\"");
+        super("remove-cert", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java
index 26a5a6eec5222b98718df1f5a524d364970ac3ed..0ba958c0962b05d2f414e8e261cbf94c02763d08 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java
@@ -18,37 +18,13 @@
 
 package com.netscape.cmstools.user;
 
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class UserRemoveMembershipCLI extends CLI {
-
-    public UserCLI parent;
+public class UserRemoveMembershipCLI extends UserMembershipRemoveCLI {
 
     public UserRemoveMembershipCLI(UserCLI parent) {
-        super("remove-membership", "Remove user membership");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> <Group ID>", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        if (args.length != 2) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String userID = args[0];
-        String groupID = args[1];
-
-        parent.client.removeUserMembership(userID, groupID);
-
-        MainCLI.printMessage("Deleted membership in group \""+groupID+"\"");
+        super("remove-membership", parent);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java
index f30c72327410dc9552a9999011029d772abf2c4b..63d07205fe89f8e61f62773191e919ffddb2072f 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java
@@ -18,79 +18,13 @@
 
 package com.netscape.cmstools.user;
 
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.net.URLEncoder;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-
-import com.netscape.certsrv.user.UserCertData;
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class UserShowCertCLI extends CLI {
-
-    public UserCLI parent;
+public class UserShowCertCLI extends UserCertShowCLI {
 
     public UserShowCertCLI(UserCLI parent) {
-        super("show-cert", "Show user cert");
-        this.parent = parent;
-    }
-
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> <Cert ID> [OPTIONS...]", options);
-    }
-
-    public void execute(String[] args) throws Exception {
-
-        Option option = new Option(null, "output", true, "Output file");
-        option.setArgName("file");
-        options.addOption(option);
-
-        options.addOption(null, "pretty", false, "Pretty print");
-        options.addOption(null, "encoded", false, "Base-64 encoded");
-
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(1);
-        }
-
-        boolean showPrettyPrint = cmd.hasOption("pretty");
-        boolean showEncoded = cmd.hasOption("encoded");
-
-        String[] cmdArgs = cmd.getArgs();
-
-        if (cmdArgs.length != 2) {
-            printHelp();
-            System.exit(1);
-        }
-
-        String userID = cmdArgs[0];
-        String certID = cmdArgs[1];
-        String file = cmd.getOptionValue("output");
-
-        UserCertData userCertData = parent.client.getUserCert(userID, URLEncoder.encode(certID, "UTF-8"));
-
-        String encoded = userCertData.getEncoded();
-        if (encoded != null && file != null) {
-            // store cert to file
-            PrintWriter out = new PrintWriter(new FileWriter(file));
-            out.print(encoded);
-            out.close();
-        }
-
-        MainCLI.printMessage("Certificate \"" + userCertData.getID() + "\"");
-
-        UserCLI.printCert(userCertData, showPrettyPrint, showEncoded);
+        super("show-cert", parent);
     }
 }
diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index fca53ff2d5b33623bb1e9cabec58e43f285dbea7..3374221ffb403bfc2d5c7c43f82175121a55b0ae 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -1139,6 +1139,7 @@ fi
 - Fixed error handling in DoUnrevoke servlet.
 - Fixed errors during Tomcat shutdown.
 - Backup upgrade tracker.
+- Added CLI command aliases.
 
 * Fri Sep 6 2013 Ade Lee <alee@redhat.com> 10.0.5-1
 - Roll release to next version
-- 
1.8.1.4

