Package org.conscrypt
Class OpenSSLSocketImplWrapper
java.lang.Object
java.net.Socket
javax.net.ssl.SSLSocket
org.conscrypt.OpenSSLSocketImpl
org.conscrypt.OpenSSLSocketImplWrapper
- All Implemented Interfaces:
Closeable,AutoCloseable,NativeCrypto.SSLHandshakeCallbacks
public class OpenSSLSocketImplWrapper extends OpenSSLSocketImpl
This class wraps the SSL functionality over an existing connected socket.
-
Constructor Summary
Constructors Modifier Constructor Description protectedOpenSSLSocketImplWrapper(Socket socket, String host, int port, boolean autoClose, SSLParametersImpl sslParameters) -
Method Summary
Modifier and Type Method Description voidbind(SocketAddress sockaddr)Binds this socket to the given local host address and port specified by the SocketAddresslocalAddr.voidconnect(SocketAddress sockaddr)Connects this socket to the given remote host address and port specified by the SocketAddressremoteAddr.voidconnect(SocketAddress sockaddr, int timeout)Connects this socket to the given remote host address and port specified by the SocketAddressremoteAddrwith the specified timeout.InetAddressgetInetAddress()Returns the IP address of the target host this socket is connected to, or null if this socket is not yet connected.booleangetKeepAlive()Returns this socket'sSocketOptions.SO_KEEPALIVEsetting.InetAddressgetLocalAddress()Returns the local IP address this socket is bound to, orInetAddress.ANYif the socket is unbound.intgetLocalPort()Returns the local port this socket is bound to, or -1 if the socket is unbound.SocketAddressgetLocalSocketAddress()Returns the local address and port of this socket as a SocketAddress or null if the socket is unbound.booleangetOOBInline()Returns this socket'sSocketOptions.SO_OOBINLINEsetting.intgetPort()Returns the port number of the target host this socket is connected to, or 0 if this socket is not yet connected.intgetReceiveBufferSize()Returns this socket'sreceive buffer size.SocketAddressgetRemoteSocketAddress()Returns the remote address and port of this socket as aSocketAddressor null if the socket is not connected.booleangetReuseAddress()Returns this socket'sSocketOptions.SO_REUSEADDRsetting.intgetSendBufferSize()Returns this socket'ssend buffer size.intgetSoLinger()Returns this socket'slingertimeout in seconds, or -1 for no linger (i.e.intgetSoTimeout()Returns this socket'sreceive timeout.booleangetTcpNoDelay()Returns this socket'sSocketOptions#TCP_NODELAYsetting.intgetTrafficClass()Returns this socket's {@see SocketOptions#IP_TOS} setting.booleanisBound()Returns whether this socket is bound to a local address and port.booleanisClosed()Returns whether this socket is closed.booleanisConnected()Returns whether this socket is connected to a remote host.booleanisInputShutdown()Returns whether the incoming channel of the socket has already been closed.booleanisOutputShutdown()Returns whether the outgoing channel of the socket has already been closed.voidsetKeepAlive(boolean on)Sets this socket'sSocketOptions.SO_KEEPALIVEoption.voidsetReceiveBufferSize(int size)Sets this socket'sreceive buffer size.voidsetReuseAddress(boolean on)Sets this socket'sSocketOptions.SO_REUSEADDRoption.voidsetSendBufferSize(int size)Sets this socket'ssend buffer size.voidsetSoLinger(boolean on, int linger)Sets this socket'slingertimeout in seconds.voidsetSoTimeout(int to)Sets this socket'sread timeoutin milliseconds.voidsetTcpNoDelay(boolean on)Sets this socket'sSocketOptions.TCP_NODELAYoption.voidsetTrafficClass(int tos)Sets this socket'sSocketOptions.IP_TOSvalue for every packet sent by this socket.StringtoString()Returns aStringcontaining a concise, human-readable description of the socket.Methods inherited from class org.conscrypt.OpenSSLSocketImpl
addHandshakeCompletedListener, clientCertificateRequested, close, finalize, getAlpnSelectedProtocol, getChannelId, getEnabledCipherSuites, getEnabledProtocols, getEnableSessionCreation, getFileDescriptor$, getInputStream, getNeedClientAuth, getNpnSelectedProtocol, getOutputStream, getSession, getSoWriteTimeout, getSupportedCipherSuites, getSupportedProtocols, getUseClientMode, getWantClientAuth, handshakeCompleted, removeHandshakeCompletedListener, sendUrgentData, setAlpnProtocols, setChannelIdEnabled, setChannelIdPrivateKey, setEnabledCipherSuites, setEnabledProtocols, setEnableSessionCreation, setHandshakeTimeout, setHostname, setNeedClientAuth, setNpnProtocols, setOOBInline, setSoWriteTimeout, setUseClientMode, setUseSessionTickets, setWantClientAuth, startHandshake, verifyCertificateChainMethods inherited from class javax.net.ssl.SSLSocket
getSSLParameters, setSSLParameters, shutdownInput, shutdownOutputMethods inherited from class java.net.Socket
getChannel, setPerformancePreferences, setSocketImplFactory
-
Constructor Details
-
OpenSSLSocketImplWrapper
protected OpenSSLSocketImplWrapper(Socket socket, String host, int port, boolean autoClose, SSLParametersImpl sslParameters) throws IOException- Throws:
IOException
-
-
Method Details
-
connect
Description copied from class:SocketConnects this socket to the given remote host address and port specified by the SocketAddressremoteAddrwith the specified timeout. The connecting method will block until the connection is established or an error occurred.- Overrides:
connectin classSocket- Parameters:
sockaddr- the address and port of the remote host to connect to.timeout- the timeout value in milliseconds or0for an infinite timeout.- Throws:
IOException- if the socket is already connected or an error occurs while connecting.
-
connect
Description copied from class:SocketConnects this socket to the given remote host address and port specified by the SocketAddressremoteAddr.- Overrides:
connectin classSocket- Parameters:
sockaddr- the address and port of the remote host to connect to.- Throws:
IOException- if the socket is already connected or an error occurs while connecting.
-
bind
Description copied from class:SocketBinds this socket to the given local host address and port specified by the SocketAddresslocalAddr. IflocalAddris set tonull, this socket will be bound to an available local address on any free port.- Overrides:
bindin classSocket- Parameters:
sockaddr- the specific address and port on the local machine to bind to.- Throws:
IOException- if the socket is already bound or an error occurs while binding.
-
getRemoteSocketAddress
Description copied from class:SocketReturns the remote address and port of this socket as aSocketAddressor null if the socket is not connected.- Overrides:
getRemoteSocketAddressin classSocket- Returns:
- the remote socket address and port.
-
getLocalSocketAddress
Description copied from class:SocketReturns the local address and port of this socket as a SocketAddress or null if the socket is unbound. This is useful on multihomed hosts.- Overrides:
getLocalSocketAddressin classSocket
-
getLocalAddress
Description copied from class:SocketReturns the local IP address this socket is bound to, orInetAddress.ANYif the socket is unbound.- Overrides:
getLocalAddressin classSocket
-
getInetAddress
Description copied from class:SocketReturns the IP address of the target host this socket is connected to, or null if this socket is not yet connected.- Overrides:
getInetAddressin classSocket
-
toString
Description copied from class:SocketReturns aStringcontaining a concise, human-readable description of the socket. -
setSoLinger
Description copied from class:Socket- Overrides:
setSoLingerin classSocket- Throws:
SocketException
-
setTcpNoDelay
Description copied from class:SocketSets this socket'sSocketOptions.TCP_NODELAYoption.- Overrides:
setTcpNoDelayin classSocket- Throws:
SocketException
-
setReuseAddress
Description copied from class:SocketSets this socket'sSocketOptions.SO_REUSEADDRoption.- Overrides:
setReuseAddressin classSocket- Throws:
SocketException
-
setKeepAlive
Description copied from class:SocketSets this socket'sSocketOptions.SO_KEEPALIVEoption.- Overrides:
setKeepAlivein classSocket- Throws:
SocketException
-
setTrafficClass
Description copied from class:SocketSets this socket'sSocketOptions.IP_TOSvalue for every packet sent by this socket.- Overrides:
setTrafficClassin classSocket- Throws:
SocketException
-
setSoTimeout
Description copied from class:SocketSets this socket'sread timeoutin milliseconds. Use 0 for no timeout. To take effect, this option must be set before the blocking method was called.- Overrides:
setSoTimeoutin classOpenSSLSocketImpl- Throws:
SocketException
-
setSendBufferSize
Description copied from class:SocketSets this socket'ssend buffer size.- Overrides:
setSendBufferSizein classSocket- Throws:
SocketException
-
setReceiveBufferSize
Description copied from class:SocketSets this socket'sreceive buffer size.- Overrides:
setReceiveBufferSizein classSocket- Throws:
SocketException
-
getTcpNoDelay
Description copied from class:SocketReturns this socket'sSocketOptions#TCP_NODELAYsetting.- Overrides:
getTcpNoDelayin classSocket- Throws:
SocketException
-
getReuseAddress
Description copied from class:SocketReturns this socket'sSocketOptions.SO_REUSEADDRsetting.- Overrides:
getReuseAddressin classSocket- Throws:
SocketException
-
getOOBInline
Description copied from class:SocketReturns this socket'sSocketOptions.SO_OOBINLINEsetting.- Overrides:
getOOBInlinein classSocket- Throws:
SocketException
-
getKeepAlive
Description copied from class:SocketReturns this socket'sSocketOptions.SO_KEEPALIVEsetting.- Overrides:
getKeepAlivein classSocket- Throws:
SocketException
-
getTrafficClass
Description copied from class:SocketReturns this socket's {@see SocketOptions#IP_TOS} setting.- Overrides:
getTrafficClassin classSocket- Throws:
SocketException
-
getSoTimeout
Description copied from class:SocketReturns this socket'sreceive timeout.- Overrides:
getSoTimeoutin classOpenSSLSocketImpl- Throws:
SocketException
-
getSoLinger
Description copied from class:SocketReturns this socket'slingertimeout in seconds, or -1 for no linger (i.e.closewill return immediately).- Overrides:
getSoLingerin classSocket- Throws:
SocketException
-
getSendBufferSize
Description copied from class:SocketReturns this socket'ssend buffer size.- Overrides:
getSendBufferSizein classSocket- Throws:
SocketException
-
getReceiveBufferSize
Description copied from class:SocketReturns this socket'sreceive buffer size.- Overrides:
getReceiveBufferSizein classSocket- Throws:
SocketException
-
isConnected
public boolean isConnected()Description copied from class:SocketReturns whether this socket is connected to a remote host.- Overrides:
isConnectedin classSocket- Returns:
trueif the socket is connected,falseotherwise.
-
isClosed
public boolean isClosed()Description copied from class:SocketReturns whether this socket is closed. -
isBound
public boolean isBound()Description copied from class:SocketReturns whether this socket is bound to a local address and port. -
isOutputShutdown
public boolean isOutputShutdown()Description copied from class:SocketReturns whether the outgoing channel of the socket has already been closed.- Overrides:
isOutputShutdownin classSocket- Returns:
trueif writing to this socket is not possible anymore,falseotherwise.
-
isInputShutdown
public boolean isInputShutdown()Description copied from class:SocketReturns whether the incoming channel of the socket has already been closed.- Overrides:
isInputShutdownin classSocket- Returns:
trueif reading from this socket is not possible anymore,falseotherwise.
-
getPort
public int getPort()Description copied from class:SocketReturns the port number of the target host this socket is connected to, or 0 if this socket is not yet connected. -
getLocalPort
public int getLocalPort()Description copied from class:SocketReturns the local port this socket is bound to, or -1 if the socket is unbound.- Overrides:
getLocalPortin classSocket
-