KickJava   Java API By Example, From Geeks To Geeks.

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


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.omg.CORBA.ORB JavaDoc;
8
9 /**
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 {
20     public static void main( String JavaDoc args[] )
21     {
22         if( args.length != 1 )
23         {
24             System.out.println( "Usage: java demo.sas.SslClient <ior_file>" );
25             System.exit( 1 );
26         }
27
28         try
29         {
30             File JavaDoc f = new File JavaDoc( args[ 0 ] );
31
32             //check if file exists
33
if( ! f.exists() )
34             {
35                 System.out.println("File " + args[0] + " does not exist.");
36
37                 System.exit( -1 );
38             }
39
40             //check if args[0] points to a directory
41
if( f.isDirectory() )
42             {
43                 System.out.println("File " + args[0] + " is a directory.");
44
45                 System.exit( -1 );
46             }
47
48             // initialize the ORB.
49
ORB JavaDoc orb = ORB.init( args, null );
50
51             BufferedReader JavaDoc br = new BufferedReader JavaDoc( new FileReader JavaDoc( f ));
52
53             // get object reference from command-line argument file
54
org.omg.CORBA.Object JavaDoc obj = orb.string_to_object( br.readLine() );
55             br.close();
56
57             //narrow to right type
58
SASDemo demo = SASDemoHelper.narrow( obj );
59
60             //call single operation
61
demo.printSAS();
62             demo.printSAS();
63             demo.printSAS();
64
65             System.out.println( "Call to server succeeded" );
66         }
67         catch( Exception JavaDoc ex )
68         {
69             ex.printStackTrace();
70         }
71     }
72 }
73
Popular Tags