edu.emory.mathcs.util.net.ssl
Class SSLSocketWrapper

java.lang.Object
  extended byjava.net.Socket
      extended byjavax.net.ssl.SSLSocket
          extended byedu.emory.mathcs.util.net.ssl.SSLSocketWrapper

public class SSLSocketWrapper
extends javax.net.ssl.SSLSocket

Wrapper for sockets which enables to add functionality in subclasses on top of existing, connected SSL sockets. It is useful when direct subclassing of delegate SSL socket class is not possible, e.g. if the delegate socket is created by a library. Possible usage example is socket factory chaining. This class delegates all socket-related requests to the wrapped delegate, as of JDK 1.4.

Version:
1.4
Author:
Dawid Kurzyniec

Field Summary
protected  javax.net.ssl.SSLSocket delegate
          the wrapped delegate socket.
 
Constructor Summary
protected SSLSocketWrapper(javax.net.ssl.SSLSocket delegate)
          Creates new socket wrapper for a given SSL socket.
 
Method Summary
 void addHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener handshakeCompletedListener)
           
 void bind(java.net.SocketAddress bindpoint)
           
 void close()
           
 void connect(java.net.SocketAddress endpoint)
           
 void connect(java.net.SocketAddress endpoint, int timeout)
           
 boolean equals(java.lang.Object obj)
           
 java.nio.channels.SocketChannel getChannel()
           
 java.lang.String[] getEnabledCipherSuites()
           
 java.lang.String[] getEnabledProtocols()
           
 boolean getEnableSessionCreation()
           
 java.net.InetAddress getInetAddress()
           
 java.io.InputStream getInputStream()
           
 boolean getKeepAlive()
           
 java.net.InetAddress getLocalAddress()
           
 int getLocalPort()
           
 java.net.SocketAddress getLocalSocketAddress()
           
 boolean getNeedClientAuth()
           
 boolean getOOBInline()
           
 java.io.OutputStream getOutputStream()
           
 int getPort()
           
 int getReceiveBufferSize()
           
 java.net.SocketAddress getRemoteSocketAddress()
           
 boolean getReuseAddress()
           
 int getSendBufferSize()
           
 javax.net.ssl.SSLSession getSession()
           
 int getSoLinger()
           
 int getSoTimeout()
           
 java.lang.String[] getSupportedCipherSuites()
           
 java.lang.String[] getSupportedProtocols()
           
 boolean getTcpNoDelay()
           
 int getTrafficClass()
           
 boolean getUseClientMode()
           
 boolean getWantClientAuth()
           
 int hashCode()
           
 boolean isBound()
          Returns true, indicating that the socket is bound.
 boolean isClosed()
           
 boolean isConnected()
          Returns true, indicating that the socket is connected.
 boolean isInputShutdown()
           
 boolean isOutputShutdown()
           
 void removeHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener handshakeCompletedListener)
           
 void sendUrgentData(int data)
           
 void setEnabledCipherSuites(java.lang.String[] suites)
           
 void setEnabledProtocols(java.lang.String[] protocols)
           
 void setEnableSessionCreation(boolean enable)
           
 void setKeepAlive(boolean on)
           
 void setNeedClientAuth(boolean need)
           
 void setOOBInline(boolean on)
           
 void setReceiveBufferSize(int size)
           
 void setReuseAddress(boolean on)
           
 void setSendBufferSize(int size)
           
 void setSoLinger(boolean on, int linger)
           
 void setSoTimeout(int timeout)
           
 void setTcpNoDelay(boolean on)
           
 void setTrafficClass(int tc)
           
 void setUseClientMode(boolean mode)
           
 void setWantClientAuth(boolean want)
           
 void shutdownInput()
           
 void shutdownOutput()
           
 void startHandshake()
           
 
Methods inherited from class java.net.Socket
setSocketImplFactory, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

delegate

protected final javax.net.ssl.SSLSocket delegate
the wrapped delegate socket.

Constructor Detail

SSLSocketWrapper

protected SSLSocketWrapper(javax.net.ssl.SSLSocket delegate)
                    throws java.net.SocketException
Creates new socket wrapper for a given SSL socket. The delegate must be connected and bound and it must not be closed.

Parameters:
delegate - the delegate SSL socket to wrap.
Throws:
java.net.SocketException - if the delegate socket is closed, not bound, or not connected.
Method Detail

connect

public void connect(java.net.SocketAddress endpoint)
             throws java.io.IOException
Throws:
java.io.IOException

connect

public void connect(java.net.SocketAddress endpoint,
                    int timeout)
             throws java.io.IOException
Throws:
java.io.IOException

bind

public void bind(java.net.SocketAddress bindpoint)
          throws java.io.IOException
Throws:
java.io.IOException

getInetAddress

