KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > demo > sas > ListGssUpClient


1 package org.jacorb.demo.sas;
2
3 import java.io.BufferedReader JavaDoc;
4 import java.io.File JavaDoc;
5 import java.io.FileReader JavaDoc;
6
7 import org.jacorb.security.sas.GssUpContext;
8 import org.omg.CORBA.ORB JavaDoc;
9
10 /**
11  * This is the client side of the sas demo. It just calls the single
12  * operation "printCert()" of the server. As you can see, sas is fully
13  * transparent.
14  *
15  * @author Nicolas Noffke
16  * @version $Id: ListGssUpClient.java,v 1.1 2004/05/05 13:37:10 david.robison Exp $
17  */

18
19 public class ListGssUpClient {
20     public static void main(String JavaDoc args[]) {
21         if (args.length != 3) {
22             System.out.println("Usage: java demo.sas.GssUpClient <ior_file> <username> <password>");
23             System.exit(1);
24         }
25
26         try {
27             // set security credentials
28
GssUpContext.setUsernamePassword(args[1], args[2]);
29
30             // initialize the ORB.
31
ORB JavaDoc orb = ORB.init(args, null);
32
33             // get the server
34
File JavaDoc f = new File JavaDoc(args[0]);
35             if (!f.exists()) {
36                 System.out.println("File " + args[0] + " does not exist.");
37                 System.exit(-1);
38             }
39             if (f.isDirectory()) {
40                 System.out.println("File " + args[0] + " is a directory.");
41                 System.exit(-1);
42             }
43             BufferedReader JavaDoc br = new BufferedReader JavaDoc(new FileReader JavaDoc(f));
44             org.omg.CORBA.Object JavaDoc obj = orb.string_to_object(br.readLine());
45             br.close();
46             SASDemo demo = SASDemoHelper.narrow(obj);
47
48             //call single operation
49

50             try {
51                demo.printSAS();
52             }
53             catch (org.omg.CORBA.NO_PERMISSION JavaDoc e)
54             {
55                 System.err.println("Login Failed!");
56
57                 // Change to correct user/password
58
GssUpContext.setUsernamePassword("jay", "test");
59                 try {
60                    demo.printSAS();
61                 }
62                 catch (org.omg.CORBA.NO_PERMISSION JavaDoc ex)
63                 {
64                     System.err.println("Failed again!");
65                 }
66             }
67
68             System.out.println("Call to server completed");
69         } catch (Exception JavaDoc ex) {
70             ex.printStackTrace();
71         }
72     }
73 }
74
Popular Tags