| Modifier and Type | Class and Description |
|---|---|
| private static class | SSLEngineImpl.
Implement a simple task delegator. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final TransportContext | |
| private final ReentrantLock | |
| private final SSLContextImpl |
| Access | Constructor and Description |
|---|---|
| pack-priv | SSLEngineImpl(SSLContextImpl sslContext)
Constructor for an SSLEngine from SSLContext, without host/port hints. |
| pack-priv | SSLEngineImpl(SSLContextImpl sslContext, String host, int port)
Constructor for an SSLEngine from SSLContext. |
| Modifier and Type | Method and Description |
|---|---|
| public void | beginHandshake()
Implements abstract javax. Begins handshaking on this |
| private static void | checkParams(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength)
|
| private void | |
| public void | closeInbound()
Implements abstract javax. Signals that no more inbound network data will be sent
to this |
| public void | closeOutbound()
Implements abstract javax. Signals that no more outbound application data will be sent
on this |
| private Plaintext | decode(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength)
|
| private Ciphertext | encode(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength)
|
| public String | getApplicationProtocol()
Overrides javax. Returns the most recent application protocol value negotiated for this connection. |
| public Runnable | getDelegatedTask()
Implements abstract javax. Returns a delegated |
| public String[] | getEnabledCipherSuites()
Implements abstract javax. Returns the names of the SSL cipher suites which are currently enabled for use on this engine. |
| public String[] | getEnabledProtocols()
Implements abstract javax. Returns the names of the protocol versions which are currently
enabled for use with this |
| public boolean | getEnableSessionCreation()
Implements abstract javax. Returns true if new SSL sessions may be established by this engine. |
| public String | getHandshakeApplicationProtocol()
Overrides javax. Returns the application protocol value negotiated on a SSL/TLS handshake currently in progress. |
| public BiFunction | getHandshakeApplicationProtocolSelector()
Overrides javax. Retrieves the callback function that selects an application protocol value during a SSL/TLS/DTLS handshake. |
| public SSLSession | getHandshakeSession()
Overrides javax. Returns the |
| public SSLEngineResult. | getHandshakeStatus()
Implements abstract javax. Returns the current handshake status for this |
| public boolean | getNeedClientAuth()
Implements abstract javax. Returns true if the engine will require client authentication. |
| public SSLSession | getSession()
Implements abstract javax. Returns the |
| public SSLParameters | getSSLParameters()
Overrides javax. Returns the SSLParameters in effect for this SSLEngine. |
| public String[] | getSupportedCipherSuites()
Implements abstract javax. Returns the names of the cipher suites which could be enabled for use on this engine. |
| public String[] | getSupportedProtocols()
Implements abstract javax. Returns the names of the protocols which could be enabled for use
with this |
| private static SSLException | |
| public boolean | getUseClientMode()
Implements abstract javax. Returns true if the engine is set to use client mode when handshaking. |
| public boolean | getWantClientAuth()
Implements abstract javax. Returns true if the engine will request client authentication. |
| public boolean | isInboundDone()
Implements abstract javax. Returns whether |
| public boolean | isOutboundDone()
Implements abstract javax. Returns whether |
| private SSLEngineResult | readRecord(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength)
|
| public void | setEnabledCipherSuites(String[] suites)
Implements abstract javax. Sets the cipher suites enabled for use on this engine. |
| public void | setEnabledProtocols(String[] protocols)
Implements abstract javax. Set the protocol versions enabled for use on this engine. |
| public void | setEnableSessionCreation(boolean flag)
Implements abstract javax. Controls whether new SSL sessions may be established by this engine. |
| public void | setHandshakeApplicationProtocolSelector(BiFunction<SSLEngine, List<String>, String> selector)
Overrides javax. Registers a callback function that selects an application protocol value for a SSL/TLS/DTLS handshake. |
| public void | setNeedClientAuth(boolean need)
Implements abstract javax. Configures the engine to require client authentication. |
| public void | setSSLParameters(SSLParameters params)
Overrides javax. Applies SSLParameters to this engine. |
| public void | setUseClientMode(boolean mode)
Implements abstract javax. Configures the engine to use client (or server) mode when handshaking. |
| public void | setWantClientAuth(boolean want)
Implements abstract javax. Configures the engine to request client authentication. |
| public String | |
| private SSLEngineResult. | tryKeyUpdate(SSLEngineResult.
Try key update for sequence number wrap or key usage limit. |
| private SSLEngineResult. | |
| private SSLEngineResult. | |
| public SSLEngineResult | unwrap(ByteBuffer src, ByteBuffer[] dsts, int offset, int length)
Implements abstract javax. Attempts to decode SSL/TLS/DTLS network data into a subsequence of plaintext application data buffers. |
| public SSLEngineResult | unwrap(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength)
|
| public boolean | useDelegatedTask()
Implements sun. Return true if delegated tasks used for handshaking operations. |
| public SSLEngineResult | wrap(ByteBuffer[] appData, int offset, int length, ByteBuffer netData)
Implements abstract javax. Attempts to encode plaintext bytes from a subsequence of data buffers into SSL/TLS/DTLS network data. |
| public SSLEngineResult | wrap(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength)
|
| private SSLEngineResult | writeRecord(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength)
|
| conContext | back to summary |
|---|---|
| pack-priv final TransportContext conContext | |
| engineLock | back to summary |
|---|---|
| private final ReentrantLock engineLock | |
| sslContext | back to summary |
|---|---|
| private final SSLContextImpl sslContext | |
| SSLEngineImpl | back to summary |
|---|---|
| pack-priv SSLEngineImpl(SSLContextImpl sslContext) Constructor for an SSLEngine from SSLContext, without host/port hints. This Engine will not be able to cache sessions, but must renegotiate everything by hand. | |
| SSLEngineImpl | back to summary |
|---|---|
| pack-priv SSLEngineImpl(SSLContextImpl sslContext, String host, int port) Constructor for an SSLEngine from SSLContext. | |
| beginHandshake | back to summary |
|---|---|
| public void beginHandshake() throws SSLException Implements abstract javax. Doc from javax. Begins handshaking on this Common reasons include a need to initiate a new protected session, create new encryption keys, or to change cipher suites. To force complete reauthentication, the current session should be invalidated before starting this handshake. The behavior of this method is protocol (and possibly implementation) dependent. For example, in TLSv1.3 calling this method after the connection has been established will force a key update. For prior TLS versions it will force a renegotiation (re-handshake).
This method is not needed for the initial handshake, as the
Note that the peer may also request a session renegotiation with
this
Unlike the
Some protocols may not support multiple handshakes on an existing
engine and may throw an
| |
| checkParams | back to summary |
|---|---|
| private static void checkParams(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength) | |
| checkTaskThrown | back to summary |
|---|---|
| private void checkTaskThrown() throws SSLException | |
| closeInbound | back to summary |
|---|---|
| public void closeInbound() throws SSLException Implements abstract javax. Doc from javax. Signals that no more inbound network data will be sent
to this
If the application initiated the closing process by calling
But if the application did not initiate the closure process, or if the circumstances above do not apply, this method should be called whenever the end of the SSL/TLS/DTLS data stream is reached. This ensures closure of the inbound side, and checks that the peer followed the SSL/TLS/DTLS close procedure properly, thus detecting possible truncation attacks. This method is idempotent: if the inbound side has already been closed, this method does not do anything.
| |
| closeOutbound | back to summary |
|---|---|
| public void closeOutbound() Implements abstract javax. Doc from javax. Signals that no more outbound application data will be sent
on this This method is idempotent: if the outbound side has already been closed, this method does not do anything.
| |
| decode | back to summary |
|---|---|
| private Plaintext decode(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws IOException | |
| encode | back to summary |
|---|---|
| private Ciphertext encode(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws IOException | |
| getApplicationProtocol | back to summary |
|---|---|
| public String getApplicationProtocol() Overrides javax. Doc from javax. Returns the most recent application protocol value negotiated for this connection. If supported by the underlying SSL/TLS/DTLS implementation, application name negotiation mechanisms such as RFC 7301 , the Application-Layer Protocol Negotiation (ALPN), can negotiate application-level values between peers.
| |
| getDelegatedTask | back to summary |
|---|---|
| public Runnable getDelegatedTask() Implements abstract javax. Doc from javax. Returns a delegated
A call to this method will return each outstanding task exactly once. Multiple delegated tasks can be run in parallel.
| |
| getEnabledCipherSuites | back to summary |
|---|---|
| public String[] getEnabledCipherSuites() Implements abstract javax. Doc from javax. Returns the names of the SSL cipher suites which are currently enabled for use on this engine. When an SSLEngine is first created, all enabled cipher suites support a minimum quality of service. Thus, in some environments this value might be empty. Note that even if a suite is enabled, it may never be used. This can occur if the peer does not support it, or its use is restricted, or the requisite certificates (and private keys) for the suite are not available, or an anonymous suite is enabled but authentication is required. The returned array includes cipher suites from the list of standard cipher suite names in the JSSE Cipher Suite Names section of the Java Security Standard Algorithm Names Specification, and may also include other cipher suites that the provider supports.
| |
| getEnabledProtocols | back to summary |
|---|---|
| public String[] getEnabledProtocols() Implements abstract javax. Doc from javax. Returns the names of the protocol versions which are currently
enabled for use with this Note that even if a protocol is enabled, it may never be used. This can occur if the peer does not support the protocol, or its use is restricted, or there are no enabled cipher suites supported by the protocol.
| |
| getEnableSessionCreation | back to summary |
|---|---|
| public boolean getEnableSessionCreation() Implements abstract javax. Doc from javax. Returns true if new SSL sessions may be established by this engine.
| |
| getHandshakeApplicationProtocol | back to summary |
|---|---|
| public String getHandshakeApplicationProtocol() Overrides javax. Doc from javax. Returns the application protocol value negotiated on a SSL/TLS handshake currently in progress.
Like
| |
| getHandshakeApplicationProtocolSelector | back to summary |
|---|---|
| public BiFunction Overrides javax. Doc from javax. Retrieves the callback function that selects an application protocol
value during a SSL/TLS/DTLS handshake.
See
| |
| getHandshakeSession | back to summary |
|---|---|
| public SSLSession getHandshakeSession() Overrides javax. Doc from javax. Returns the
TLS/DTLS protocols may negotiate parameters that are needed when using
an instance of this class, but before the
This method provides early access to the
| |
| getHandshakeStatus | back to summary |
|---|---|
| public SSLEngineResult. Implements abstract javax. Doc from javax. Returns the current handshake status for this
| |
| getNeedClientAuth | back to summary |
|---|---|
| public boolean getNeedClientAuth() Implements abstract javax. Doc from javax. Returns true if the engine will require client authentication. This option is only useful to engines in the server mode.
| |
| getSession | back to summary |
|---|---|
| public SSLSession getSession() Implements abstract javax. Doc from javax. Returns the These can be long-lived, and frequently correspond to an entire login session for some user. The session specifies a particular cipher suite which is being actively used by all connections in that session, as well as the identities of the session's client and server.
Unlike Until the initial handshake has completed, this method returns a session object which reports an invalid cipher suite of "SSL_NULL_WITH_NULL_NULL".
| |
| getSSLParameters | back to summary |
|---|---|
| public SSLParameters getSSLParameters() Overrides javax. Doc from javax. Returns the SSLParameters in effect for this SSLEngine. The ciphersuites and protocols of the returned SSLParameters are always non-null.
| |
| getSupportedCipherSuites | back to summary |
|---|---|
| public String[] getSupportedCipherSuites() Implements abstract javax. Doc from javax. Returns the names of the cipher suites which could be enabled for use on this engine. Normally, only a subset of these will actually be enabled by default, since this list may include cipher suites which do not meet quality of service requirements for those defaults. Such cipher suites might be useful in specialized applications. The returned array includes cipher suites from the list of standard cipher suite names in the JSSE Cipher Suite Names section of the Java Security Standard Algorithm Names Specification, and may also include other cipher suites that the provider supports.
| |
| getSupportedProtocols | back to summary |
|---|---|
| public String[] getSupportedProtocols() Implements abstract javax. Doc from javax. Returns the names of the protocols which could be enabled for use
with this
| |
| getTaskThrown | back to summary |
|---|---|
| private static SSLException getTaskThrown(Exception taskThrown) | |
| getUseClientMode | back to summary |
|---|---|
| public boolean getUseClientMode() Implements abstract javax. Doc from javax. Returns true if the engine is set to use client mode when handshaking.
| |
| getWantClientAuth | back to summary |
|---|---|
| public boolean getWantClientAuth() Implements abstract javax. Doc from javax. Returns true if the engine will request client authentication. This option is only useful for engines in the server mode.
| |
| isInboundDone | back to summary |
|---|---|
| public boolean isInboundDone() Implements abstract javax. Doc from javax. Returns whether
| |
| isOutboundDone | back to summary |
|---|---|
| public boolean isOutboundDone() Implements abstract javax. Doc from javax. Returns whether
Note that during the closure phase, a
| |
| readRecord | back to summary |
|---|---|
| private SSLEngineResult readRecord(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws IOException | |
| setEnabledCipherSuites | back to summary |
|---|---|
| public void setEnabledCipherSuites(String[] suites) Implements abstract javax. Doc from javax. Sets the cipher suites enabled for use on this engine.
Each cipher suite in the Note that the standard list of cipher suite names may be found in the JSSE Cipher Suite Names section of the Java Security Standard Algorithm Names Specification. Providers may support cipher suite names not found in this list or might not use the recommended name for a certain cipher suite.
See
| |
| setEnabledProtocols | back to summary |
|---|---|
| public void setEnabledProtocols(String[] protocols) Implements abstract javax. Doc from javax. Set the protocol versions enabled for use on this engine.
The protocols must have been listed by getSupportedProtocols()
as being supported. Following a successful call to this method,
only protocols listed in the
| |
| setEnableSessionCreation | back to summary |
|---|---|
| public void setEnableSessionCreation(boolean flag) Implements abstract javax. Doc from javax. Controls whether new SSL sessions may be established by this engine. If session creations are not allowed, and there are no existing sessions to resume, there will be no successful handshaking.
| |
| setHandshakeApplicationProtocolSelector | back to summary |
|---|---|
| public void setHandshakeApplicationProtocolSelector(BiFunction<SSLEngine, List<String>, String> selector) Overrides javax. Doc from javax. Registers a callback function that selects an application protocol
value for a SSL/TLS/DTLS handshake.
The function overrides any values supplied using
For example, the following call registers a callback function that examines the TLS handshake parameters and selects an application protocol name:
| |
| setNeedClientAuth | back to summary |
|---|---|
| public void setNeedClientAuth(boolean need) Implements abstract javax. Doc from javax. Configures the engine to require client authentication. This option is only useful for engines in the server mode. An engine's client authentication setting is one of the following:
Unlike
Calling this method overrides any previous setting made by
this method or
| |
| setSSLParameters | back to summary |
|---|---|
| public void setSSLParameters(SSLParameters params) Overrides javax. Doc from javax. Applies SSLParameters to this engine. This means:
| |
| setUseClientMode | back to summary |
|---|---|
| public void setUseClientMode(boolean mode) Implements abstract javax. Doc from javax. Configures the engine to use client (or server) mode when handshaking. This method must be called before any handshaking occurs. Once handshaking has begun, the mode can not be reset for the life of this engine. Servers normally authenticate themselves, and clients are not required to do so.
| |
| setWantClientAuth | back to summary |
|---|---|
| public void setWantClientAuth(boolean want) Implements abstract javax. Doc from javax. Configures the engine to request client authentication. This option is only useful for engines in the server mode. An engine's client authentication setting is one of the following:
Unlike
Calling this method overrides any previous setting made by
this method or
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| tryKeyUpdate | back to summary |
|---|---|
| private SSLEngineResult. Try key update for sequence number wrap or key usage limit. Note that in order to maintain the handshake status properly, we check the sequence number and key usage limit after the last record reading/writing process. As we request renegotiation or close the connection for wrapped sequence number when there is enough sequence number space left to handle a few more records, so the sequence number of the last record cannot be wrapped. | |
| tryNewSessionTicket | back to summary |
|---|---|
| private SSLEngineResult. | |
| tryToFinishHandshake | back to summary |
|---|---|
| private SSLEngineResult. | |
| unwrap | back to summary |
|---|---|
| public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts, int offset, int length) throws SSLException Implements abstract javax. Doc from javax. Attempts to decode SSL/TLS/DTLS network data into a subsequence of
plaintext application data buffers. This "scattering"
operation decodes, in a single invocation, a sequence of bytes
into one or more of a given sequence of buffers. Scattering
unwraps are often useful when implementing network protocols or
file formats that, for example, group data into segments
consisting of one or more fixed-length headers followed by a
variable-length body. See
Depending on the state of the SSLEngine, this method may consume network data without producing any application data (for example, it may consume handshake data.) The application is responsible for reliably obtaining the network data from the peer, and for invoking unwrap() on the data in the order it was received. The application must properly synchronize multiple calls to this method.
If this
This method will attempt to consume one complete SSL/TLS/DTLS network
packet, but will never consume more than the sum of the bytes
remaining in the buffers. Each
The underlying memory used by the
The inbound network buffer, Note the network data will not be useful to a second SSLEngine, as each SSLEngine contains unique random state which influences the SSL/TLS/DTLS messages. See the class description for more information on engine closure.
| |
| unwrap | back to summary |
|---|---|
| public SSLEngineResult unwrap(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws SSLException | |
| useDelegatedTask | back to summary |
|---|---|
| public boolean useDelegatedTask() Implements sun. Doc from sun. Return true if delegated tasks used for handshaking operations.
| |
| wrap | back to summary |
|---|---|
| public SSLEngineResult wrap(ByteBuffer[] appData, int offset, int length, ByteBuffer netData) throws SSLException Implements abstract javax. Doc from javax. Attempts to encode plaintext bytes from a subsequence of data
buffers into SSL/TLS/DTLS network data. This "gathering"
operation encodes, in a single invocation, a sequence of bytes
from one or more of a given sequence of buffers. Gathering
wraps are often useful when implementing network protocols or
file formats that, for example, group data into segments
consisting of one or more fixed-length headers followed by a
variable-length body. See
Depending on the state of the SSLEngine, this method may produce network data without consuming any application data (for example, it may generate handshake data.) The application is responsible for reliably transporting the network data to the peer, and for ensuring that data created by multiple calls to wrap() is transported in the same order in which it was generated. The application must properly synchronize multiple calls to this method.
If this
This method will attempt to produce SSL/TLS/DTLS records, and will
consume as much source data as possible, but will never consume
more than the sum of the bytes remaining in each buffer. Each
The underlying memory used by the See the class description for more information on engine closure.
| |
| wrap | back to summary |
|---|---|
| public SSLEngineResult wrap(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws SSLException | |
| writeRecord | back to summary |
|---|---|
| private SSLEngineResult writeRecord(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws IOException | |
| Modifier and Type | Field and Description |
|---|---|
| private final SSLEngineImpl |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| engine | back to summary |
|---|---|
| private final SSLEngineImpl engine | |
| DelegatedTask | back to summary |
|---|---|
| pack-priv DelegatedTask(SSLEngineImpl engineInstance) | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |