01: package org.jacorb.demo.sas;
02:
03: import java.io.BufferedReader;
04: import java.io.File;
05: import java.io.FileReader;
06:
07: import org.jacorb.security.sas.GssUpContext;
08: import org.omg.CORBA.ORB;
09:
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 args[]) {
21: if (args.length != 3) {
22: System.out
23: .println("Usage: java demo.sas.GssUpClient <ior_file> <username> <password>");
24: System.exit(1);
25: }
26:
27: try {
28: // set security credentials
29: GssUpContext.setUsernamePassword(args[1], args[2]);
30:
31: // initialize the ORB.
32: ORB orb = ORB.init(args, null);
33:
34: // get the server
35: File f = new File(args[0]);
36: if (!f.exists()) {
37: System.out.println("File " + args[0]
38: + " does not exist.");
39: System.exit(-1);
40: }
41: if (f.isDirectory()) {
42: System.out.println("File " + args[0]
43: + " is a directory.");
44: System.exit(-1);
45: }
46: BufferedReader br = new BufferedReader(new FileReader(f));
47: org.omg.CORBA.Object obj = orb.string_to_object(br
48: .readLine());
49: br.close();
50: SASDemo demo = SASDemoHelper.narrow(obj);
51:
52: //call single operation
53: demo.printSAS();
54: demo.printSAS();
55: demo.printSAS();
56:
57: System.out.println("Call to server succeeded");
58: } catch (Exception ex) {
59: ex.printStackTrace();
60: }
61: }
62: }
|