|
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.wsrf.utils.FaultHelper; |
|
18 |
| |
|
19 |
| import org.globus.cas.types.ManageServiceAction; |
|
20 |
| |
|
21 |
| import org.globus.cas.faults.CasFault; |
|
22 |
| import org.globus.cas.faults.NoPermissionFault; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| public class ActionMappingHandler { |
|
28 |
| |
|
29 |
| static String msg = |
|
30 |
| "Usage: cas-action [<options>] <operationType> <serviceTypeName> \n" |
|
31 |
| + " <actionName> \n" |
|
32 |
| + " Options are -debug Runs with debug trace \n" |
|
33 |
| + " -c <instanceURl> Specify URL for CAS server\n" |
|
34 |
| + " -help Prints this message\n" |
|
35 |
| + " -v Prints version number\n" |
|
36 |
| + " -s Identity of CAS server. If not specified, will \n" |
|
37 |
| + " defualt to host authorization.\n" |
|
38 |
| + " -m security mechanism. 'msg' for secure message\n" |
|
39 |
| + " or 'conv' for secure conversation or 'trans' for\n" |
|
40 |
| + " transport security. If unspecified, if instance\n" |
|
41 |
| + " url is 'https', then trasport security is used \n" |
|
42 |
| + " else mechanism defaults to secure message\n" |
|
43 |
| + " -p protection type, 'sig' signature and 'enc' \n" |
|
44 |
| + " encryption, defaults to signature\n" |
|
45 |
| + " <operationType> : indicates the type of operation that needs to\n" |
|
46 |
| + " be done. Should be \"add\" or \"remove\" \n" |
|
47 |
| + " <serviceTypeName> : name of the service type on which the action\n" |
|
48 |
| + " mapping needs to be or removed \n " |
|
49 |
| + " <actionName> : should be the name of the action "; |
|
50 |
| |
|
51 |
| static boolean debug = false; |
|
52 |
| |
|
53 |
0
| public static void main(String args[]) throws Exception {
|
|
54 |
| |
|
55 |
0
| if (args.length<1) {
|
|
56 |
0
| System.out.println(msg);
|
|
57 |
0
| System.exit(0);
|
|
58 |
| } |
|
59 |
| |
|
60 |
0
| CasClientSetup clientSetup = new CasClientSetup(args, msg);
|
|
61 |
0
| String instanceURL = clientSetup.getInstanceURL();
|
|
62 |
0
| String serverIdentity = clientSetup.getServerIdentity();
|
|
63 |
0
| int startIndex = clientSetup.argsStartIndex;
|
|
64 |
0
| debug = clientSetup.debug;
|
|
65 |
| |
|
66 |
0
| printMessage("CAS client to add or remove service type/action\n"
|
|
67 |
| + " mappings "); |
|
68 |
| |
|
69 |
0
| if (args.length < startIndex + 2) {
|
|
70 |
0
| System.err.println("Not enough parameters");
|
|
71 |
0
| System.err.println(msg);
|
|
72 |
0
| System.exit(-1);
|
|
73 |
| } |
|
74 |
| |
|
75 |
0
| String operation = args[startIndex];
|
|
76 |
| |
|
77 |
0
| if ((!(operation.equals(CasConstants.ADD_OPERATION))) &&
|
|
78 |
| (!(operation.equals(CasConstants.REMOVE_OPERATION)))) { |
|
79 |
0
| System.err.println("Erroneous operation type " + operation);
|
|
80 |
0
| System.exit(-1);
|
|
81 |
| } |
|
82 |
0
| CASPortType casPort =
|
|
83 |
| clientSetup.getCASPort(instanceURL, 3, serverIdentity); |
|
84 |
0
| printMessage("Parameters " + args[startIndex] + " "
|
|
85 |
| + args[startIndex+1] + " " + args[startIndex+2]); |
|
86 |
0
| try {
|
|
87 |
0
| ManageServiceAction mngService =
|
|
88 |
| new ManageServiceAction(); |
|
89 |
0
| mngService.setRequestType(args[startIndex]);
|
|
90 |
0
| mngService.setServiceTypeName(args[startIndex+1]);
|
|
91 |
0
| mngService.setActionName(args[startIndex+2]);
|
|
92 |
0
| casPort.manageServiceAction(mngService);
|
|
93 |
| } catch (NoPermissionFault noPermFault) { |
|
94 |
0
| System.err.println(noPermFault.getDescription());
|
|
95 |
0
| System.exit(-1);
|
|
96 |
| } catch (CasFault casFault) { |
|
97 |
0
| if (!debug) {
|
|
98 |
0
| String desc =
|
|
99 |
| (new FaultHelper(casFault)).getDescriptionAsString(); |
|
100 |
0
| System.err.println(desc);
|
|
101 |
| } else { |
|
102 |
0
| System.err.println((new FaultHelper(casFault))
|
|
103 |
| .getStackTrace()); |
|
104 |
| } |
|
105 |
0
| System.exit(-1);
|
|
106 |
| } catch (Exception exp) { |
|
107 |
0
| exp.printStackTrace();
|
|
108 |
0
| if (debug) {
|
|
109 |
0
| System.err.println(exp);
|
|
110 |
| } else { |
|
111 |
0
| System.err.println(CasClientSetup.getErrorMsg(exp));
|
|
112 |
| } |
|
113 |
0
| System.exit(-1);
|
|
114 |
| } |
|
115 |
0
| System.out.println("Completed successfully");
|
|
116 |
| } |
|
117 |
| |
|
118 |
0
| private static void printMessage(String msg) {
|
|
119 |
0
| if (debug) {
|
|
120 |
0
| System.out.println(msg);
|
|
121 |
| } |
|
122 |
| } |
|
123 |
| } |