de.tu_darmstadt.sp.rmi
Class RMISecureSocketFactory

java.lang.Object
  |
  +--java.rmi.server.RMISocketFactory
        |
        +--de.tu_darmstadt.sp.rmi.RMISecureSocketFactory

public class RMISecureSocketFactory
extends java.rmi.server.RMISocketFactory

Class RMISecureSocketFactory creates secures sockets for RMI connections. It uses SSLeaySockets. Additionaly it adds new functionality which enables the RMI client (caller) or server (calee) to find out each other's identities, security parameters of the connection, etc.

Version:
$Revision: 1.3 $
Author:
Andrei Popovici

Field Summary
protected  RMISSLSocketFactory clientFactory
          the factory for client sockets
protected  RMISSLServerSocketFactory serverFactory
          the factory for sever sockets
 
Constructor Summary
RMISecureSocketFactory()
          Create a RMISecureSocketFactory which produces secure sockets obtained from clientFactory and serverFactory.
 
Method Summary
 java.net.ServerSocket createServerSocket(int port)
          Return a Server Socket listening on the specified port.
 java.net.Socket createSocket(java.lang.String host, int port)
          Return a socket connected to the specified host on the given port.
static SSLSocket getClient()
          Return the Socket used by the currnt RMI call.
static java.security.cert.X509Certificate getClientCertificate()
          Return the certificate representing the identity of the peer (client,caller) in the current RMI call.
static java.security.cert.X509Certificate[] getClientCertificateChain()
          Return the certificate chain used by the peer(client, caller) in the current RMI call.
static SSLSocket getServer()
          Return the Socket used by the last RMI call in the current thread.
static java.security.cert.X509Certificate getServerCertificate()
          Return the certificate representing the identity of the peer in the last RMI call of the current thread.
static java.security.cert.X509Certificate[] getServerCertificateChain()
          Return the certificate chain used by the peer in the last RMI call of the current thread.
 
Methods inherited from class java.rmi.server.RMISocketFactory
getDefaultSocketFactory, getFailureHandler, getSocketFactory, setFailureHandler, setSocketFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clientFactory

protected RMISSLSocketFactory clientFactory
the factory for client sockets

serverFactory

protected RMISSLServerSocketFactory serverFactory
the factory for sever sockets
Constructor Detail

RMISecureSocketFactory

public RMISecureSocketFactory()
Create a RMISecureSocketFactory which produces secure sockets obtained from clientFactory and serverFactory. The the default initialisation for the two factories is RMISSLSocketFactory, respectively RMISSLSeverSocketFactory.

If you want to use other socket types than those produced by the default factories, you have to subclass this class and respecify clientFactory and severFactory in the subclasse's constructors.

Method Detail

createServerSocket

public java.net.ServerSocket createServerSocket(int port)
                                         throws java.io.IOException
Return a Server Socket listening on the specified port. This factory returns RMISSLServerSocket objects. This may change in subclasses.
Overrides:
createServerSocket in class java.rmi.server.RMISocketFactory

createSocket

public java.net.Socket createSocket(java.lang.String host,
                                    int port)
                             throws java.io.IOException
Return a socket connected to the specified host on the given port. This factory returns SSLeaySocket objects. This may change in subclasses.
Overrides:
createSocket in class java.rmi.server.RMISocketFactory

getServer

public static SSLSocket getServer()
Return the Socket used by the last RMI call in the current thread. It is the socket used for the connection to the server.

getServerCertificateChain

public static java.security.cert.X509Certificate[] getServerCertificateChain()
                                                                      throws SSLPeerUnverifiedException
Return the certificate chain used by the peer in the last RMI call of the current thread. The first certificate is the identity of the peer.

This method is just "syntactic sugar" since the same information can be obtained from the socket returned by getServer.


getServerCertificate

public static java.security.cert.X509Certificate getServerCertificate()
                                                               throws SSLPeerUnverifiedException
Return the certificate representing the identity of the peer in the last RMI call of the current thread.

This method is just "syntactic sugar" since the same information can be obtained from the socket returned by fetRemoteCallSocket.


getClient

public static SSLSocket getClient()
Return the Socket used by the currnt RMI call. It is the socket used for the connection to the client.

getClientCertificateChain

public static java.security.cert.X509Certificate[] getClientCertificateChain()
                                                                      throws SSLPeerUnverifiedException
Return the certificate chain used by the peer(client, caller) in the current RMI call. The first certificate is the identity of the peer.

This method is just "syntactic sugar" since the same information can be obtained from the socket returned by getClient.


getClientCertificate

public static java.security.cert.X509Certificate getClientCertificate()
                                                               throws SSLPeerUnverifiedException
Return the certificate representing the identity of the peer (client,caller) in the current RMI call.

This method is just "syntactic sugar" since the same information can be obtained from the socket returned by getClient.