de.tu_darmstadt.sp.rmi
Class RMISSLSocket

java.lang.Object
  |
  +--java.net.Socket
        |
        +--javax.net.ssl.SSLSocket
              |
              +--de.tu_darmstadt.sp.ssl.SSLeaySocket
                    |
                    +--de.tu_darmstadt.sp.rmi.RMISSLSocket

public class RMISSLSocket
extends SSLeaySocket

Class RMISSLSocket extends the SSLeaySocket and provides an acoounting for all communications thorugh the created sockets: the most recent thread which used a socket is associated to it. Conversely, every thread can find out the last RMISSLSocket it has used using the methods getCurrentServerSideSocket and getCurrentClientSideSocket.

Version:
$Revision: 1.1 $
Author:
Andrei Popovici

Fields inherited from class de.tu_darmstadt.sp.ssl.SSLeaySocket
context, handle
 
Constructor Summary
protected RMISSLSocket(java.net.InetAddress address, int port, java.net.InetAddress clientAddr, int clientPort, SSLeaySessionContext ctx)
          Returns a socket connected to a ServerSocket on the named host, at the given port.
  RMISSLSocket(java.net.InetAddress address, int port, SSLeaySessionContext ctx)
          Constructs a TCP connection to a server at a specified address and port.This (usually) acts as the SSL client, but SSL policy is usually controlled by the corresponding factory.
  RMISSLSocket(SSLeaySessionContext ctx)
          Create an unconnected socket using the client mode.
  RMISSLSocket(java.lang.String host, int port, java.net.InetAddress clientAddr, int clientPort, SSLeaySessionContext ctx)
          Constructs an SSL connection to a named host at a specified port, binding the client side of the connection a given address and port.
  RMISSLSocket(java.lang.String host, int port, SSLeaySessionContext ctx)
          Constructs a TCP connection to a named host at a specified port.
 
Method Summary
static SSLSocket getCurrentClientSideSocket()
          Return the last RMISSLSocketconnetion in the currrent thread.
static SSLSocket getCurrentServerSideSocket()
          Return the last RMISSLSocketconnetion in the currrent thread.
 java.io.InputStream getInputStream()
          Returns an input stream for this socket.
 java.io.OutputStream getOutputStream()
          Returns an output stream for this socket.
 
Methods inherited from class de.tu_darmstadt.sp.ssl.SSLeaySocket
addHandshakeCompletedListener, close, getEnabledCipherSuites, getEnableSessionCreation, getNeedClientAuth, getPeerName, getSession, getSupportedCipherSuites, getUseClientMode, removeHandshakeCompletedListener, setEnabledCipherSuites, setEnableSessionCreation, setNeedClientAuth, setUseClientMode, startHandshake, toString
 
Methods inherited from class java.net.Socket
getInetAddress, getLocalAddress, getLocalPort, getPort, getReceiveBufferSize, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, setReceiveBufferSize, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RMISSLSocket

public RMISSLSocket(SSLeaySessionContext ctx)
Create an unconnected socket using the client mode. Though unconnected, SSL options like preferred ciphers a.o. can be specified.
Parameters:
ctx - the SSLeaySessionContext for the session(s) used by this connection.
Throws:
SSLeayRuntimeException - if no SSLeayHandle could be created

RMISSLSocket

public RMISSLSocket(java.lang.String host,
                    int port,
                    SSLeaySessionContext ctx)
             throws java.net.UnknownHostException,
                    java.io.IOException
Constructs a TCP connection to a named host at a specified port. This (tipically) acts as the SSL client, but SSL policy is usually controlled by the corresponding factory. The constructor does not start the handshake.
Parameters:
host - the host name.
port - the port number.
ctx - the SSLeaySessionContext for the session(s) used by this connection.
Throws:
java.io.IOException - if an I/O error occurs when creating the socket.
SSLeayRuntimeException - if no SSLeayHandle could be created

RMISSLSocket

public RMISSLSocket(java.net.InetAddress address,
                    int port,
                    SSLeaySessionContext ctx)
             throws java.io.IOException
Constructs a TCP connection to a server at a specified address and port.This (usually) acts as the SSL client, but SSL policy is usually controlled by the corresponding factory. The constructor does not start the handshake.
Parameters:
address - the IP address.
port - the port number.
ctx - the SSLeaySessionContext for the session(s) used by this connection.
Throws:
java.io.IOException - if an I/O error occurs when creating the socket.
SSLeayRuntimeException - if no SSLeayHandle could be created

RMISSLSocket

public RMISSLSocket(java.lang.String host,
                    int port,
                    java.net.InetAddress clientAddr,
                    int clientPort,
                    SSLeaySessionContext ctx)
             throws java.io.IOException
Constructs an SSL connection to a named host at a specified port, binding the client side of the connection a given address and port. This typically acts as the SSL client, but SSL policy is usually controlled by the corresponding factory. The constructor does not start the handshake.
Parameters:
host - the name of the remote host
port - the remote port
clientAddr - the local address the socket is bound to
clientPort - the local port the socket is bound to
ctx - the SSLeaySessionContext for the session(s) used by this connection.
Throws:
java.io.IOException - if an I/O error occurs when creating the socket.
SSLeayRuntimeException - if no SSLeayHandle could be created

RMISSLSocket

protected RMISSLSocket(java.net.InetAddress address,
                       int port,
                       java.net.InetAddress clientAddr,
                       int clientPort,
                       SSLeaySessionContext ctx)
                throws java.io.IOException
Returns a socket connected to a ServerSocket on the named host, at the given port. The client address address is the specified host and port. This socket is configured using the socket options established for this factory.
Parameters:
address - the remote address
port - the remote port
clientAddr - the local address the socket is bound to
clientPort - the local port the socket is bound to
ctx - the SSLeaySessionContext for the session(s) used by this connection.
Throws:
java.io.IOException - if an I/O error occurs when creating the socket.
SSLeayRuntimeException - if no SSLeayHandle could be created.
Method Detail

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an input stream for this socket. The input stream uses the underlying SSL session. If there is no SSL session, a startHandshake will be performed.

Additionaly, this method associates the current thread to this socket.

Returns:
an input stream for reading bytes from this socket
Throws:
java.io.IOException - if an I/O error occurs when creating the input stream or the underlying SSLHandle is not properly initialized and connected.
Overrides:
getInputStream in class SSLeaySocket

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Returns an output stream for this socket. The output stream uses the underlying SSL session. If there is no SSL session, a startHandshake will be performed.

Additionaly, this method associates the current thread to this socket.

Returns:
an output stream for writing bytes to this socket
Throws:
java.io.IOException - if an I/O error occurs when creating the output stream or the underlying SSLHandle is not properly initialized and connected.
Overrides:
getOutputStream in class SSLeaySocket

getCurrentServerSideSocket

public static SSLSocket getCurrentServerSideSocket()
Return the last RMISSLSocketconnetion in the currrent thread.

getCurrentClientSideSocket

public static SSLSocket getCurrentClientSideSocket()
Return the last RMISSLSocketconnetion in the currrent thread.