summaryrefslogtreecommitdiffstats
path: root/base/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src')
-rw-r--r--base/common/src/CMakeLists.txt10
-rw-r--r--base/common/src/com/netscape/cms/client/cli/MainCLI.java2
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupAddCLI.java81
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupAddMemberCLI.java57
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupCLI.java118
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupFindCLI.java98
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupFindMemberCLI.java104
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupModifyCLI.java80
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupRemoveCLI.java54
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupRemoveMemberCLI.java54
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupRestClient.java92
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupShowCLI.java53
-rw-r--r--base/common/src/com/netscape/cms/client/group/GroupShowMemberCLI.java54
13 files changed, 857 insertions, 0 deletions
diff --git a/base/common/src/CMakeLists.txt b/base/common/src/CMakeLists.txt
index 42a3a54ed..7b73a8536 100644
--- a/base/common/src/CMakeLists.txt
+++ b/base/common/src/CMakeLists.txt
@@ -459,6 +459,16 @@ set(pki-certsrv_java_SRCS
set(pki-cms_java_SRCS
com/netscape/cms/client/cli/CLI.java
com/netscape/cms/client/cli/MainCLI.java
+ com/netscape/cms/client/group/GroupAddCLI.java
+ com/netscape/cms/client/group/GroupAddMemberCLI.java
+ com/netscape/cms/client/group/GroupFindMemberCLI.java
+ com/netscape/cms/client/group/GroupFindCLI.java
+ com/netscape/cms/client/group/GroupCLI.java
+ com/netscape/cms/client/group/GroupRestClient.java
+ com/netscape/cms/client/group/GroupModifyCLI.java
+ com/netscape/cms/client/group/GroupRemoveCLI.java
+ com/netscape/cms/client/group/GroupRemoveMemberCLI.java
+ com/netscape/cms/client/group/GroupShowCLI.java
com/netscape/cms/client/user/UserAddCertCLI.java
com/netscape/cms/client/user/UserAddCLI.java
com/netscape/cms/client/user/UserCLI.java
diff --git a/base/common/src/com/netscape/cms/client/cli/MainCLI.java b/base/common/src/com/netscape/cms/client/cli/MainCLI.java
index 96e1ea1ee..4932fb183 100644
--- a/base/common/src/com/netscape/cms/client/cli/MainCLI.java
+++ b/base/common/src/com/netscape/cms/client/cli/MainCLI.java
@@ -26,6 +26,7 @@ import org.mozilla.jss.crypto.AlreadyInitializedException;
import org.mozilla.jss.crypto.CryptoToken;
import org.mozilla.jss.util.Password;
+import com.netscape.cms.client.group.GroupCLI;
import com.netscape.cms.client.user.UserCLI;
/**
@@ -48,6 +49,7 @@ public class MainCLI extends CLI {
super("pki", "PKI command-line interface");
addModule(new UserCLI(this));
+ addModule(new GroupCLI(this));
}
public String getProtocol() {
diff --git a/base/common/src/com/netscape/cms/client/group/GroupAddCLI.java b/base/common/src/com/netscape/cms/client/group/GroupAddCLI.java
new file mode 100644
index 000000000..f32fffd5d
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupAddCLI.java
@@ -0,0 +1,81 @@
+// --- 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.cms.client.group;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+
+import com.netscape.certsrv.group.GroupData;
+import com.netscape.cms.client.cli.CLI;
+import com.netscape.cms.client.cli.MainCLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupAddCLI extends CLI {
+
+ public GroupCLI parent;
+
+ public GroupAddCLI(GroupCLI parent) {
+ super("add", "Add group");
+ 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, "description", true, "Description");
+ option.setArgName("description");
+ 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 groupID = cmdArgs[0];
+
+ GroupData groupData = new GroupData();
+ groupData.setID(groupID);
+ groupData.setDescription(cmd.getOptionValue("description"));
+
+ groupData = parent.client.addGroup(groupData);
+
+ MainCLI.printMessage("Added group \""+groupID+"\"");
+
+ GroupCLI.printGroup(groupData);
+ }
+}
diff --git a/base/common/src/com/netscape/cms/client/group/GroupAddMemberCLI.java b/base/common/src/com/netscape/cms/client/group/GroupAddMemberCLI.java
new file mode 100644
index 000000000..965ad4ee9
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupAddMemberCLI.java
@@ -0,0 +1,57 @@
+// --- 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.cms.client.group;
+
+import com.netscape.certsrv.group.GroupMemberData;
+import com.netscape.cms.client.cli.CLI;
+import com.netscape.cms.client.cli.MainCLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupAddMemberCLI extends CLI {
+
+ public GroupCLI parent;
+
+ 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...]", 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);
+ }
+}
diff --git a/base/common/src/com/netscape/cms/client/group/GroupCLI.java b/base/common/src/com/netscape/cms/client/group/GroupCLI.java
new file mode 100644
index 000000000..26e2c7123
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupCLI.java
@@ -0,0 +1,118 @@
+// --- 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.cms.client.group;
+
+import java.util.Arrays;
+
+import org.apache.commons.lang.StringUtils;
+import org.jboss.resteasy.plugins.providers.atom.Link;
+
+import com.netscape.certsrv.group.GroupData;
+import com.netscape.certsrv.group.GroupMemberData;
+import com.netscape.cms.client.cli.CLI;
+import com.netscape.cms.client.cli.MainCLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupCLI extends CLI {
+
+ public MainCLI parent;
+ public GroupRestClient client;
+
+ public GroupCLI(MainCLI parent) {
+ super("group", "Group management commands");
+ this.parent = parent;
+
+ addModule(new GroupFindCLI(this));
+ addModule(new GroupShowCLI(this));
+ addModule(new GroupAddCLI(this));
+ addModule(new GroupModifyCLI(this));
+ addModule(new GroupRemoveCLI(this));
+
+ addModule(new GroupFindMemberCLI(this));
+ addModule(new GroupShowMemberCLI(this));
+ addModule(new GroupAddMemberCLI(this));
+ addModule(new GroupRemoveMemberCLI(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 GroupRestClient(parent.url + "/pki", parent.certNickname);
+
+ String command = args[0];
+ String[] commandArgs = Arrays.copyOfRange(args, 1, args.length);
+
+ if (command == null) {
+ printHelp();
+ System.exit(1);
+ }
+
+ CLI module = getModule(command);
+ if (module != null) {
+ module.execute(commandArgs);
+
+ } else {
+ System.err.println("Error: Invalid command \""+command+"\"");
+ printHelp();
+ System.exit(1);
+ }
+ }
+
+ public static void printGroup(GroupData groupData) {
+ System.out.println(" Group ID: "+groupData.getID());
+
+ String description = groupData.getDescription();
+ if (!StringUtils.isEmpty(description)) System.out.println(" Description: "+description);
+
+ Link link = groupData.getLink();
+ if (verbose && link != null) {
+ System.out.println(" Link: " + link.getHref());
+ }
+ }
+
+ public static void printGroupMember(GroupMemberData groupMemberData) {
+ System.out.println(" Member: "+groupMemberData.getID());
+
+ Link link = groupMemberData.getLink();
+ if (verbose && link != null) {
+ System.out.println(" Link: " + link.getHref());
+ }
+ }
+}
diff --git a/base/common/src/com/netscape/cms/client/group/GroupFindCLI.java b/base/common/src/com/netscape/cms/client/group/GroupFindCLI.java
new file mode 100644
index 000000000..41263c7b9
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupFindCLI.java
@@ -0,0 +1,98 @@
+// --- 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.cms.client.group;
+
+import java.util.Collection;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+
+import com.netscape.certsrv.group.GroupCollection;
+import com.netscape.certsrv.group.GroupData;
+import com.netscape.cms.client.cli.CLI;
+import com.netscape.cms.client.cli.MainCLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupFindCLI extends CLI {
+
+ public GroupCLI parent;
+
+ public GroupFindCLI(GroupCLI parent) {
+ super("find", "Find groups");
+ this.parent = parent;
+ }
+
+ public void printHelp() {
+ formatter.printHelp(parent.name + "-" + name + " [FILTER] [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();
+ String filter = cmdArgs.length > 0 ? cmdArgs[0] : null;
+
+ 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);
+
+ GroupCollection response = parent.client.findGroups(filter, start, size);
+
+ Collection<GroupData> entries = response.getGroups();
+
+ MainCLI.printMessage(entries.size()+" group(s) matched");
+
+ boolean first = true;
+
+ for (GroupData groupData : entries) {
+
+ if (first) {
+ first = false;
+ } else {
+ System.out.println();
+ }
+
+ GroupCLI.printGroup(groupData);
+ }
+
+ MainCLI.printMessage("Number of entries returned "+entries.size());
+ }
+}
diff --git a/base/common/src/com/netscape/cms/client/group/GroupFindMemberCLI.java b/base/common/src/com/netscape/cms/client/group/GroupFindMemberCLI.java
new file mode 100644
index 000000000..ca8273270
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupFindMemberCLI.java
@@ -0,0 +1,104 @@
+// --- 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.cms.client.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.cms.client.cli.CLI;
+import com.netscape.cms.client.cli.MainCLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupFindMemberCLI extends CLI {
+
+ public GroupCLI parent;
+
+ 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());
+ }
+}
diff --git a/base/common/src/com/netscape/cms/client/group/GroupModifyCLI.java b/base/common/src/com/netscape/cms/client/group/GroupModifyCLI.java
new file mode 100644
index 000000000..b2b5c8553
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupModifyCLI.java
@@ -0,0 +1,80 @@
+// --- 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.cms.client.group;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+
+import com.netscape.certsrv.group.GroupData;
+import com.netscape.cms.client.cli.CLI;
+import com.netscape.cms.client.cli.MainCLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupModifyCLI extends CLI {
+
+ public GroupCLI parent;
+
+ public GroupModifyCLI(GroupCLI parent) {
+ super("mod", "Modify group");
+ 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, "description", true, "Description");
+ option.setArgName("description");
+ 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];
+
+ GroupData groupData = new GroupData();
+ groupData.setID(groupID);
+ groupData.setDescription(cmd.getOptionValue("description"));
+
+ groupData = parent.client.modifyGroup(groupID, groupData);
+
+ MainCLI.printMessage("Modified group \""+groupID+"\"");
+
+ GroupCLI.printGroup(groupData);
+ }
+}
diff --git a/base/common/src/com/netscape/cms/client/group/GroupRemoveCLI.java b/base/common/src/com/netscape/cms/client/group/GroupRemoveCLI.java
new file mode 100644
index 000000000..45e779860
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupRemoveCLI.java
@@ -0,0 +1,54 @@
+// --- 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.cms.client.group;
+
+import com.netscape.cms.client.cli.CLI;
+import com.netscape.cms.client.cli.MainCLI;
+
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupRemoveCLI extends CLI {
+
+ public GroupCLI parent;
+
+ public GroupRemoveCLI(GroupCLI parent) {
+ super("del", "Remove group");
+ this.parent = parent;
+ }
+
+ public void printHelp() {
+ formatter.printHelp(parent.name + "-" + name + " <Group ID> [OPTIONS...]", options);
+ }
+
+ public void execute(String[] args) throws Exception {
+
+ if (args.length != 1) {
+ printHelp();
+ System.exit(1);
+ }
+
+ String groupID = args[0];
+
+ parent.client.removeGroup(groupID);
+
+ MainCLI.printMessage("Deleted group \""+groupID+"\"");
+ }
+}
diff --git a/base/common/src/com/netscape/cms/client/group/GroupRemoveMemberCLI.java b/base/common/src/com/netscape/cms/client/group/GroupRemoveMemberCLI.java
new file mode 100644
index 000000000..25807ae31
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupRemoveMemberCLI.java
@@ -0,0 +1,54 @@
+// --- 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.cms.client.group;
+
+import com.netscape.cms.client.cli.CLI;
+import com.netscape.cms.client.cli.MainCLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupRemoveMemberCLI extends CLI {
+
+ public GroupCLI parent;
+
+ 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...]", 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+"\"");
+ }
+}
diff --git a/base/common/src/com/netscape/cms/client/group/GroupRestClient.java b/base/common/src/com/netscape/cms/client/group/GroupRestClient.java
new file mode 100644
index 000000000..c5070a447
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupRestClient.java
@@ -0,0 +1,92 @@
+//--- 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.cms.client.group;
+
+import java.net.URISyntaxException;
+
+import org.jboss.resteasy.client.ClientResponse;
+
+import com.netscape.certsrv.group.GroupCollection;
+import com.netscape.certsrv.group.GroupData;
+import com.netscape.certsrv.group.GroupMemberCollection;
+import com.netscape.certsrv.group.GroupMemberData;
+import com.netscape.certsrv.group.GroupMemberResource;
+import com.netscape.certsrv.group.GroupResource;
+import com.netscape.cms.servlet.csadmin.CMSRestClient;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupRestClient extends CMSRestClient {
+
+ public GroupResource groupClient;
+ public GroupMemberResource groupMemberClient;
+
+ public GroupRestClient(String baseUri) throws URISyntaxException {
+ this(baseUri, null);
+ }
+
+ public GroupRestClient(String baseUri, String nickname) throws URISyntaxException {
+ super(baseUri, nickname);
+
+ groupClient = createProxy(GroupResource.class);
+ groupMemberClient = createProxy(GroupMemberResource.class);
+ }
+
+ public GroupCollection findGroups(String groupIDFilter, Integer start, Integer size) {
+ return groupClient.findGroups(groupIDFilter, start, size);
+ }
+
+ public GroupData getGroup(String groupID) {
+ return groupClient.getGroup(groupID);
+ }
+
+ public GroupData addGroup(GroupData groupData) {
+ @SuppressWarnings("unchecked")
+ ClientResponse<GroupData> response = (ClientResponse<GroupData>)groupClient.addGroup(groupData);
+ return response.getEntity();
+ }
+
+ public GroupData modifyGroup(String groupID, GroupData groupData) {
+ @SuppressWarnings("unchecked")
+ ClientResponse<GroupData> response = (ClientResponse<GroupData>)groupClient.modifyGroup(groupID, groupData);
+ return response.getEntity();
+ }
+
+ public void removeGroup(String groupID) {
+ groupClient.removeGroup(groupID);
+ }
+
+ public GroupMemberCollection findGroupMembers(String groupID, Integer start, Integer size) {
+ return groupMemberClient.findGroupMembers(groupID, start, size);
+ }
+
+ public GroupMemberData getGroupMember(String groupID, String memberID) {
+ return groupMemberClient.getGroupMember(groupID, memberID);
+ }
+
+ public GroupMemberData addGroupMember(String groupID, String memberID) {
+ @SuppressWarnings("unchecked")
+ ClientResponse<GroupMemberData> response = (ClientResponse<GroupMemberData>)groupMemberClient.addGroupMember(groupID, memberID);
+ return response.getEntity();
+ }
+
+ public void removeGroupMember(String groupID, String memberID) {
+ groupMemberClient.removeGroupMember(groupID, memberID);
+ }
+}
diff --git a/base/common/src/com/netscape/cms/client/group/GroupShowCLI.java b/base/common/src/com/netscape/cms/client/group/GroupShowCLI.java
new file mode 100644
index 000000000..59a4a07de
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupShowCLI.java
@@ -0,0 +1,53 @@
+// --- 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.cms.client.group;
+
+import com.netscape.certsrv.group.GroupData;
+import com.netscape.cms.client.cli.CLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupShowCLI extends CLI {
+
+ public GroupCLI parent;
+
+ public GroupShowCLI(GroupCLI parent) {
+ super("show", "Show group");
+ this.parent = parent;
+ }
+
+ public void printHelp() {
+ formatter.printHelp(parent.name + "-" + name + " <Group ID> [OPTIONS...]", options);
+ }
+
+ public void execute(String[] args) throws Exception {
+
+ if (args.length != 1) {
+ printHelp();
+ System.exit(1);
+ }
+
+ String groupID = args[0];
+
+ GroupData groupData = parent.client.getGroup(groupID);
+
+ GroupCLI.printGroup(groupData);
+ }
+}
diff --git a/base/common/src/com/netscape/cms/client/group/GroupShowMemberCLI.java b/base/common/src/com/netscape/cms/client/group/GroupShowMemberCLI.java
new file mode 100644
index 000000000..7490799bd
--- /dev/null
+++ b/base/common/src/com/netscape/cms/client/group/GroupShowMemberCLI.java
@@ -0,0 +1,54 @@
+// --- 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.cms.client.group;
+
+import com.netscape.certsrv.group.GroupMemberData;
+import com.netscape.cms.client.cli.CLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class GroupShowMemberCLI extends CLI {
+
+ public GroupCLI parent;
+
+ 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...]", 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);
+
+ GroupCLI.printGroupMember(groupMemberData);
+ }
+}