public java.net.InetAddress getInetAddress()

getLocalAddress

public java.net.InetAddress getLocalAddress()

getPort

public int getPort()

getLocalPort

public int getLocalPort()

getRemoteSocketAddress

public java.net.SocketAddress getRemoteSocketAddress()

getLocalSocketAddress

public java.net.SocketAddress getLocalSocketAddress()

getChannel

public java.nio.channels.SocketChannel getChannel()

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Throws:
java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Throws:
java.io.IOException

setTcpNoDelay

public void setTcpNoDelay(boolean on)
                   throws java.net.SocketException
Throws:
java.net.SocketException

getTcpNoDelay

public boolean getTcpNoDelay()
                      throws java.net.SocketException
Throws:
java.net.SocketException

setSoLinger

public void setSoLinger(boolean on,
                        int linger)
                 throws java.net.SocketException
Throws:
java.net.SocketException

getSoLinger

public int getSoLinger()
                throws java.net.SocketException
Throws:
java.net.SocketException

sendUrgentData

public void sendUrgentData(int data)
                    throws java.io.IOException
Throws:
java.io.IOException

setOOBInline

public void setOOBInline(boolean on)
                  throws java.net.SocketException
Throws:
java.net.SocketException

getOOBInline

public boolean getOOBInline()
                     throws java.net.SocketException
Throws:
java.net.SocketException

setSoTimeout

public void setSoTimeout(int timeout)
                  throws java.net.SocketException
Throws:
java.net.SocketException

getSoTimeout

public int getSoTimeout()
                 throws java.net.SocketException
Throws:
java.net.SocketException

setSendBufferSize

public void setSendBufferSize(int size)
                       throws java.net.SocketException
Throws:
java.net.SocketException

getSendBufferSize

public int getSendBufferSize()
                      throws java.net.SocketException
Throws:
java.net.SocketException

setReceiveBufferSize

public void setReceiveBufferSize(int size)
                          throws java.net.SocketException
Throws:
java.net.SocketException

getReceiveBufferSize

public int getReceiveBufferSize()
                         throws java.net.SocketException
Throws:
java.net.SocketException

setKeepAlive

public void setKeepAlive(boolean on)
                  throws java.net.SocketException
Throws:
java.net.SocketException

getKeepAlive

public boolean getKeepAlive()
                     throws java.net.SocketException
Throws:
java.net.SocketException

setTrafficClass

public void setTrafficClass(int tc)
                     throws java.net.SocketException
Throws:
java.net.SocketException

getTrafficClass

public int getTrafficClass()
                    throws java.net.SocketException
Throws:
java.net.SocketException

setReuseAddress

public void setReuseAddress(boolean on)
                     throws java.net.SocketException
Throws:
java.net.SocketException

getReuseAddress

public boolean getReuseAddress()
                        throws java.net.SocketException
Throws:
java.net.SocketException

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

shutdownInput

public void shutdownInput()
                   throws java.io.IOException
Throws:
java.io.IOException

shutdownOutput

public void shutdownOutput()
                    throws java.io.IOException
Throws:
java.io.IOException

isConnected

public boolean isConnected()
Returns true, indicating that the socket is connected.

Returns:
true

isBound

public boolean isBound()
Returns true, indicating that the socket is bound.

Returns:
true

isClosed

public boolean isClosed()

isInputShutdown

public boolean isInputShutdown()

isOutputShutdown

public boolean isOutputShutdown()

getSupportedCipherSuites

public java.lang.String[] getSupportedCipherSuites()

getEnabledCipherSuites

public java.lang.String[] getEnabledCipherSuites()

setEnabledCipherSuites

public void setEnabledCipherSuites(java.lang.String[] suites)

getSupportedProtocols

public java.lang.String[] getSupportedProtocols()

getEnabledProtocols

public java.lang.String[] getEnabledProtocols()

setEnabledProtocols

public void setEnabledProtocols(java.lang.String[] protocols)

getSession

public javax.net.ssl.SSLSession getSession()

addHandshakeCompletedListener

public void addHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener handshakeCompletedListener)

removeHandshakeCompletedListener

public void removeHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener handshakeCompletedListener)

startHandshake

public void startHandshake()
                    throws java.io.IOException
Throws:
java.io.IOException

setUseClientMode

public void setUseClientMode(boolean mode)

getUseClientMode

public boolean getUseClientMode()

setNeedClientAuth

public void setNeedClientAuth(boolean need)

getNeedClientAuth

public boolean getNeedClientAuth()

setWantClientAuth

public void setWantClientAuth(boolean want)

getWantClientAuth

public boolean getWantClientAuth()

setEnableSessionCreation

public void setEnableSessionCreation(boolean enable)

getEnableSessionCreation

public boolean getEnableSessionCreation()

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()