|
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.types.VoidType; |
|
16 |
| |
|
17 |
| import org.globus.cas.faults.CasFault; |
|
18 |
| |
|
19 |
| import org.globus.wsrf.utils.FaultHelper; |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| public class Whoami { |
|
24 |
| |
|
25 |
| static String msg = |
|
26 |
| " Usage: cas-whomai [<options>] \n" |
|
27 |
| + " Options are -debug Runs with debug trace \n" |
|
28 |
| + " -c <instanceURl> Specify URL for CAS server\n" |
|
29 |
| + " -help Prints this message\n" |
|
30 |
| + " -v Prints version number\n" |
|
31 |
| + " -s Identity of CAS server. If not specified, will \n" |
|
32 |
| + " defualt to host authorization.\n" |
|
33 |
| + " -m security mechanism. 'msg' for secure message\n" |
|
34 |
| + " or 'conv' for secure conversation or 'trans' for\n" |
|
35 |
| + " transport security. If unspecified, if instance\n" |
|
36 |
| + " url is 'https', then trasport security is used \n" |
|
37 |
| + " else mechanism defaults to secure message\n" |
|
38 |
| + " -p protection type, 'sig' signature and 'enc' \n" |
|
39 |
| + " encryption, defaults to signature\n"; |
|
40 |
| |
|
41 |
| static boolean debug = false; |
|
42 |
| |
|
43 |
0
| public static void main(String args[]) throws Exception {
|
|
44 |
| |
|
45 |
0
| if ((args.length == 1) && (args[0].equals("-help"))) {
|
|
46 |
0
| System.out.println(msg);
|
|
47 |
0
| System.exit(0);
|
|
48 |
| } |
|
49 |
| |
|
50 |
0
| CasClientSetup clientSetup = new CasClientSetup(args, msg);
|
|
51 |
0
| String instanceURL = clientSetup.getInstanceURL();
|
|
52 |
0
| String serverIdentity = clientSetup.getServerIdentity();
|
|
53 |
0
| debug = clientSetup.debug;
|
|
54 |
| |
|
55 |
0
| if (debug) {
|
|
56 |
0
| System.out.println("CAS client to return the CAS nickname of "
|
|
57 |
| + " client."); |
|
58 |
| } |
|
59 |
| |
|
60 |
0
| CASPortType casPort =
|
|
61 |
| clientSetup.getCASPort(instanceURL, 0, serverIdentity); |
|
62 |
| |
|
63 |
0
| String userName = null;
|
|
64 |
0
| try {
|
|
65 |
0
| userName = casPort.whoami(new VoidType());
|
|
66 |
| } catch (CasFault casFault) { |
|
67 |
0
| if (!debug) {
|
|
68 |
0
| String desc =
|
|
69 |
| (new FaultHelper(casFault)).getDescriptionAsString(); |
|
70 |
0
| System.err.println(desc);
|
|
71 |
| } else { |
|
72 |
0
| System.err.println((new FaultHelper(casFault))
|
|
73 |
| .getStackTrace()); |
|
74 |
| } |
|
75 |
0
| System.exit(-1);
|
|
76 |
| } catch (Exception exp) { |
|
77 |
0
| if (debug) {
|
|
78 |
0
| System.err.println(exp.toString());
|
|
79 |
| } else { |
|
80 |
0
| System.err.println(CasClientSetup.getErrorMsg(exp));
|
|
81 |
| } |
|
82 |
0
| System.exit(-1);
|
|
83 |
| } |
|
84 |
| |
|
85 |
0
| if (userName == null) {
|
|
86 |
0
| System.out.println("This client does not have a nickname on this"
|
|
87 |
| + " cas server "); |
|
88 |
| } else { |
|
89 |
0
| System.out.println("CAS nickname is " + userName);
|
|
90 |
| } |
|
91 |
| |
|
92 |
0
| System.out.println("Completed successfully");
|
|
93 |
| } |
|
94 |
| } |