Top Inners Fields Constructors Methods
io.netty.handler.ssl

pack-priv Class JdkAlpnSslEngine

extends JdkSslEngine
Class Inheritance
Known Direct Subclasses
io.netty.handler.ssl.BouncyCastleAlpnSslEngine
Annotations
@SuppressJava6Requirement
reason:Usage guarded by java version check
Imports
io.netty.util.internal.StringUtil, .SuppressJava6Requirement, javax.net.ssl.SSLEngine, .SSLEngineResult, .SSLException, java.nio.ByteBuffer, java.util.LinkedHashSet, .List, java.util.function.BiConsumer, .BiFunction

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
private final JdkAlpnSslEngine.AlpnSelector
private final JdkApplicationProtocolNegotiator.ProtocolSelectionListener

Constructor Summary

AccessConstructor and Description
pack-priv
JdkAlpnSslEngine(SSLEngine engine, JdkApplicationProtocolNegotiator applicationNegotiator, boolean isServer, BiConsumer<SSLEngine, JdkAlpnSslEngine.AlpnSelector> setHandshakeApplicationProtocolSelector, BiConsumer<SSLEngine, List<String>> setApplicationProtocols)

Deprecated as a consequence of JdkApplicationProtocolNegotiator being deprecated.
pack-priv
JdkAlpnSslEngine(SSLEngine engine, JdkApplicationProtocolNegotiator applicationNegotiator, boolean isServer)

Deprecated as a consequence of JdkApplicationProtocolNegotiator being deprecated.

Method Summary

Modifier and TypeMethod and Description
public String
getApplicationProtocol()

Overrides javax.net.ssl.SSLEngine.getApplicationProtocol.

Returns the most recent application protocol value negotiated for this connection.
public String
getHandshakeApplicationProtocol()

Overrides javax.net.ssl.SSLEngine.getHandshakeApplicationProtocol.

Returns the application protocol value negotiated on a SSL/TLS handshake currently in progress.
public BiFunction<SSLEngine, List<String>, String>
getHandshakeApplicationProtocolSelector()

Overrides javax.net.ssl.SSLEngine.getHandshakeApplicationProtocolSelector.

Retrieves the callback function that selects an application protocol value during a SSL/TLS/DTLS handshake.
public String
public void
setHandshakeApplicationProtocolSelector(BiFunction<SSLEngine, List<String>, String>
the callback function, or null to disable the callback functionality.
selector
)

Overrides javax.net.ssl.SSLEngine.setHandshakeApplicationProtocolSelector.

Registers a callback function that selects an application protocol value for a SSL/TLS/DTLS handshake.
pack-priv void
public SSLEngineResult
unwrap(ByteBuffer
a ByteBuffer containing inbound network data.
src
,
ByteBuffer
a ByteBuffer to hold inbound application data.
dst
)

Overrides io.netty.handler.ssl.JdkSslEngine.unwrap.

Attempts to decode SSL/TLS/DTLS network data into a plaintext application data buffer.
public SSLEngineResult
unwrap(ByteBuffer
a ByteBuffer containing inbound network data.
src
,
ByteBuffer[]
an array of ByteBuffers to hold inbound application data.
dsts
)

Overrides io.netty.handler.ssl.JdkSslEngine.unwrap.

Attempts to decode SSL/TLS/DTLS network data into a sequence of plaintext application data buffers.
public SSLEngineResult
unwrap(ByteBuffer
a ByteBuffer containing inbound network data.
src
,
ByteBuffer[]
an array of ByteBuffers to hold inbound application data.
dst
,
int
The offset within the buffer array of the first buffer from which bytes are to be transferred; it must be non-negative and no larger than dsts.length.
offset
,
int
The maximum number of buffers to be accessed; it must be non-negative and no larger than dsts.length - offset.
len
)

Overrides io.netty.handler.ssl.JdkSslEngine.unwrap.

Attempts to decode SSL/TLS/DTLS network data into a subsequence of plaintext application data buffers.
private SSLEngineResult
public SSLEngineResult
wrap(ByteBuffer
a ByteBuffer containing outbound application data
src
,
ByteBuffer
a ByteBuffer to hold outbound network data
dst
)

Overrides io.netty.handler.ssl.JdkSslEngine.wrap.

Attempts to encode a buffer of plaintext application data into SSL/TLS/DTLS network data.
public SSLEngineResult
wrap(ByteBuffer[]
an array of ByteBuffers containing the outbound application data
srcs
,
ByteBuffer
a ByteBuffer to hold outbound network data
dst
)

Overrides io.netty.handler.ssl.JdkSslEngine.wrap.

