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.omg.CORBA.ORB;
08:
09: /**
10: * This is the client side of the sas demo. It just calls the single
11: * operation "printCert()" of the server. As you can see, sas is fully
12: * transparent.
13: *
14: * @author Nicolas Noffke
15: * @version $Id: SslClient.java,v 1.2 2004/02/05 10:49:54 nick.cross Exp $
16: */
17:
18: public class SslClient {
19: public static void main(String args[]) {
20: if (args.length != 1) {
21: System.out
22: .println("Usage: java demo.sas.SslClient <ior_file>");
23: System.exit(1);
24: }
25:
26: try {
27: File f = new File(args[0]);
28:
29: //check if file exists
30: if (!f.exists()) {
31: System.out.println("File " + args[0]
32: + " does not exist.");
33:
34: System.exit(-1);
35: }
36:
37: //check if args[0] points to a directory
38: if (f.isDirectory()) {
39: System.out.println("File " + args[0]
40: + " is a directory.");
41:
42: System.exit(-1);
43: }
44:
45: // initialize the ORB.
46: ORB orb = ORB.init(args, null);
47:
48: BufferedReader br = new BufferedReader(new FileReader(f));
49:
50: // get object reference from command-line argument file
51: org.omg.CORBA.Object obj = orb.string_to_object(br
52: .readLine());
53: br.close();
54:
55: //narrow to right type
56: SASDemo demo = SASDemoHelper.narrow(obj);
57:
58: //call single operation
59: demo.printSAS();
60: demo.printSAS();
61: demo.printSAS();
62:
63: System.out.println("Call to server succeeded");
64: } catch (Exception ex) {
65: ex.printStackTrace();
66: }
67: }
68: }
|