public final class SSLSocketImpl extends BaseSSLSocketImpl implements SSLTransport
This is a normal connection type socket, implementing SSL over some lower level socket, such as TCP. Because it is layered over some lower level socket, it MUST override all default socket methods.
This API offers a non-traditional option for establishing SSL connections. You may first establish the connection directly, then pass that connection to the SSL socket constructor with a flag saying which role should be taken in the handshake protocol. (The two ends of the connection must not choose the same role!) This allows setup of SSL proxying or tunneling, and also allows the kind of "role reversal" that is required for most FTP data transfers.
SSLSocket,
SSLServerSocket| 限定符和类型 | 类和说明 |
|---|---|
private class |
SSLSocketImpl.AppInputStream
InputStream for application data as returned by
SSLSocket.getInputStream().
|
private class |
SSLSocketImpl.AppOutputStream
OutputStream for application data as returned by
SSLSocket.getOutputStream().
|
| 限定符和类型 | 字段和说明 |
|---|---|
private SSLSocketImpl.AppInputStream |
appInput |
private SSLSocketImpl.AppOutputStream |
appOutput |
private boolean |
autoClose |
(专用程序包) TransportContext |
conContext |
private static int |
DEFAULT_SKIP_TIMEOUT |
private ReentrantLock |
handshakeLock |
private boolean |
isConnected |
private String |
peerHost |
private ReentrantLock |
socketLock |
(专用程序包) SSLContextImpl |
sslContext |
private boolean |
tlsIsClosed |
private static boolean |
trustNameService |
requireCloseNotify| 构造器和说明 |
|---|
SSLSocketImpl(SSLContextImpl sslContext)
Package-private constructor used to instantiate an unconnected
socket.
|
SSLSocketImpl(SSLContextImpl sslContext,
InetAddress address,
int peerPort)
Constructs an SSL connection to a server at a specified
address, and TCP port, using the authentication context
provided.
|
SSLSocketImpl(SSLContextImpl sslContext,
InetAddress peerAddr,
int peerPort,
InetAddress localAddr,
int localPort)
Constructs an SSL connection to a server at a specified
address, and TCP port, using the authentication context
provided.
|
SSLSocketImpl(SSLContextImpl sslContext,
Socket sock,
InputStream consumed,
boolean autoClose)
Creates a server mode
Socket layered over an
existing connected socket, and is able to read data which has
already been consumed/removed from the Socket's
underlying InputStream. |
SSLSocketImpl(SSLContextImpl sslContext,
Socket sock,
String peerHost,
int port,
boolean autoClose)
Layer SSL traffic over an existing connection, rather than
creating a new connection.
|
SSLSocketImpl(SSLContextImpl sslContext,
SSLConfiguration sslConfig)
Package-private constructor used to instantiate a server socket.
|
SSLSocketImpl(SSLContextImpl sslContext,
String peerHost,
int peerPort)
Constructs an SSL connection to a named host at a specified
port, using the authentication context provided.
|
SSLSocketImpl(SSLContextImpl sslContext,
String peerHost,
int peerPort,
InetAddress localAddr,
int localPort)
Constructs an SSL connection to a named host at a specified
port, using the authentication context provided.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addHandshakeCompletedListener(HandshakeCompletedListener listener) |
private void |
bruteForceCloseInput(boolean hasCloseReceipt)
Brute force close the input bound.
|
void |
close() |
private void |
closeSocket(boolean selfInitiated) |
void |
connect(SocketAddress endpoint,
int timeout) |
private Plaintext |
decode(ByteBuffer destination) |
(专用程序包) void |
doneConnect()
Initialize the handshaker and socket streams.
|
private void |
duplexCloseInput()
Duplex close, start from closing inbound.
|
private void |
duplexCloseOutput()
Duplex close, start from closing outbound.
|
private void |
ensureNegotiated() |
String |
getApplicationProtocol() |
String[] |
getEnabledCipherSuites() |
String[] |
getEnabledProtocols() |
boolean |
getEnableSessionCreation() |
String |
getHandshakeApplicationProtocol() |
java.util.function.BiFunction<SSLSocket,List<String>,String> |
getHandshakeApplicationProtocolSelector() |
SSLSession |
getHandshakeSession() |
InputStream |
getInputStream() |
boolean |
getNeedClientAuth() |
OutputStream |
getOutputStream() |
String |
getPeerHost()
Returns the host name of the peer.
|
int |
getPeerPort()
Returns the port number of the peer.
|
SSLSession |
getSession() |
SSLParameters |
getSSLParameters() |
String[] |
getSupportedCipherSuites() |
String[] |
getSupportedProtocols() |
boolean |
getUseClientMode() |
boolean |
getWantClientAuth() |
private Plaintext |
handleEOF(EOFException eofe) |
private void |
handleException(Exception cause)
Handle an exception.
|
boolean |
isClosed() |
boolean |
isInputShutdown()
Returns the input state of the socket
|
boolean |
isOutputShutdown()
Returns the output state of the socket
|
private ByteBuffer |
readApplicationRecord(ByteBuffer buffer)
Read application data record.
|
private int |
readHandshakeRecord()
Read the initial handshake records.
|
void |
removeHandshakeCompletedListener(HandshakeCompletedListener listener) |
void |
setEnabledCipherSuites(String[] suites) |
void |
setEnabledProtocols(String[] protocols) |
void |
setEnableSessionCreation(boolean flag) |
void |
setHandshakeApplicationProtocolSelector(java.util.function.BiFunction<SSLSocket,List<String>,String> selector) |
void |
setHost(String host) |
void |
setNeedClientAuth(boolean need) |
void |
setSSLParameters(SSLParameters params) |
void |
setUseClientMode(boolean mode) |
void |
setWantClientAuth(boolean want) |
void |
shutdown()
Shutdown the transport.
|
void |
shutdownInput()
Places the input stream for this socket at "end of stream".
|
private void |
shutdownInput(boolean checkCloseNotify) |
void |
shutdownOutput()
Disables the output stream for this socket.
|
void |
startHandshake() |
private void |
tryKeyUpdate()
Try key update for sequence number wrap or key usage limit.
|
boolean |
useDelegatedTask()
Return true if delegated tasks used for handshaking operations.
|
private void |
useImplicitHost(boolean useNameService) |
private void |
waitForClose()
Wait for close_notify alert for a graceful closure.
|
bind, connect, finalize, getChannel, getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isConnected, isLayered, sendUrgentData, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, toStringsetSocketImplFactorydecodefinal SSLContextImpl sslContext
final TransportContext conContext
private final SSLSocketImpl.AppInputStream appInput
private final SSLSocketImpl.AppOutputStream appOutput
private String peerHost
private boolean autoClose
private boolean isConnected
private volatile boolean tlsIsClosed
private final ReentrantLock socketLock
private final ReentrantLock handshakeLock
private static final boolean trustNameService
private static final int DEFAULT_SKIP_TIMEOUT
SSLSocketImpl(SSLContextImpl sslContext)
SSLSocketImpl(SSLContextImpl sslContext, SSLConfiguration sslConfig)
SSLSocketImpl(SSLContextImpl sslContext, String peerHost, int peerPort) throws IOException, UnknownHostException
SSLSocketImpl(SSLContextImpl sslContext, InetAddress address, int peerPort) throws IOException
IOExceptionSSLSocketImpl(SSLContextImpl sslContext, String peerHost, int peerPort, InetAddress localAddr, int localPort) throws IOException, UnknownHostException
SSLSocketImpl(SSLContextImpl sslContext, InetAddress peerAddr, int peerPort, InetAddress localAddr, int localPort) throws IOException
IOExceptionSSLSocketImpl(SSLContextImpl sslContext, Socket sock, InputStream consumed, boolean autoClose) throws IOException
Socket layered over an
existing connected socket, and is able to read data which has
already been consumed/removed from the Socket's
underlying InputStream.IOExceptionSSLSocketImpl(SSLContextImpl sslContext, Socket sock, String peerHost, int port, boolean autoClose) throws IOException
This particular constructor always uses the socket in the role of an SSL client. It may be useful in cases which start using SSL after some initial data transfers, for example in some SSL tunneling applications or as part of some kinds of application protocols which negotiate use of a SSL based security.
IOExceptionpublic void connect(SocketAddress endpoint, int timeout) throws IOException
connect 在类中 SocketIOExceptionpublic String[] getSupportedCipherSuites()
getSupportedCipherSuites 在类中 SSLSocketpublic String[] getEnabledCipherSuites()
getEnabledCipherSuites 在类中 SSLSocketpublic void setEnabledCipherSuites(String[] suites)
setEnabledCipherSuites 在类中 SSLSocketpublic String[] getSupportedProtocols()
getSupportedProtocols 在类中 SSLSocketpublic String[] getEnabledProtocols()
getEnabledProtocols 在类中 SSLSocketpublic void setEnabledProtocols(String[] protocols)
setEnabledProtocols 在类中 SSLSocketpublic SSLSession getSession()
getSession 在类中 SSLSocketpublic SSLSession getHandshakeSession()
getHandshakeSession 在类中 SSLSocketpublic void addHandshakeCompletedListener(HandshakeCompletedListener listener)
addHandshakeCompletedListener 在类中 SSLSocketpublic void removeHandshakeCompletedListener(HandshakeCompletedListener listener)
public void startHandshake()
throws IOException
startHandshake 在类中 SSLSocketIOExceptionpublic void setUseClientMode(boolean mode)
setUseClientMode 在类中 SSLSocketpublic boolean getUseClientMode()
getUseClientMode 在类中 SSLSocketpublic void setNeedClientAuth(boolean need)
setNeedClientAuth 在类中 SSLSocketpublic boolean getNeedClientAuth()
getNeedClientAuth 在类中 SSLSocketpublic void setWantClientAuth(boolean want)
setWantClientAuth 在类中 SSLSocketpublic boolean getWantClientAuth()
getWantClientAuth 在类中 SSLSocketpublic void setEnableSessionCreation(boolean flag)
setEnableSessionCreation 在类中 SSLSocketpublic boolean getEnableSessionCreation()
getEnableSessionCreation 在类中 SSLSocketpublic void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableclose 在类中 BaseSSLSocketImplIOExceptionprivate void duplexCloseOutput()
throws IOException
IOExceptionprivate void duplexCloseInput()
throws IOException
IOExceptionprivate void bruteForceCloseInput(boolean hasCloseReceipt)
throws IOException
IOExceptionpublic void shutdownInput()
throws IOException
BaseSSLSocketImplshutdownInput 在类中 BaseSSLSocketImplIOExceptionSocket.shutdownInput()private void shutdownInput(boolean checkCloseNotify)
throws IOException
IOExceptionpublic boolean isInputShutdown()
BaseSSLSocketImplisInputShutdown 在类中 BaseSSLSocketImplSocket.isInputShutdown()public void shutdownOutput()
throws IOException
BaseSSLSocketImplshutdownOutput 在类中 BaseSSLSocketImplIOExceptionSocket.shutdownOutput()public boolean isOutputShutdown()
BaseSSLSocketImplisOutputShutdown 在类中 BaseSSLSocketImplSocket.isOutputShutdown()public InputStream getInputStream() throws IOException
getInputStream 在类中 BaseSSLSocketImplIOExceptionprivate void ensureNegotiated()
throws IOException
IOExceptionpublic OutputStream getOutputStream() throws IOException
getOutputStream 在类中 BaseSSLSocketImplIOExceptionpublic SSLParameters getSSLParameters()
getSSLParameters 在类中 SSLSocketpublic void setSSLParameters(SSLParameters params)
setSSLParameters 在类中 SSLSocketpublic String getApplicationProtocol()
getApplicationProtocol 在类中 SSLSocketpublic String getHandshakeApplicationProtocol()
public void setHandshakeApplicationProtocolSelector(java.util.function.BiFunction<SSLSocket,List<String>,String> selector)
public java.util.function.BiFunction<SSLSocket,List<String>,String> getHandshakeApplicationProtocolSelector()
private int readHandshakeRecord()
throws IOException
IOExceptionprivate ByteBuffer readApplicationRecord(ByteBuffer buffer) throws IOException
IOExceptionprivate Plaintext decode(ByteBuffer destination) throws IOException
IOExceptionprivate void tryKeyUpdate()
throws IOException
IOExceptionvoid doneConnect()
throws IOException
IOExceptionprivate void useImplicitHost(boolean useNameService)
public void setHost(String host)
private void handleException(Exception cause) throws IOException
IOExceptionprivate Plaintext handleEOF(EOFException eofe) throws IOException
IOExceptionpublic String getPeerHost()
SSLTransportgetPeerHost 在接口中 SSLTransportpublic int getPeerPort()
SSLTransportgetPeerPort 在接口中 SSLTransportpublic boolean useDelegatedTask()
SSLTransportuseDelegatedTask 在接口中 SSLTransportpublic void shutdown()
throws IOException
SSLTransportshutdown 在接口中 SSLTransportIOExceptionprivate void closeSocket(boolean selfInitiated)
throws IOException
IOExceptionprivate void waitForClose()
throws IOException
IOExceptionCopyright © 2023. All rights reserved.