Attempts to encode plaintext bytes from a sequence of data buffers into SSL/TLS/DTLS network data.
public SSLEngineResult
wrap(ByteBuffer[]
an array of ByteBuffers containing the outbound application data
srcs
,
int
The offset within the buffer array of the first buffer from which bytes are to be retrieved; it must be non-negative and no larger than srcs.length
offset
,
int
The maximum number of buffers to be accessed; it must be non-negative and no larger than srcs.length - offset
len
,
ByteBuffer
a ByteBuffer to hold outbound network data
dst
)

Overrides io.netty.handler.ssl.JdkSslEngine.wrap.

Attempts to encode plaintext bytes from a subsequence of data buffers into SSL/TLS/DTLS network data.
Inherited from io.netty.handler.ssl.JdkSslEngine:
beginHandshakecloseInboundcloseOutboundgetDelegatedTaskgetEnabledCipherSuitesgetEnabledProtocolsgetEnableSessionCreationgetHandshakeSessiongetHandshakeStatusgetNeedClientAuthgetPeerHostgetPeerPortgetSessiongetSSLParametersgetSupportedCipherSuitesgetSupportedProtocolsgetUseClientModegetWantClientAuthgetWrappedEngineisInboundDoneisOutboundDonesetEnabledCipherSuitessetEnabledProtocolssetEnableSessionCreationsetNeedClientAuthsetSSLParameterssetUseClientModesetWantClientAuth

Field Detail

alpnSelectorback to summary
private final JdkAlpnSslEngine.AlpnSelector alpnSelector
selectionListenerback to summary
private final JdkApplicationProtocolNegotiator.ProtocolSelectionListener selectionListener

Constructor Detail

JdkAlpnSslEngineback to summary
pack-priv JdkAlpnSslEngine(SSLEngine engine, JdkApplicationProtocolNegotiator applicationNegotiator, boolean isServer, BiConsumer<SSLEngine, JdkAlpnSslEngine.AlpnSelector> setHandshakeApplicationProtocolSelector, BiConsumer<SSLEngine, List<String>> setApplicationProtocols)

Deprecated

as a consequence of JdkApplicationProtocolNegotiator being deprecated. See corresponding docs for further information.

JdkAlpnSslEngineback to summary
pack-priv JdkAlpnSslEngine(SSLEngine engine, JdkApplicationProtocolNegotiator applicationNegotiator, boolean isServer)

Deprecated

as a consequence of JdkApplicationProtocolNegotiator being deprecated. See corresponding docs for further information.

Method Detail

getApplicationProtocolback to summary
public String getApplicationProtocol()

Overrides javax.net.ssl.SSLEngine.getApplicationProtocol.

Doc from javax.net.ssl.SSLEngine.getApplicationProtocol.

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.

Returns:String

null if it has not yet been determined if application protocols might be used for this connection, an empty String if application protocols values will not be used, or a non-empty application protocol String if a value was successfully negotiated.

getHandshakeApplicationProtocolback to summary
public String getHandshakeApplicationProtocol()

Overrides javax.net.ssl.SSLEngine.getHandshakeApplicationProtocol.

Doc from javax.net.ssl.SSLEngine.getHandshakeApplicationProtocol.

Returns the application protocol value negotiated on a SSL/TLS handshake currently in progress.

Like getHandshakeSession(), a connection may be in the middle of a handshake. The application protocol may or may not yet be available.

Returns:String

null if it has not yet been determined if application protocols might be used for this handshake, an empty String if application protocols values will not be used, or a non-empty application protocol String if a value was successfully negotiated.

getHandshakeApplicationProtocolSelectorback to summary
public BiFunction<SSLEngine, List<String>, String> getHandshakeApplicationProtocolSelector()

Overrides javax.net.ssl.SSLEngine.getHandshakeApplicationProtocolSelector.

Doc from javax.net.ssl.SSLEngine.getHandshakeApplicationProtocolSelector.

Retrieves the callback function that selects an application protocol value during a SSL/TLS/DTLS handshake. See setHandshakeApplicationProtocolSelector for the function's type parameters.

Returns:BiFunction<SSLEngine, List<String>, String>

the callback function, or null if none has been set.

getNegotiatedApplicationProtocolback to summary
public String getNegotiatedApplicationProtocol()

Overrides io.netty.handler.ssl.JdkSslEngine.getNegotiatedApplicationProtocol.

Implements io.netty.handler.ssl.ApplicationProtocolAccessor.getNegotiatedApplicationProtocol.

Doc from io.netty.handler.ssl.ApplicationProtocolAccessor.getNegotiatedApplicationProtocol.

Returns the name of the negotiated application-level protocol.

Returns:String

the application-level protocol name or null if the negotiation failed or the client does not have ALPN/NPN extension

