From 9a5fdaed159dc2865b207784f3b782b07f1ea17d Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Tue, 6 Aug 2013 02:29:50 -0400
Subject: [PATCH] Reorganized CLI user commands.

New CLI modules have been added for each subsystem. The user commands
have been moved under these subsystems.

Ticket #701
---
 .../src/com/netscape/certsrv/ca/CAClient.java      | 10 +++--
 .../certsrv/kra/{DRMClient.java => KRAClient.java} | 10 +++--
 .../src/com/netscape/certsrv/ocsp/OCSPClient.java  | 41 +++++++++++++++++++++
 .../src/com/netscape/certsrv/tks/TKSClient.java    | 41 +++++++++++++++++++++
 .../src/com/netscape/certsrv/user/UserClient.java  | 16 ++++----
 .../{user/UserRemoveCLI.java => cli/CACLI.java}    | 43 +++++++++++-----------
 .../{user/UserRemoveCLI.java => cli/KRACLI.java}   | 43 +++++++++++-----------
 .../src/com/netscape/cmstools/cli/MainCLI.java     |  6 ++-
 .../{user/UserRemoveCLI.java => cli/OCSPCLI.java}  | 43 +++++++++++-----------
 .../{user/UserRemoveCLI.java => cli/TKSCLI.java}   | 43 +++++++++++-----------
 .../src/com/netscape/cmstools/user/UserAddCLI.java | 12 +++---
 .../com/netscape/cmstools/user/UserAddCertCLI.java | 12 +++---
 .../cmstools/user/UserAddMembershipCLI.java        | 12 +++---
 .../src/com/netscape/cmstools/user/UserCLI.java    | 34 +++--------------
 .../com/netscape/cmstools/user/UserFindCLI.java    | 12 +++---
 .../netscape/cmstools/user/UserFindCertCLI.java    | 12 +++---
 .../cmstools/user/UserFindMembershipCLI.java       | 12 +++---
 .../com/netscape/cmstools/user/UserModifyCLI.java  | 12 +++---
 .../com/netscape/cmstools/user/UserRemoveCLI.java  | 12 +++---
 .../netscape/cmstools/user/UserRemoveCertCLI.java  | 12 +++---
 .../cmstools/user/UserRemoveMembershipCLI.java     | 12 +++---
 .../com/netscape/cmstools/user/UserShowCLI.java    | 12 +++---
 .../netscape/cmstools/user/UserShowCertCLI.java    | 12 +++---
 .../src/com/netscape/cms/servlet/test/DRMTest.java |  6 +--
 24 files changed, 276 insertions(+), 204 deletions(-)
 rename base/common/src/com/netscape/certsrv/kra/{DRMClient.java => KRAClient.java} (94%)
 create mode 100644 base/common/src/com/netscape/certsrv/ocsp/OCSPClient.java
 create mode 100644 base/common/src/com/netscape/certsrv/tks/TKSClient.java
 copy base/java-tools/src/com/netscape/cmstools/{user/UserRemoveCLI.java => cli/CACLI.java} (53%)
 copy base/java-tools/src/com/netscape/cmstools/{user/UserRemoveCLI.java => cli/KRACLI.java} (53%)
 copy base/java-tools/src/com/netscape/cmstools/{user/UserRemoveCLI.java => cli/OCSPCLI.java} (52%)
 copy base/java-tools/src/com/netscape/cmstools/{user/UserRemoveCLI.java => cli/TKSCLI.java} (53%)

diff --git a/base/common/src/com/netscape/certsrv/ca/CAClient.java b/base/common/src/com/netscape/certsrv/ca/CAClient.java
index 655b13ab1c7779fefe11abb381eebe58bab01bff..86e706ef2f11f2af872be194bc406cb15b4baf56 100644
--- a/base/common/src/com/netscape/certsrv/ca/CAClient.java
+++ b/base/common/src/com/netscape/certsrv/ca/CAClient.java
@@ -37,6 +37,7 @@ import com.netscape.certsrv.profile.ProfileData;
 import com.netscape.certsrv.profile.ProfileDataInfos;
 import com.netscape.certsrv.profile.ProfileResource;
 import com.netscape.certsrv.request.RequestId;
