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