edu.emory.mathcs.util.net.ssl
Class SSLSocketWrapper
java.lang.Object
java.net.Socket
javax.net.ssl.SSLSocket
edu.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. |
Methods inherited from class java.net.Socket |
setSocketImplFactory, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
delegate
protected final javax.net.ssl.SSLSocket delegate
- the wrapped delegate socket.
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.
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()