KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > ssl > Client


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