public class JSSSocket
extends javax.net.ssl.SSLSocket
Constructor and Description |
---|
JSSSocket()
Start building a new JSSSocket.
|
Modifier and Type | Method and Description |
---|---|
void |
addHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener callback)
Add a callback to fire on handshake completion.
|
void |
bind(java.net.SocketAddress bindpoint) |
void |
close() |
void |
connect(java.net.SocketAddress endpoint) |
void |
connect(java.net.SocketAddress endpoint,
int timeout) |
void |
consumeSocket(java.net.Socket parent)
Consume a parent socket, utilizing it for all read/write operations.
|
boolean |
getAutoClose()
Get the autoClose status of this socket, that is, whether or not its
parent socket will be automatically closed.
|
JSSSocketChannel |
getChannel()
Get the underlying SocketChannel for this Socket.
|
java.lang.String[] |
getEnabledCipherSuites()
Get the set of enabled cipher suites for this SSLSocket.
|
java.lang.String[] |
getEnabledProtocols()
Get the set of enabled protocol versions for this SSLSocket.
|
boolean |
getEnableSessionCreation()
Get whether or not this SSLSocket enables creation of new sessions.
|
JSSEngine |
getEngine()
Get the underlying JSSEngine instance.
|
javax.net.ssl.SSLSession |
getHandshakeSession()
Get the initial session constructed during handshaking.
|
java.net.InetAddress |
getInetAddress() |
java.io.InputStream |
getInputStream()
Get a copy of an input stream for this Socket.
|
protected JSSSocketChannel |
getInternalChannel()
Helper to always return the channel for this socket,
initializing it if it isn't yet created.
|
boolean |
getKeepAlive() |
java.net.InetAddress |
getLocalAddress() |
int |
getLocalPort() |
java.net.SocketAddress |
getLocalSocketAddress() |
boolean |
getNeedClientAuth()
Get whether or not this SSLSocket needs client authentication.
|
boolean |
getOOBInline() |
<T> T |
getOption(java.net.SocketOption<T> name) |
java.io.OutputStream |
getOutputStream()
Get a copy of an output stream for this Socket.
|
int |
getPort() |
int |
getReceiveBufferSize() |
java.net.SocketAddress |
getRemoteSocketAddress() |
boolean |
getReuseAddress() |
int |
getSendBufferSize() |
javax.net.ssl.SSLSession |
getSession()
Get the established session for this SSLSocket.
|
int |
getSoLinger() |
int |
getSoTimeout() |
protected javax.net.ssl.SSLContext |
getSSLContext()
Get the SSLContext if one exists or create a new instance.
|
JSSParameters |
getSSLParameters()
Get the configuration of this SSLSocket as a JSSParameters object.
|
java.lang.String[] |
getSupportedCipherSuites()
Get the set of supported cipher suites for this SSLSocket.
|
java.lang.String[] |
getSupportedProtocols()
Get the set of supported protocol versions for this SSLSocket.
|
boolean |
getTcpNoDelay() |
int |
getTrafficClass() |
boolean |
getUseClientMode()
Get whether or not this SSLSocket is handshaking as a client.
|
boolean |
getWantClientAuth()
Get whether or not this SSLSocket wants client authentication.
|
void |
initEngine()
Explicitly initialize the SSLEngine with no session resumption
information.
|
void |
initEngine(java.lang.String host,
int port)
Explicitly initialize the SSLEngine with information for session
resumption, including peer's hostname and port.
|
boolean |
isBound() |
boolean |
isClosed() |
boolean |
isConnected() |
boolean |
isInputShutdown() |
boolean |
isOutputShutdown() |
protected void |
notifyHandshakeCompletedListeners()
Internal helper to fire callbacks on handshake completion.
|
void |
removeHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener callback)
Remove a callback from firing on handshake completion.
|
void |
sendUrgentData(int data) |
void |
setAutoClose(boolean on)
Set the autoClose status of this socket, that is, whether or not its
parent socket will be automatically closed.
|
void |
setCertFromAlias(java.lang.String alias)
Set the certificate this SSLSocket will utilize from an alias in the
NSS DB.
|
void |
setConsumedData(java.io.InputStream consumed)
Helper to inform this socket of data already consumed from the wrapped
socket.
|
void |
setEnabledCipherSuites(java.lang.String[] suites)
Set the list of enabled cipher suites for this SSLSocket.
|
void |
setEnabledProtocols(java.lang.String[] protocols)
Set the list of enabled protocol versions for this SSLSocket.
|
void |
setEnableSessionCreation(boolean enabled)
Set whether or not this SSLSocket enables creation of new sessions.
|
void |
setHostname(java.lang.String name)
Set the hostname this client socket is connecting to, for HTTPS TLS
certificate validation purposes.
|
void |
setKeepAlive(boolean on) |
void |
setKeyManager(javax.net.ssl.X509KeyManager km)
Set the KeyManager this SSLSocket will utilize to select a key.
|
void |
setKeyManagers(javax.net.ssl.X509KeyManager[] xkms)
Set the key managers this SSLSocket will utilize to select a key.
|
void |
setKeyMaterials(PK11Cert our_cert,
PK11PrivKey our_key)
Set the certificate this SSLSocket will utilize from a certificate and
its matching private key.
|
void |
setNeedClientAuth(boolean need)
Set whether or not this SSLSocket needs client authentication.
|
void |
setOOBInline(boolean on) |
<T> java.net.Socket |
setOption(java.net.SocketOption<T> name,
T value) |
void |
setPerformancePreferences(int connectionTime,
int latency,
int bandwidth) |
void |
setReceiveBufferSize(int size) |
void |
setReuseAddress(boolean on) |
void |
setSendBufferSize(int size) |
void |
setSoLinger(boolean on,
int linger) |
void |
setSoTimeout(int timeout) |
void |
setSSLContext(javax.net.ssl.SSLContext ctx)
Explicitly set the SSLContext utilized by this JSSSocket instance.
|
void |
setSSLParameters(javax.net.ssl.SSLParameters params)
Set the configuration of this SSLSocket from the given SSLParameters
instance.
|
void |
setTcpNoDelay(boolean on) |
void |
setTrafficClass(int tc) |
void |
setTrustManager(JSSTrustManager tm)
Set the trust manager this SSLSocket will utilize to validate a peer's
certificate.
|
void |
setTrustManagers(javax.net.ssl.X509TrustManager[] xtms)
Set the trust managers this SSLSocket will utilize to validate a peer's
certificate.
|
void |
setUseClientMode(boolean client)
Set whether or not this SSLSocket is handshaking as a client.
|
void |
setWantClientAuth(boolean want)
Set whether or not this SSLSocket wants client authentication.
|
void |
shutdownInput() |
void |
shutdownOutput() |
void |
startHandshake()
Begin a handshake, blocking to completion; this will begin a new
handshake when one has already been issued.
|
java.util.Set<java.net.SocketOption<?>> |
supportedOptions() |
java.lang.String |
toString() |
public JSSSocket()
public void consumeSocket(java.net.Socket parent) throws java.io.IOException
java.io.IOException
protected javax.net.ssl.SSLContext getSSLContext() throws java.io.IOException
java.io.IOException
public void setSSLContext(javax.net.ssl.SSLContext ctx) throws java.io.IOException
java.io.IOException
public void initEngine() throws java.io.IOException
java.io.IOException
public void initEngine(java.lang.String host, int port) throws java.io.IOException
java.io.IOException
public JSSEngine getEngine()
public JSSSocketChannel getChannel()
getChannel
in class java.net.Socket
Socket.getChannel()
protected JSSSocketChannel getInternalChannel()
public java.io.InputStream getInputStream() throws java.io.IOException
getInputStream
in class java.net.Socket
java.io.IOException
Socket.getInputStream()
public java.io.OutputStream getOutputStream() throws java.io.IOException
getOutputStream
in class java.net.Socket
java.io.IOException
Socket.getOutputStream()
public void setConsumedData(java.io.InputStream consumed)
public boolean getAutoClose()
public void setAutoClose(boolean on)
public void setHostname(java.lang.String name)
JSSEngine.setHostname(String)
public void setCertFromAlias(java.lang.String alias) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
JSSEngine.setCertFromAlias(String)
public void setKeyMaterials(PK11Cert our_cert, PK11PrivKey our_key) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
JSSEngine.setKeyMaterials(PK11Cert, PK11PrivKey)
public void setKeyManager(javax.net.ssl.X509KeyManager km)
JSSEngine.setKeyManager(X509KeyManager)
public void setKeyManagers(javax.net.ssl.X509KeyManager[] xkms)
public void setTrustManager(JSSTrustManager tm)
public void setTrustManagers(javax.net.ssl.X509TrustManager[] xtms)
public void startHandshake() throws java.io.IOException
startHandshake
in class javax.net.ssl.SSLSocket
java.io.IOException
SSLEngine.beginHandshake()
,
SSLSocket.startHandshake()
public void addHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener callback) throws java.lang.IllegalArgumentException
addHandshakeCompletedListener
in class javax.net.ssl.SSLSocket
java.lang.IllegalArgumentException
SSLSocket.addHandshakeCompletedListener(HandshakeCompletedListener)
protected void notifyHandshakeCompletedListeners()
public void removeHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener callback) throws java.lang.IllegalArgumentException
removeHandshakeCompletedListener
in class javax.net.ssl.SSLSocket
java.lang.IllegalArgumentException
SSLSocket.removeHandshakeCompletedListener(HandshakeCompletedListener)
public java.lang.String[] getEnabledCipherSuites()
getEnabledCipherSuites
in class javax.net.ssl.SSLSocket
JSSEngine.getEnabledCipherSuites()
,
SSLSocket.getEnabledCipherSuites()
public java.lang.String[] getSupportedCipherSuites()
getSupportedCipherSuites
in class javax.net.ssl.SSLSocket
JSSEngine.getSupportedCipherSuites()
,
SSLSocket.getSupportedCipherSuites()
public void setEnabledCipherSuites(java.lang.String[] suites)
setEnabledCipherSuites
in class javax.net.ssl.SSLSocket
JSSEngine.setEnabledCipherSuites(String[])
,
SSLSocket.setEnabledCipherSuites(String[])
public java.lang.String[] getEnabledProtocols()
getEnabledProtocols
in class javax.net.ssl.SSLSocket
JSSEngine.getEnabledProtocols()
,
SSLSocket.getEnabledProtocols()
public java.lang.String[] getSupportedProtocols()
getSupportedProtocols
in class javax.net.ssl.SSLSocket
JSSEngine.getSupportedProtocols()
,
SSLSocket.getSupportedProtocols()
public void setEnabledProtocols(java.lang.String[] protocols)
setEnabledProtocols
in class javax.net.ssl.SSLSocket
JSSEngine.setEnabledProtocols(String[])
,
SSLSocket.setEnabledProtocols(String[])
public boolean getEnableSessionCreation()
getEnableSessionCreation
in class javax.net.ssl.SSLSocket
JSSEngine.getEnableSessionCreation()
,
SSLSocket.getEnableSessionCreation()
public void setEnableSessionCreation(boolean enabled)
setEnableSessionCreation
in class javax.net.ssl.SSLSocket
JSSEngine.setEnableSessionCreation(boolean)
,
SSLSocket.setEnableSessionCreation(boolean)
public javax.net.ssl.SSLSession getHandshakeSession()
getHandshakeSession
in class javax.net.ssl.SSLSocket
SSLEngine.getHandshakeSession()
,
SSLSocket.getHandshakeSession()
public javax.net.ssl.SSLSession getSession()
getSession
in class javax.net.ssl.SSLSocket
JSSEngine.getSession()
,
SSLSocket.getSession()
public boolean getUseClientMode()
getUseClientMode
in class javax.net.ssl.SSLSocket
JSSEngine.getUseClientMode()
,
SSLSocket.getUseClientMode()
public void setUseClientMode(boolean client)
setUseClientMode
in class javax.net.ssl.SSLSocket
JSSEngine.setUseClientMode(boolean)
,
SSLSocket.setUseClientMode(boolean)
public boolean getWantClientAuth()
getWantClientAuth
in class javax.net.ssl.SSLSocket
JSSEngine.getWantClientAuth()
,
SSLSocket.getWantClientAuth()
public void setWantClientAuth(boolean want)
setWantClientAuth
in class javax.net.ssl.SSLSocket
JSSEngine.setWantClientAuth(boolean)
,
SSLSocket.setWantClientAuth(boolean)
public boolean getNeedClientAuth()
getNeedClientAuth
in class javax.net.ssl.SSLSocket
JSSEngine.getNeedClientAuth()
,
SSLSocket.getNeedClientAuth()
public void setNeedClientAuth(boolean need)
setNeedClientAuth
in class javax.net.ssl.SSLSocket
JSSEngine.setNeedClientAuth(boolean)
,
SSLSocket.setNeedClientAuth(boolean)
public JSSParameters getSSLParameters()
getSSLParameters
in class javax.net.ssl.SSLSocket
JSSEngine.getSSLParameters()
,
SSLSocket.getSSLParameters()
public void setSSLParameters(javax.net.ssl.SSLParameters params)
setSSLParameters
in class javax.net.ssl.SSLSocket
JSSEngine.setSSLParameters(SSLParameters)
,
SSLSocket.setSSLParameters(SSLParameters)
public void connect(java.net.SocketAddress endpoint) throws java.io.IOException
connect
in class java.net.Socket
java.io.IOException
public void connect(java.net.SocketAddress endpoint, int timeout) throws java.io.IOException
connect
in class java.net.Socket
java.io.IOException
public void bind(java.net.SocketAddress bindpoint) throws java.io.IOException
bind
in class java.net.Socket
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.net.Socket
java.io.IOException
public void shutdownInput() throws java.io.IOException
shutdownInput
in class java.net.Socket
java.io.IOException
public void shutdownOutput() throws java.io.IOException
shutdownOutput
in class java.net.Socket
java.io.IOException
public java.net.InetAddress getInetAddress()
getInetAddress
in class java.net.Socket
public java.net.InetAddress getLocalAddress()
getLocalAddress
in class java.net.Socket
public int getPort()
getPort
in class java.net.Socket
public int getLocalPort()
getLocalPort
in class java.net.Socket
public java.net.SocketAddress getLocalSocketAddress()
getLocalSocketAddress
in class java.net.Socket
public java.net.SocketAddress getRemoteSocketAddress()
getRemoteSocketAddress
in class java.net.Socket
public boolean getTcpNoDelay() throws java.net.SocketException
getTcpNoDelay
in class java.net.Socket
java.net.SocketException
public void setTcpNoDelay(boolean on) throws java.net.SocketException
setTcpNoDelay
in class java.net.Socket
java.net.SocketException
public int getSoLinger() throws java.net.SocketException
getSoLinger
in class java.net.Socket
java.net.SocketException
public void setSoLinger(boolean on, int linger) throws java.net.SocketException
setSoLinger
in class java.net.Socket
java.net.SocketException
public int getSoTimeout() throws java.net.SocketException
getSoTimeout
in class java.net.Socket
java.net.SocketException
public void setSoTimeout(int timeout) throws java.net.SocketException
setSoTimeout
in class java.net.Socket
java.net.SocketException
public boolean getOOBInline() throws java.net.SocketException
getOOBInline
in class java.net.Socket
java.net.SocketException
public void setOOBInline(boolean on) throws java.net.SocketException
setOOBInline
in class java.net.Socket
java.net.SocketException
public void sendUrgentData(int data) throws java.io.IOException
sendUrgentData
in class java.net.Socket
java.io.IOException
public int getSendBufferSize() throws java.net.SocketException
getSendBufferSize
in class java.net.Socket
java.net.SocketException
public void setSendBufferSize(int size) throws java.net.SocketException
setSendBufferSize
in class java.net.Socket
java.net.SocketException
public int getReceiveBufferSize() throws java.net.SocketException
getReceiveBufferSize
in class java.net.Socket
java.net.SocketException
public void setReceiveBufferSize(int size) throws java.net.SocketException
setReceiveBufferSize
in class java.net.Socket
java.net.SocketException
public boolean getKeepAlive() throws java.net.SocketException
getKeepAlive
in class java.net.Socket
java.net.SocketException
public void setKeepAlive(boolean on) throws java.net.SocketException
setKeepAlive
in class java.net.Socket
java.net.SocketException
public int getTrafficClass() throws java.net.SocketException
getTrafficClass
in class java.net.Socket
java.net.SocketException
public void setTrafficClass(int tc) throws java.net.SocketException
setTrafficClass
in class java.net.Socket
java.net.SocketException
public boolean getReuseAddress() throws java.net.SocketException
getReuseAddress
in class java.net.Socket
java.net.SocketException
public void setReuseAddress(boolean on) throws java.net.SocketException
setReuseAddress
in class java.net.Socket
java.net.SocketException
public boolean isConnected()
isConnected
in class java.net.Socket
public boolean isBound()
isBound
in class java.net.Socket
public boolean isClosed()
isClosed
in class java.net.Socket
public boolean isInputShutdown()
isInputShutdown
in class java.net.Socket
public boolean isOutputShutdown()
isOutputShutdown
in class java.net.Socket
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth)
setPerformancePreferences
in class java.net.Socket
public java.lang.String toString()
toString
in class java.net.Socket
public <T> java.net.Socket setOption(java.net.SocketOption<T> name, T value) throws java.io.IOException
java.io.IOException
public <T> T getOption(java.net.SocketOption<T> name) throws java.io.IOException
java.io.IOException
public java.util.Set<java.net.SocketOption<?>> supportedOptions()