Annotations
@Override
setHandshakeApplicationProtocolSelectorback to summary
public void setHandshakeApplicationProtocolSelector(BiFunction<SSLEngine, List<String>, String> selector)

Overrides javax.net.ssl.SSLEngine.setHandshakeApplicationProtocolSelector.

Doc from javax.net.ssl.SSLEngine.setHandshakeApplicationProtocolSelector.

Registers a callback function that selects an application protocol value for a SSL/TLS/DTLS handshake. The function overrides any values supplied using SSLParameters.setApplicationProtocols and it supports the following type parameters:

SSLEngine
The function's first argument allows the current SSLEngine to be inspected, including the handshake session and configuration settings.
List<String>
The function's second argument lists the application protocol names advertised by the TLS peer.
String
The function's result is an application protocol name, or null to indicate that none of the advertised names are acceptable. If the return value is an empty String then application protocol indications will not be used. If the return value is null (no value chosen) or is a value that was not advertised by the peer, the underlying protocol will determine what action to take. (For example, ALPN will send a "no_application_protocol" alert and terminate the connection.)
For example, the following call registers a callback function that examines the TLS handshake parameters and selects an application protocol name:
serverEngine.setHandshakeApplicationProtocolSelector(
        (serverEngine, clientProtocols) -> {
            SSLSession session = serverEngine.getHandshakeSession();
            return chooseApplicationProtocol(
                serverEngine,
                clientProtocols,
                session.getProtocol(),
                session.getCipherSuite());
        });
Parameters
selector:BiFunction<SSLEngine, List<String>, String>

the callback function, or null to disable the callback functionality.

setNegotiatedApplicationProtocolback to summary
pack-priv void setNegotiatedApplicationProtocol(String applicationProtocol)

Overrides io.netty.handler.ssl.JdkSslEngine.setNegotiatedApplicationProtocol.

Annotations
@Override
unwrapback to summary
public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer dst) throws SSLException

Overrides io.netty.handler.ssl.JdkSslEngine.unwrap.

Doc from javax.net.ssl.SSLEngine.unwrap.

Attempts to decode SSL/TLS/DTLS network data into a plaintext application data buffer.

An invocation of this method behaves in exactly the same manner as the invocation:

engine.unwrap(src, new ByteBuffer[] { dst }, 0, 1);
Parameters
src:ByteBuffer

a ByteBuffer containing inbound network data.

dst:ByteBuffer

a ByteBuffer to hold inbound application data.

Returns:SSLEngineResult

an SSLEngineResult describing the result of this operation.

Annotations
@Override
Exceptions
SSLException:
A problem was encountered while processing the data that caused the SSLEngine to abort. See the class description for more information on engine closure.
unwrapback to summary
public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts) throws SSLException

Overrides io.netty.handler.ssl.JdkSslEngine.unwrap.

Doc from javax.net.ssl.SSLEngine.unwrap.

Attempts to decode SSL/TLS/DTLS network data into a sequence of plaintext application data buffers.

An invocation of this method behaves in exactly the same manner as the invocation:

engine.unwrap(src, dsts, 0, dsts.length);
Parameters
src:ByteBuffer

a ByteBuffer containing inbound network data.

dsts:ByteBuffer[]

an array of ByteBuffers to hold inbound application data.

Returns:SSLEngineResult

an SSLEngineResult describing the result of this operation.

Annotations
@Override
Exceptions
SSLException:
A problem was encountered while processing the data that caused the SSLEngine to abort. See the class description for more information on engine closure.
unwrapback to summary
public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dst, int offset, int len) throws SSLException

Overrides io.netty.handler.ssl.JdkSslEngine.unwrap.

Doc from javax.net.ssl.SSLEngine.unwrap.

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 java.nio.channels.ScatteringByteChannel for more information on scattering, and java.nio.channels.ScatteringByteChannel#read(ByteBuffer[], int, int) for more information on the subsequence behavior.

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 SSLEngine has not yet started its initial handshake, this method will automatically start the handshake.

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 ByteBuffer's position is updated to reflect the amount of data consumed or produced. The limits remain the same.

The underlying memory used by the src and dsts ByteBuffers must not be the same.

The inbound network buffer, src, may be modified as a result of this call: therefore if the network data packet is required for some secondary purpose, the data should be duplicated before calling this method.

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.

Parameters
src:ByteBuffer

a ByteBuffer containing inbound network data.

dst:ByteBuffer[]

an array of ByteBuffers to hold inbound application data.

offset:int

The offset within the buffer array of the first buffer from which bytes are to be transferred; it must be non-negative and no larger than dsts.length.

len:int

The maximum number of buffers to be accessed; it must be non-negative and no larger than dsts.length - offset.

Returns:SSLEngineResult

an SSLEngineResult describing the result of this operation.

