|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| package org.globus.cas.impl.client; |
|
12 |
| |
|
13 |
| import org.globus.cas.CASPortType; |
|
14 |
| |
|
15 |
| import org.globus.cas.impl.CasConstants; |
|
16 |
| |
|
17 |
| import org.globus.cas.types.ManageUserGroups; |
|
18 |
| import org.globus.cas.types.ManageObjectGroups; |
|
19 |
| import org.globus.cas.types.ManageServiceActionGroups; |
|
20 |
| |
|
21 |
| import org.globus.cas.faults.CasFault; |
|
22 |
| import org.globus.cas.faults.NoPermissionFault; |
|
23 |
| |
|
24 |
| import org.globus.wsrf.utils.FaultHelper; |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| public class RemoveGroupEntry { |
|
31 |
| |
|
32 |
| static String msg = |
|
33 |
| " Usage : cas-group-remove-entry [<options>] <groupType> <groupName>\n" |
|
34 |
| + " <memberDetails>\n" |
|
35 |
| + " Options are -debug Runs with debug trace \n" |
|
36 |
| + " -c <instanceURl> Specify URL for CAS server\n" |
|
37 |
| + " -help Prints this message\n" |
|
38 |
| + " -v Prints version number\n" |
|
39 |
| + " -s Identity of CAS server. If not specified, will \n" |
|
40 |
| + " defualt to host authorization.\n" |
|
41 |
| + " -m security mechanism. 'msg' for secure message\n" |
|
42 |
| + " or 'conv' for secure conversation or 'trans' for\n" |
|
43 |
| + " transport security. If unspecified, if instance\n" |
|
44 |
| + " url is 'https', then trasport security is used \n" |
|
45 |
| + " else mechanism defaults to secure message\n" |
|
46 |
| + " -p protection type, 'sig' signature and 'enc' \n" |
|
47 |
| + " encryption, defaults to signature\n" |
|
48 |
| + " <groupType> : Type of group this operation is on. Should be \n" |
|
49 |
| + " \"user\" or \"object\" or \"serviceAction\"\n" |
|
50 |
| + " <groupName> : Name of the group from which member needs to be\n" |
|
51 |
| + " removed\n" |
|
52 |
| + " <memberDetails> : \n" |
|
53 |
| + " If <groupType> is \"user\", <nickname>\n" |
|
54 |
| + " <nickname> : Nickname of user who needs to be removed from\n" |
|
55 |
| + " group\n" |
|
56 |
| + " If <groupType> is \"object\", <objectSpecDesc> <objectSepc>\n" |
|
57 |
| + " <objectSpecDesc> : Type of object. Should be \"object\" \n" |
|
58 |
| + " or \"user\" or \"userGroup\" or \n" |
|
59 |
| + " \"serviceType\" or \"namespace\" or\n" |
|
60 |
| + " \"trustAnchor\" \n" |
|
61 |
| + " <objectSpec> : Data to uniquely identify the CAS Object. \n" |
|
62 |
| + " <objectNamespace> <objectName>, where \n" |
|
63 |
| + " <objectNamespace> is Namespace the object\n" |
|
64 |
| + " belongs to and <objectName> is name of the\n" |
|
65 |
| + " object (or) nickname of the user (or) name\n" |
|
66 |
| + " of user group (or) service type name (or)\n" |
|
67 |
| + " nickname of the namespace or) nickname of\n" |
|
68 |
| + " trust anchor respectively\n" |
|
69 |
| + " If <groupType> is \"serviceAction\", <serviceType> <action>\n" |
|
70 |
| + " This indicates the service/action mapping that needs to \n" |
|
71 |
| + " be removed from the group \n" |
|
72 |
| + " <serviceType> : Name of the service type\n" |
|
73 |
| + " <action> : Name of the action mapped to service type.\n"; |
|
74 |
| |
|
75 |
| static boolean debug = false; |
|
76 |
| |
|
77 |
0
| public static void main(String args[]) throws Exception {
|
|
78 |
| |
|
79 |
0
| if (args.length<1) {
|
|
80 |
0
| System.out.println(msg);
|
|
81 |
0
| System.exit(0);
|
|
82 |
| } |
|
83 |
| |
|
84 |
0
| CasClientSetup clientSetup = new CasClientSetup(args, msg);
|
|
85 |
0
| String instanceURL = clientSetup.getInstanceURL();
|
|
86 |
0
| String serverIdentity = clientSetup.getServerIdentity();
|
|
87 |
0
| int startIndex = clientSetup.argsStartIndex;
|
|
88 |
0
| debug = clientSetup.debug;
|
|
89 |
| |
|
90 |
0
| printMessage("CAS client to remove a member from a group.");
|
|
91 |
| |
|
92 |
0
| if (args.length < startIndex + 2) {
|
|
93 |
0
| System.err.println("Not enough parameters");
|
|
94 |
0
| System.err.println(msg);
|
|
95 |
0
| System.exit(-1);
|
|
96 |
| } |
|
97 |
| |
|
98 |
0
| String objectType = args[startIndex];
|
|
99 |
| |
|
100 |
0
| try {
|
|
101 |
0
| if (objectType.equals(CasConstants.USER_SPEC)) {
|
|
102 |
0
| CASPortType casPort =
|
|
103 |
| clientSetup.getCASPort(instanceURL, 3, serverIdentity); |
|
104 |
0
| printMessage("User group " + args[startIndex+1] + " "
|
|
105 |
| + args[startIndex+2]); |
|
106 |
0
| ManageUserGroups mngUserGps =
|
|
107 |
| new ManageUserGroups(); |
|
108 |
0
| mngUserGps.setRequestType(CasConstants.REMOVE_OPERATION);
|
|
109 |
0
| mngUserGps.setGroupName(args[startIndex+1]);
|
|
110 |
0
| mngUserGps.setUserNickname(args[startIndex+2]);
|
|
111 |
0
| casPort.manageUserGroups(mngUserGps);
|
|
112 |
0
| } else if (objectType.equals(CasConstants.OBJECT_SPEC)) {
|
|
113 |
0
| CASPortType casPort =
|
|
114 |
| clientSetup.getCASPort(instanceURL, 4, serverIdentity); |
|
115 |
| |
|
116 |
0
| printMessage("Object group " + args[startIndex+1] + " "
|
|
117 |
| + args[startIndex+3] + " " + args[startIndex+2]); |
|
118 |
0
| String objectDesc = args[startIndex+3];
|
|
119 |
| |
|
120 |
| |
|
121 |
0
| if (args[startIndex+2].equals(CasConstants.OBJECT_SPEC)) {
|
|
122 |
0
| printMessage("Group type is object group");
|
|
123 |
0
| clientSetup.checkParameters(5);
|
|
124 |
0
| objectDesc = args[startIndex+3]
|
|
125 |
| + CasConstants.OBJECTSPEC_DELIMITER |
|
126 |
| + args[startIndex+4]; |
|
127 |
| } |
|
128 |
0
| ManageObjectGroups objGps =
|
|
129 |
| new ManageObjectGroups(); |
|
130 |
0
| objGps.setRequestType(CasConstants.REMOVE_OPERATION);
|
|
131 |
0
| objGps.setGroupName(args[startIndex+1]);
|
|
132 |
0
| objGps.setObjectSpec(objectDesc);
|
|
133 |
0
| objGps.setObjectSpecDesc(args[startIndex+2]);
|
|
134 |
0
| casPort.manageObjectGroups(objGps);
|
|
135 |
0
| } else if (objectType.equals(CasConstants.SERVICEACTION_SPEC)) {
|
|
136 |
0
| CASPortType casPort =
|
|
137 |
| clientSetup.getCASPort(instanceURL, 4, serverIdentity); |
|
138 |
0
| printMessage("Service Action group " + args[startIndex+1]
|
|
139 |
| + " " + args[startIndex+2] + " " |
|
140 |
| + args[startIndex+3]); |
|
141 |
0
| ManageServiceActionGroups mngServiceAction =
|
|
142 |
| new ManageServiceActionGroups(); |
|
143 |
0
| mngServiceAction.setRequestType(CasConstants.REMOVE_OPERATION);
|
|
144 |
0
| mngServiceAction.setGroupName(args[startIndex+1]);
|
|
145 |
0
| mngServiceAction.setServiceTypeName(args[startIndex+2]);
|
|
146 |
0
| mngServiceAction.setActionName(args[startIndex+3]);
|
|
147 |
0
| casPort.manageServiceActionGroups(mngServiceAction);
|
|
148 |
| } else { |
|
149 |
0
| System.err.println("Erroneous object type " + objectType);
|
|
150 |
0
| System.err.println(msg);
|
|
151 |
0
| System.exit(-1);
|
|
152 |
| } |
|
153 |
| } catch (NoPermissionFault noPermFault) { |
|
154 |
0
| System.err.println(noPermFault.getDescription());
|
|
155 |
0
| System.exit(-1);
|
|
156 |
| } catch (CasFault casFault) { |
|
157 |
0
| if (!debug) {
|
|
158 |
0
| String desc =
|
|
159 |
| (new FaultHelper(casFault)).getDescriptionAsString(); |
|
160 |
0
| System.err.println(desc);
|
|
161 |
| } else { |
|
162 |
0
| System.err.println((new FaultHelper(casFault))
|
|
163 |
| .getStackTrace()); |
|
164 |
| } |
|
165 |
0
| System.exit(-1);
|
|
166 |
| } catch (Exception exp) { |
|
167 |
0
| if (debug) {
|
|
168 |
0
| System.err.println(exp.toString());
|
|
169 |
| } else { |
|
170 |
0
| System.err.println(CasClientSetup.getErrorMsg(exp));
|
|
171 |
| } |
|
172 |
0
| System.exit(-1);
|
|
173 |
| } |
|
174 |
0
| System.out.println("Completed successfully");
|
|
175 |
| } |
|
176 |
| |
|
177 |
0
| private static void printMessage(String msg) {
|
|
178 |
0
| if (debug) {
|
|
179 |
0
| System.out.println(msg);
|
|
180 |
| } |
|
181 |
| } |
|
182 |
| } |