FileDocCategorySizeDatePackage
SSLHelloImpl.javaAPI DocExample2137Wed Apr 19 11:20:18 BST 2000None

SSLHelloImpl

public class SSLHelloImpl extends UnicastRemoteObject implements Hello
Copyright (c) 1996, 1997, 1998, 1999 Phaos Technology Corp. All rights reserved.

Fields Summary
private String
name
Constructors Summary
public SSLHelloImpl(SSLServerSocketFactory ssf, String s)


      /* pass a client ssl socketfactory and a server ssl socket
       * factory to allow secure rmi communication.  
       *
       * SSLClientSocketFactory is downloaded to client transparently.  
       */
      super(0, new SSLClientSocketFactory(), ssf);
      
      name = s;
  
Methods Summary
public static voidmain(java.lang.String[] args)

    try {
	// initialize server certificate
	SSLCertificate cert = new SSLCertificate();
	cert.certificateList = new Vector();
	cert.certificateList.addElement(new X509(new File("server-cert.der")));
	cert.certificateList.addElement(new X509(new File("ca-cert.der")));

	// initialize SSL context object
	SSLParams params = new SSLParams();
	params.setServerCert(cert);

	// require client authentication
	params.setRequestClientCert(true);

	System.setSecurityManager(new RMISecurityManager());
	
	// secure server socket factory to use in remote objects
	SSLServerSocketFactory ssf = new SSLServerSocketFactory(params);

	// create a secure rmiregistry
	Registry registry = LocateRegistry.createRegistry(1099,
			   new SSLClientSocketFactory(), ssf);

	// create a remote object that will use a secure client/server socket pair
	SSLHelloImpl o = new 
	    SSLHelloImpl(ssf, "HelloServer");

	registry.rebind("/HelloServer", o);
	System.out.println("HelloServer bound in registry");

      } catch (Exception e) {
	  System.err.println(e.getMessage());
	  e.printStackTrace();
      }
  
public java.lang.StringsayHello()

    return "SSL Hello World!";