Annotations
@Override
Exceptions
SSLException:
A problem was encountered while processing the data that caused the SSLEngine to abort. See the class description for more information on engine closure.
verifyProtocolSelectionback to summary
private SSLEngineResult verifyProtocolSelection(SSLEngineResult result) throws SSLException
wrapback to summary
public SSLEngineResult wrap(ByteBuffer src, ByteBuffer dst) throws SSLException

Overrides io.netty.handler.ssl.JdkSslEngine.wrap.

Doc from javax.net.ssl.SSLEngine.wrap.

Attempts to encode a buffer of plaintext application data into SSL/TLS/DTLS network data.

An invocation of this method behaves in exactly the same manner as the invocation:

engine.wrap(new ByteBuffer[] { src }, 0, 1, dst);
Parameters
src:ByteBuffer

a ByteBuffer containing outbound application data

dst:ByteBuffer

a ByteBuffer to hold outbound network data

Returns:SSLEngineResult

an SSLEngineResult describing the result of this operation.

Annotations
@Override
Exceptions
SSLException:
A problem was encountered while processing the data that caused the SSLEngine to abort. See the class description for more information on engine closure.
wrapback to summary
public SSLEngineResult wrap(ByteBuffer[] srcs, ByteBuffer dst) throws SSLException

Overrides io.netty.handler.ssl.JdkSslEngine.wrap.

Doc from javax.net.ssl.SSLEngine.wrap.

Attempts to encode plaintext bytes from a sequence of data buffers into SSL/TLS/DTLS network data.

An invocation of this method behaves in exactly the same manner as the invocation:

engine.wrap(srcs, 0, srcs.length, dst);
Parameters
srcs:ByteBuffer[]

an array of ByteBuffers containing the outbound application data

dst:ByteBuffer

a ByteBuffer to hold outbound network data

Returns:SSLEngineResult

an SSLEngineResult describing the result of this operation.

Annotations
@Override
Exceptions
SSLException:
A problem was encountered while processing the data that caused the SSLEngine to abort. See the class description for more information on engine closure.
wrapback to summary
public SSLEngineResult wrap(ByteBuffer[] srcs, int offset, int len, ByteBuffer dst) throws SSLException

Overrides io.netty.handler.ssl.JdkSslEngine.wrap.

Doc from javax.net.ssl.SSLEngine.wrap.

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 java.nio.channels.GatheringByteChannel for more information on gathering, and java.nio.channels.GatheringByteChannel#write(ByteBuffer[], int, int) for more information on the subsequence behavior.

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 SSLEngine has not yet started its initial handshake, this method will automatically start the handshake.

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 ByteBuffer's position is updated to reflect the amount of data consumed or produced. The limits remain the same.

The underlying memory used by the srcs and dst ByteBuffers must not be the same.

See the class description for more information on engine closure.

Parameters
srcs:ByteBuffer[]

an array of ByteBuffers containing the outbound application data

offset:int

The offset within the buffer array of the first buffer from which bytes are to be retrieved; it must be non-negative and no larger than srcs.length

len:int

The maximum number of buffers to be accessed; it must be non-negative and no larger than srcs.length - offset

dst:ByteBuffer

a ByteBuffer to hold outbound network data

Returns:SSLEngineResult

an SSLEngineResult describing the result of this operation.

Annotations
@Override
Exceptions
SSLException:
A problem was encountered while processing the data that caused the SSLEngine to abort. See the class description for more information on engine closure.
io.netty.handler.ssl back to summary

pack-priv final Class JdkAlpnSslEngine.AlpnSelector

extends Object
implements BiFunction<SSLEngine, List<String>, String>
Class Inheritance
All Implemented Interfaces
java.util.function.BiFunction

Field Summary

Modifier and TypeField and Description
private boolean
private final JdkApplicationProtocolNegotiator.ProtocolSelector

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String
apply(SSLEngine
the first function argument
sslEngine
,
List<String>
the second function argument
strings
)

Implements java.util.function.BiFunction.apply.

Applies this function to the given arguments.
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

calledback to summary
private boolean called
selectorback to summary
private final JdkApplicationProtocolNegotiator.ProtocolSelector selector

Constructor Detail

AlpnSelectorback to summary
pack-priv AlpnSelector(JdkApplicationProtocolNegotiator.ProtocolSelector selector)

Method Detail

applyback to summary
public String apply(SSLEngine sslEngine, List<String> strings)

Implements java.util.function.BiFunction.apply.

Doc from java.util.function.BiFunction.apply.

Applies this function to the given arguments.

Parameters
sslEngine:SSLEngine

the first function argument

strings:List<String>

the second function argument

Returns:String

the function result

Annotations
@Override
checkUnsupportedback to summary
pack-priv void checkUnsupported()