KickJava   Java API By Example, From Geeks To Geeks.

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


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: GssUpClient.java,v 1.2 2004/02/05 10:49:54 nick.cross Exp $
17  */

18
19 public class GssUpClient {
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
demo.printSAS();
50             demo.printSAS();
51             demo.printSAS();
52
53             System.out.println("Call to server succeeded");
54         } catch (Exception JavaDoc ex) {
55             ex.printStackTrace();
56         }
57     }
58 }
59
Popular Tags