+import com.netscape.certsrv.user.UserClient;
 
 public class CAClient extends SubsystemClient {
 
@@ -54,9 +55,12 @@ public class CAClient extends SubsystemClient {
     }
 
     public void init() throws URISyntaxException {
-        certRequestClient = client.createProxy(CertRequestResource.class);
-        certClient = client.createProxy(CertResource.class);
-        profileClient = client.createProxy(ProfileResource.class);
+
+        addClient(new UserClient(client, name));
+
+        certRequestClient = client.createProxy(name, CertRequestResource.class);
+        certClient = client.createProxy(name, CertResource.class);
+        profileClient = client.createProxy(name, ProfileResource.class);
     }
 
     public Collection<CertRequestInfo> listRequests(String requestState, String requestType) {
diff --git a/base/common/src/com/netscape/certsrv/kra/DRMClient.java b/base/common/src/com/netscape/certsrv/kra/KRAClient.java
similarity index 94%
rename from base/common/src/com/netscape/certsrv/kra/DRMClient.java
rename to base/common/src/com/netscape/certsrv/kra/KRAClient.java
index 9e8e20deeef31d2656396ab0778c9e3461f9c20a..e07f91d7edbde933354d06f960003ee9cd5883e7 100644
--- a/base/common/src/com/netscape/certsrv/kra/DRMClient.java
+++ b/base/common/src/com/netscape/certsrv/kra/KRAClient.java
@@ -22,24 +22,28 @@ import com.netscape.certsrv.key.KeyRequestResource;
 import com.netscape.certsrv.key.KeyResource;
 import com.netscape.certsrv.request.RequestId;
 import com.netscape.certsrv.system.SystemCertResource;
+import com.netscape.certsrv.user.UserClient;
 import com.netscape.cmsutil.util.Utils;
 
-public class DRMClient extends SubsystemClient {
+public class KRAClient extends SubsystemClient {
 
     private KeyResource keyClient;
     private KeyRequestResource keyRequestClient;
     private SystemCertResource systemCertClient;
 
-    public DRMClient(ClientConfig config) throws URISyntaxException {
+    public KRAClient(ClientConfig config) throws URISyntaxException {
         this(new PKIClient(config));
     }
 
-    public DRMClient(PKIClient client) throws URISyntaxException {
+    public KRAClient(PKIClient client) throws URISyntaxException {
         super(client, "kra");
         init();
     }
 
     public void init() throws URISyntaxException {
+
+        addClient(new UserClient(client, name));
+
         systemCertClient = client.createProxy(SystemCertResource.class);
         keyRequestClient = client.createProxy(KeyRequestResource.class);
         keyClient = client.createProxy(KeyResource.class);
diff --git a/base/common/src/com/netscape/certsrv/ocsp/OCSPClient.java b/base/common/src/com/netscape/certsrv/ocsp/OCSPClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..e18c646034e9aee805e13cc3dbd79b99218e7cf4
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/ocsp/OCSPClient.java
@@ -0,0 +1,41 @@
+//--- BEGIN COPYRIGHT BLOCK ---
+//This program is free software; you can redistribute it and/or modify
+//it under the terms of the GNU General Public License as published by
+//the Free Software Foundation; version 2 of the License.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License along
+//with this program; if not, write to the Free Software Foundation, Inc.,
+//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+//(C) 2012 Red Hat, Inc.
+//All rights reserved.
+//--- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.ocsp;
+
+import java.net.URISyntaxException;
+
+import com.netscape.certsrv.client.ClientConfig;
+import com.netscape.certsrv.client.PKIClient;
+import com.netscape.certsrv.client.SubsystemClient;
+import com.netscape.certsrv.user.UserClient;
+
+public class OCSPClient extends SubsystemClient {
+
+    public OCSPClient(ClientConfig config) throws URISyntaxException {
+        this(new PKIClient(config));
+    }
+
+    public OCSPClient(PKIClient client) throws URISyntaxException {
+        super(client, "ocsp");
+        init();
+    }
+
+    public void init() throws URISyntaxException {
+        addClient(new UserClient(client, name));
+    }
+}
diff --git a/base/common/src/com/netscape/certsrv/tks/TKSClient.java b/base/common/src/com/netscape/certsrv/tks/TKSClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..cfa544b51a85df3efc824f163e9b1aef8a11ae06
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/tks/TKSClient.java
@@ -0,0 +1,41 @@
+//--- BEGIN COPYRIGHT BLOCK ---
+//This program is free software; you can redistribute it and/or modify
+//it under the terms of the GNU General Public License as published by
+//the Free Software Foundation; version 2 of the License.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License along
+//with this program; if not, write to the Free Software Foundation, Inc.,
+//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+//(C) 2012 Red Hat, Inc.
+//All rights reserved.
+//--- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.tks;
+
+import java.net.URISyntaxException;
+
+import com.netscape.certsrv.client.ClientConfig;
+import com.netscape.certsrv.client.PKIClient;
+import com.netscape.certsrv.client.SubsystemClient;
+import com.netscape.certsrv.user.UserClient;
+
+public class TKSClient extends SubsystemClient {
+
+    public TKSClient(ClientConfig config) throws URISyntaxException {
+        this(new PKIClient(config));
+    }
+
+    public TKSClient(PKIClient client) throws URISyntaxException {
+        super(client, "tks");
+        init();
+    }
+
+    public void init() throws URISyntaxException {
+        addClient(new UserClient(client, name));
+    }
+}
diff --git a/base/common/src/com/netscape/certsrv/user/UserClient.java b/base/common/src/com/netscape/certsrv/user/UserClient.java
index bde2d919c609a2a0d4ea9aa1ad2847c175a3a247..a32bc4b5be120f6b07205cabc0bd99b28f3a673f 100644
--- a/base/common/src/com/netscape/certsrv/user/UserClient.java
+++ b/base/common/src/com/netscape/certsrv/user/UserClient.java
@@ -34,19 +34,17 @@ public class UserClient extends Client {
     public UserCertResource userCertClient;
     public UserMembershipResource userMembershipClient;
 
-    public UserClient(ClientConfig config) throws URISyntaxException {
-        this(new PKIClient(config));
+    public UserClient(ClientConfig config, String subsystem) throws URISyntaxException {
+        this(new PKIClient(config), subsystem);
     }
 
-    public UserClient(PKIClient client) throws URISyntaxException {
+
+    public UserClient(PKIClient client, String subsystem) throws URISyntaxException {
         super(client, "user");
-        init();
-    }
 
-    public void init() throws URISyntaxException {
-        userClient = client.createProxy(UserResource.class);
-        userCertClient = client.createProxy(UserCertResource.class);
-        userMembershipClient = client.createProxy(UserMembershipResource.class);
+        userClient = client.createProxy(subsystem, UserResource.class);
+        userCertClient = client.createProxy(subsystem, UserCertResource.class);
+        userMembershipClient = client.createProxy(subsystem, UserMembershipResource.class);
     }
 
     public UserCollection findUsers(String filter, Integer start, Integer size) {
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/CACLI.java
similarity index 53%
copy from base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
copy to base/java-tools/src/com/netscape/cmstools/cli/CACLI.java
index e7a9ad5d178a569e917d703600118912b7edb2e2..c659f4cb02e40b6d77e91409eafa261e5c270a31 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/CACLI.java
@@ -12,42 +12,43 @@
 // with this program; if not, write to the Free Software Foundation, Inc.,
 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 //
-// (C) 2012 Red Hat, Inc.
+// (C) 2013 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cmstools.user;
+package com.netscape.cmstools.cli;
 
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
+import com.netscape.certsrv.ca.CAClient;
+import com.netscape.certsrv.client.Client;
+import com.netscape.cmstools.user.UserCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class UserRemoveCLI extends CLI {
+public class CACLI extends SubsystemCLI {
 
-    public UserCLI parent;
+    public CAClient caClient;
 
-    public UserRemoveCLI(UserCLI parent) {
-        super("del", "Remove user");
-        this.parent = parent;
-    }
+    public CACLI(MainCLI mainCLI) {
+        super("ca", "CA management commands", mainCLI);
 
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID>", options);
+        addModule(new UserCLI(this));
     }
 
-    public void execute(String[] args) throws Exception {
-
-        if (args.length != 1) {
-            printHelp();
-            System.exit(1);
-        }
+    public void init() throws Exception {
+        client = mainCLI.client;
+        caClient = new CAClient(client);
+    }
 
-        String userID = args[0];
+    public void login() {
+        caClient.login();
+    }
 
-        parent.client.removeUser(userID);
+    public void logout() {
+        caClient.logout();
+    }
 
-        MainCLI.printMessage("Deleted user \"" + userID + "\"");
+    public Client getClient(String name) {
+        return caClient.getClient(name);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/KRACLI.java
similarity index 53%
copy from base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
copy to base/java-tools/src/com/netscape/cmstools/cli/KRACLI.java
index e7a9ad5d178a569e917d703600118912b7edb2e2..548fa41278ccf72421cdd8cb1477956db59c166b 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/KRACLI.java
@@ -12,42 +12,43 @@
 // with this program; if not, write to the Free Software Foundation, Inc.,
 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 //
-// (C) 2012 Red Hat, Inc.
+// (C) 2013 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cmstools.user;
+package com.netscape.cmstools.cli;
 
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
+import com.netscape.certsrv.client.Client;
+import com.netscape.certsrv.kra.KRAClient;
+import com.netscape.cmstools.user.UserCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class UserRemoveCLI extends CLI {
+public class KRACLI extends SubsystemCLI {
 
-    public UserCLI parent;
+    public KRAClient kraClient;
 
-    public UserRemoveCLI(UserCLI parent) {
-        super("del", "Remove user");
-        this.parent = parent;
-    }
+    public KRACLI(MainCLI mainCLI) {
+        super("kra", "KRA management commands", mainCLI);
 
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID>", options);
+        addModule(new UserCLI(this));
     }
 
-    public void execute(String[] args) throws Exception {
-
-        if (args.length != 1) {
-            printHelp();
-            System.exit(1);
-        }
+    public void init() throws Exception {
+        client = mainCLI.client;
+        kraClient = new KRAClient(client);
+    }
 
-        String userID = args[0];
+    public void login() {
+        kraClient.login();
+    }
 
-        parent.client.removeUser(userID);
+    public void logout() {
+        kraClient.logout();
+    }
 
-        MainCLI.printMessage("Deleted user \"" + userID + "\"");
+    public Client getClient(String name) {
+        return kraClient.getClient(name);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
index 35d7d9e181cafd5db49225fb1a2f4d893c4f7d75..df7b31cde518bc1b1f537be22ed497f1fedafe0f 100644
--- a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
@@ -46,7 +46,6 @@ import com.netscape.cmstools.key.KeyCLI;
 import com.netscape.cmstools.profile.ProfileCLI;
 import com.netscape.cmstools.system.KRAConnectorCLI;
 import com.netscape.cmstools.system.SecurityDomainCLI;
-import com.netscape.cmstools.user.UserCLI;
 
 /**
  * @author Endi S. Dewata
@@ -69,15 +68,18 @@ public class MainCLI extends CLI {
     public MainCLI() throws Exception {
         super("pki", "PKI command-line interface");
 
+        addModule(new CACLI(this));
         addModule(new CertCLI(this));
         addModule(new ClientCLI(this));
         addModule(new GroupCLI(this));
         addModule(new KeyCLI(this));
+        addModule(new KRACLI(this));
         addModule(new KRAConnectorCLI(this));
+        addModule(new OCSPCLI(this));
         addModule(new ProfileCLI(this));
         addModule(new SecurityDomainCLI(this));
+        addModule(new TKSCLI(this));
         addModule(new TPSCLI(this));
-        addModule(new UserCLI(this));
     }
 
     public void printVersion() {
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/OCSPCLI.java
similarity index 52%
copy from base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
copy to base/java-tools/src/com/netscape/cmstools/cli/OCSPCLI.java
index e7a9ad5d178a569e917d703600118912b7edb2e2..f4c452666282b1f90da00e0396aeca46edfbebd7 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/OCSPCLI.java
@@ -12,42 +12,43 @@
 // with this program; if not, write to the Free Software Foundation, Inc.,
 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 //
-// (C) 2012 Red Hat, Inc.
+// (C) 2013 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cmstools.user;
+package com.netscape.cmstools.cli;
 
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
+import com.netscape.certsrv.client.Client;
+import com.netscape.certsrv.ocsp.OCSPClient;
+import com.netscape.cmstools.user.UserCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class UserRemoveCLI extends CLI {
+public class OCSPCLI extends SubsystemCLI {
 
-    public UserCLI parent;
+    public OCSPClient ocspClient;
 
-    public UserRemoveCLI(UserCLI parent) {
-        super("del", "Remove user");
-        this.parent = parent;
-    }
+    public OCSPCLI(MainCLI mainCLI) {
+        super("ocsp", "OCSP management commands", mainCLI);
 
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID>", options);
+        addModule(new UserCLI(this));
     }
 
-    public void execute(String[] args) throws Exception {
-
-        if (args.length != 1) {
-            printHelp();
-            System.exit(1);
-        }
+    public void init() throws Exception {
+        client = mainCLI.client;
+        ocspClient = new OCSPClient(client);
+    }
 
-        String userID = args[0];
+    public void login() {
+        ocspClient.login();
+    }
 
-        parent.client.removeUser(userID);
+    public void logout() {
+        ocspClient.logout();
+    }
 
-        MainCLI.printMessage("Deleted user \"" + userID + "\"");
+    public Client getClient(String name) {
+        return ocspClient.getClient(name);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/TKSCLI.java
similarity index 53%
copy from base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
copy to base/java-tools/src/com/netscape/cmstools/cli/TKSCLI.java
index e7a9ad5d178a569e917d703600118912b7edb2e2..bc338cc94a07767840976920b6797ffae2535025 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/TKSCLI.java
@@ -12,42 +12,43 @@
 // with this program; if not, write to the Free Software Foundation, Inc.,
 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 //
-// (C) 2012 Red Hat, Inc.
+// (C) 2013 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cmstools.user;
+package com.netscape.cmstools.cli;
 
-import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
+import com.netscape.certsrv.client.Client;
+import com.netscape.certsrv.tks.TKSClient;
+import com.netscape.cmstools.user.UserCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class UserRemoveCLI extends CLI {
+public class TKSCLI extends SubsystemCLI {
 
-    public UserCLI parent;
+    public TKSClient tksClient;
 
-    public UserRemoveCLI(UserCLI parent) {
-        super("del", "Remove user");
-        this.parent = parent;
-    }
+    public TKSCLI(MainCLI mainCLI) {
+        super("tks", "TKS management commands", mainCLI);
 
-    public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID>", options);
+        addModule(new UserCLI(this));
     }
 
-    public void execute(String[] args) throws Exception {
-
-        if (args.length != 1) {
-            printHelp();
-            System.exit(1);
-        }
+    public void init() throws Exception {
+        client = mainCLI.client;
+        tksClient = new TKSClient(client);
+    }
 
-        String userID = args[0];
+    public void login() {
+        tksClient.login();
+    }
 
-        parent.client.removeUser(userID);
+    public void logout() {
+        tksClient.logout();
+    }
 
-        MainCLI.printMessage("Deleted user \"" + userID + "\"");
+    public Client getClient(String name) {
+        return tksClient.getClient(name);
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserAddCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserAddCLI.java
index 3db8fe5332713e45a936453bf89b8340e8e32a27..33a6786e7ffdd91835782747c5b365e21a30a4fe 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserAddCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserAddCLI.java
@@ -30,15 +30,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserAddCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserAddCLI(UserCLI parent) {
-        super("add", "Add user");
-        this.parent = parent;
+    public UserAddCLI(UserCLI userCLI) {
+        super("add", "Add user", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
+        formatter.printHelp(getFullName() + " <User ID> [OPTIONS...]", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -97,7 +97,7 @@ public class UserAddCLI extends CLI {
         userData.setType(cmd.getOptionValue("type"));
         userData.setState(cmd.getOptionValue("state"));
 
-        userData = parent.client.addUser(userData);
+        userData = userCLI.userClient.addUser(userData);
 
         MainCLI.printMessage("Added user \"" + userId + "\"");
 
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..e3271c022a355a4002601d8af953ea52c7970d7a 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserAddCertCLI.java
@@ -33,15 +33,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserAddCertCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserAddCertCLI(UserCLI parent) {
-        super("add-cert", "Add user cert");
-        this.parent = parent;
+    public UserAddCertCLI(UserCLI userCLI) {
+        super("add-cert", "Add user cert", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
+        formatter.printHelp(getFullName() + " <User ID> [OPTIONS...]", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -88,7 +88,7 @@ public class UserAddCertCLI extends CLI {
             System.out.println(userCertData);
         }
 
-        userCertData = parent.client.addUserCert(userId, userCertData);
+        userCertData = userCLI.userClient.addUserCert(userId, userCertData);
 
         MainCLI.printMessage("Added certificate \"" + userCertData.getID() + "\"");
 
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..ab8e61fe185397db7fb2e8546c58d0e21fe1130d 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserAddMembershipCLI.java
@@ -27,15 +27,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserAddMembershipCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserAddMembershipCLI(UserCLI parent) {
-        super("add-membership", "Add user membership");
-        this.parent = parent;
+    public UserAddMembershipCLI(UserCLI userCLI) {
+        super("add-membership", "Add user membership", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> <Group ID>", options);
+        formatter.printHelp(getFullName() + " <User ID> <Group ID>", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -48,7 +48,7 @@ public class UserAddMembershipCLI extends CLI {
         String userID = args[0];
         String groupID = args[1];
 
-        UserMembershipData userMembershipData = parent.client.addUserMembership(userID, groupID);
+        UserMembershipData userMembershipData = userCLI.userClient.addUserMembership(userID, groupID);
 
         MainCLI.printMessage("Added membership in \""+groupID+"\"");
 
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..7f429abcfa7fcbd54e013b655bbe63a92851d97f 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
@@ -28,19 +28,17 @@ import com.netscape.certsrv.user.UserClient;
 import com.netscape.certsrv.user.UserData;
 import com.netscape.certsrv.user.UserMembershipData;
 import com.netscape.cmstools.cli.CLI;
-import com.netscape.cmstools.cli.MainCLI;
+import com.netscape.cmstools.cli.SubsystemCLI;
 
 /**
  * @author Endi S. Dewata
  */
 public class UserCLI extends CLI {
 
-    public MainCLI parent;
-    public UserClient client;
+    public UserClient userClient;
 
-    public UserCLI(MainCLI parent) {
-        super("user", "User management commands");
-        this.parent = parent;
+    public UserCLI(SubsystemCLI subsystemCLI) {
+        super("user", "User management commands", subsystemCLI);
 
         addModule(new UserFindCLI(this));
         addModule(new UserShowCLI(this));
@@ -58,30 +56,10 @@ public class UserCLI extends CLI {
         addModule(new UserRemoveMembershipCLI(this));
     }
 
-    public void printHelp() {
-
-        System.out.println("Commands:");
-
-        int leftPadding = 1;
-        int rightPadding = 25;
-
-        for (CLI module : modules.values()) {
-            String label = name + "-" + module.getName();
-
-            int padding = rightPadding - leftPadding - label.length();
-            if (padding < 1)
-                padding = 1;
-
-            System.out.print(StringUtils.repeat(" ", leftPadding));
-            System.out.print(label);
-            System.out.print(StringUtils.repeat(" ", padding));
-            System.out.println(module.getDescription());
-        }
-    }
-
     public void execute(String[] args) throws Exception {
 
-        client = new UserClient(parent.client);
+        client = parent.client;
+        userClient = (UserClient)parent.getClient("user");
 
         if (args.length == 0) {
             printHelp();
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java
index 187d4596d91421f1f14e2ca3d772f73e8ef35ceb..4b081920eee32b3a32de72d6221104be620bca14 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java
@@ -33,15 +33,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserFindCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserFindCLI(UserCLI parent) {
-        super("find", "Find users");
-        this.parent = parent;
+    public UserFindCLI(UserCLI userCLI) {
+        super("find", "Find users", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " [FILTER] [OPTIONS...]", options);
+        formatter.printHelp(getFullName() + " [FILTER] [OPTIONS...]", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -74,7 +74,7 @@ public class UserFindCLI extends CLI {
         s = cmd.getOptionValue("size");
         Integer size = s == null ? null : Integer.valueOf(s);
 
-        UserCollection response = parent.client.findUsers(filter, start, size);
+        UserCollection response = userCLI.userClient.findUsers(filter, start, size);
 
         Collection<UserData> entries = response.getUsers();
 
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..15bc4f753f9bf9b98905e074b545af8959aba201 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserFindCertCLI.java
@@ -33,15 +33,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserFindCertCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserFindCertCLI(UserCLI parent) {
-        super("find-cert", "Find user certs");
-        this.parent = parent;
+    public UserFindCertCLI(UserCLI userCLI) {
+        super("find-cert", "Find user certs", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
+        formatter.printHelp(getFullName() + " <User ID> [OPTIONS...]", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -80,7 +80,7 @@ public class UserFindCertCLI extends CLI {
         s = cmd.getOptionValue("size");
         Integer size = s == null ? null : Integer.valueOf(s);
 
-        UserCertCollection response = parent.client.findUserCerts(userID, start, size);
+        UserCertCollection response = userCLI.userClient.findUserCerts(userID, start, size);
 
         Collection<UserCertData> entries = response.getCerts();
 
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..0c41635dd1624e8982eea45d26ee2bedde121b95 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserFindMembershipCLI.java
@@ -33,15 +33,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserFindMembershipCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserFindMembershipCLI(UserCLI parent) {
-        super("find-membership", "Find user memberships");
-        this.parent = parent;
+    public UserFindMembershipCLI(UserCLI userCLI) {
+        super("find-membership", "Find user memberships", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
+        formatter.printHelp(getFullName() + " <User ID> [OPTIONS...]", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -80,7 +80,7 @@ public class UserFindMembershipCLI extends CLI {
         s = cmd.getOptionValue("size");
         Integer size = s == null ? null : Integer.valueOf(s);
 
-        UserMembershipCollection response = parent.client.findUserMemberships(userID, start, size);
+        UserMembershipCollection response = userCLI.userClient.findUserMemberships(userID, start, size);
 
         Collection<UserMembershipData> entries = response.getMemberships();
 
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserModifyCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserModifyCLI.java
index 706224ef9385a9350efff50af528cfdb0c85de61..a09e0fcdfab270e68ff793a6942b851ac01744c7 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserModifyCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserModifyCLI.java
@@ -30,15 +30,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserModifyCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserModifyCLI(UserCLI parent) {
-        super("mod", "Modify user");
-        this.parent = parent;
+    public UserModifyCLI(UserCLI userCLI) {
+        super("mod", "Modify user", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> [OPTIONS...]", options);
+        formatter.printHelp(getFullName() + " <User ID> [OPTIONS...]", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -98,7 +98,7 @@ public class UserModifyCLI extends CLI {
         // userData.setType(cmd.getOptionValue("type"));
         userData.setState(cmd.getOptionValue("state"));
 
-        userData = parent.client.modifyUser(userId, userData);
+        userData = userCLI.userClient.modifyUser(userId, userData);
 
         MainCLI.printMessage("Modified user \"" + userId + "\"");
 
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
index e7a9ad5d178a569e917d703600118912b7edb2e2..b26b4ae8a7b314f3b720e976fff14be3cb513caa 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCLI.java
@@ -26,15 +26,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserRemoveCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserRemoveCLI(UserCLI parent) {
-        super("del", "Remove user");
-        this.parent = parent;
+    public UserRemoveCLI(UserCLI userCLI) {
+        super("del", "Remove user", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID>", options);
+        formatter.printHelp(getFullName() + " <User ID>", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -46,7 +46,7 @@ public class UserRemoveCLI extends CLI {
 
         String userID = args[0];
 
-        parent.client.removeUser(userID);
+        userCLI.userClient.removeUser(userID);
 
         MainCLI.printMessage("Deleted user \"" + userID + "\"");
     }
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..5758c4ccd593226f0f5639f3f121d57939c6735e 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveCertCLI.java
@@ -29,15 +29,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserRemoveCertCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserRemoveCertCLI(UserCLI parent) {
-        super("remove-cert", "Remove user cert");
-        this.parent = parent;
+    public UserRemoveCertCLI(UserCLI userCLI) {
+        super("remove-cert", "Remove user cert", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> <Cert ID>", options);
+        formatter.printHelp(getFullName() + " <User ID> <Cert ID>", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -54,7 +54,7 @@ public class UserRemoveCertCLI extends CLI {
             System.out.println("Removing cert "+certID+" from user "+userID+".");
         }
 
-        parent.client.removeUserCert(userID, URLEncoder.encode(certID, "UTF-8"));
+        userCLI.userClient.removeUserCert(userID, URLEncoder.encode(certID, "UTF-8"));
 
         MainCLI.printMessage("Deleted certificate \"" + certID + "\"");
     }
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..62091efb00b32c7178a8cca9da67bb85a8f00d43 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserRemoveMembershipCLI.java
@@ -26,15 +26,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserRemoveMembershipCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserRemoveMembershipCLI(UserCLI parent) {
-        super("remove-membership", "Remove user membership");
-        this.parent = parent;
+    public UserRemoveMembershipCLI(UserCLI userCLI) {
+        super("remove-membership", "Remove user membership", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> <Group ID>", options);
+        formatter.printHelp(getFullName() + " <User ID> <Group ID>", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -47,7 +47,7 @@ public class UserRemoveMembershipCLI extends CLI {
         String userID = args[0];
         String groupID = args[1];
 
-        parent.client.removeUserMembership(userID, groupID);
+        userCLI.userClient.removeUserMembership(userID, groupID);
 
         MainCLI.printMessage("Deleted membership in group \""+groupID+"\"");
     }
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserShowCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserShowCLI.java
index a04cd6da283a5c5a1f91a2c5caca0f6b7b018526..ce0623e3b893c4fad0b3386967b9d1671654cad5 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserShowCLI.java
@@ -27,15 +27,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserShowCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserShowCLI(UserCLI parent) {
-        super("show", "Show user");
-        this.parent = parent;
+    public UserShowCLI(UserCLI userCLI) {
+        super("show", "Show user", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID>", options);
+        formatter.printHelp(getFullName() + " <User ID>", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -47,7 +47,7 @@ public class UserShowCLI extends CLI {
 
         String userId = args[0];
 
-        UserData userData = parent.client.getUser(userId);
+        UserData userData = userCLI.userClient.getUser(userId);
 
         MainCLI.printMessage("User \"" + userId + "\"");
 
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..87e535f6a93f143d1c1bcf2a4c25bfcf0d09d1ea 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserShowCertCLI.java
@@ -34,15 +34,15 @@ import com.netscape.cmstools.cli.MainCLI;
  */
 public class UserShowCertCLI extends CLI {
 
-    public UserCLI parent;
+    public UserCLI userCLI;
 
-    public UserShowCertCLI(UserCLI parent) {
-        super("show-cert", "Show user cert");
-        this.parent = parent;
+    public UserShowCertCLI(UserCLI userCLI) {
+        super("show-cert", "Show user cert", userCLI);
+        this.userCLI = userCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(parent.name + "-" + name + " <User ID> <Cert ID> [OPTIONS...]", options);
+        formatter.printHelp(getFullName() + " <User ID> <Cert ID> [OPTIONS...]", options);
     }
 
     public void execute(String[] args) throws Exception {
@@ -79,7 +79,7 @@ public class UserShowCertCLI extends CLI {
         String certID = cmdArgs[1];
         String file = cmd.getOptionValue("output");
 
-        UserCertData userCertData = parent.client.getUserCert(userID, URLEncoder.encode(certID, "UTF-8"));
+        UserCertData userCertData = userCLI.userClient.getUserCert(userID, URLEncoder.encode(certID, "UTF-8"));
 
         String encoded = userCertData.getEncoded();
         if (encoded != null && file != null) {
diff --git a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java
index ec277e5dc144ea6ac705a2d68312656b06c42c4f..3b64a28010415f547d6e2488add89278db36bb18 100644
--- a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java
+++ b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java
@@ -43,7 +43,7 @@ import com.netscape.certsrv.key.KeyData;
 import com.netscape.certsrv.key.KeyDataInfo;
 import com.netscape.certsrv.key.KeyRequestInfo;
 import com.netscape.certsrv.key.KeyRequestResource;
-import com.netscape.certsrv.kra.DRMClient;
+import com.netscape.certsrv.kra.KRAClient;
 import com.netscape.certsrv.request.RequestId;
 import com.netscape.certsrv.request.RequestNotFoundException;
 import com.netscape.cms.servlet.base.PKIService;
@@ -195,13 +195,13 @@ public class DRMTest {
         // Set base URI and get client
 
 
-        DRMClient client;
+        KRAClient client;
         try {
             ClientConfig config = new ClientConfig();
             config.setServerURI(protocol + "://" + host + ":" + port + "/kra");
             config.setCertNickname(clientCertNickname);
 
-            client = new DRMClient(config);
+            client = new KRAClient(config);
 
         } catch (Exception e) {
             e.printStackTrace();
-- 
1.8.1.4

