Top Description Inners Fields Constructors Methods
io.netty5.handler.ssl

public Class SniHandler

extends AbstractSniHandler<SslContext>
Class Inheritance
Imports
io.netty5.buffer.BufferAllocator, io.netty5.channel.ChannelHandlerContext, io.netty5.handler.codec.DecoderException, io.netty5.util.AsyncMapping, .DomainNameMapping, .Mapping, io.netty5.util.concurrent.Future, .Promise, io.netty5.util.internal.SilentDispose, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory

Enables SNI (Server Name Indication) extension for server side SSL. For clients support SNI, the server could have multiple host name bound on a single IP. The client will send host name in the handshake data so server could decide which certificate to choose for the host name.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final SniHandler.Selection
private static final InternalLogger
protected final AsyncMapping<String, SslContext>
private volatile SniHandler.Selection

Constructor Summary

AccessConstructor and Description
public
SniHandler(Mapping<? super String, ? extends SslContext>
the mapping of domain name to SslContext
mapping
)

Creates a SNI detection handler with configured SslContext maintained by Mapping

public
SniHandler(DomainNameMapping<? extends SslContext>
the mapping of domain name to SslContext
mapping
)

Deprecated as a consequence of DomainNameMapping being deprecated.
Creates a SNI detection handler with configured SslContext maintained by DomainNameMapping
public
SniHandler(AsyncMapping<? super String, ? extends SslContext>
the mapping of domain name to SslContext
mapping
)

Creates a SNI detection handler with configured SslContext maintained by AsyncMapping

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the selected hostname
hostname
()

protected Future<SslContext>
lookup(ChannelHandlerContext ctx, String hostname)

Implements abstract io.netty5.handler.ssl.AbstractSniHandler.lookup.

The default implementation will simply call AsyncMapping#map(Object, Promise) but users can override this method to implement custom behavior.
protected SslHandler
newSslHandler(SslContext context, BufferAllocator allocator)

Returns a new SslHandler using the given SslContext and BufferAllocator.

protected final void
protected void
replaceHandler(ChannelHandlerContext ctx, String hostname, SslContext sslContext)

The default implementation of this method will simply replace this SniHandler instance with a SslHandler.

public SslContext

Returns:

the selected SslContext
sslContext
()

Inherited from io.netty5.handler.ssl.AbstractSniHandler:
lookuponLookupComplete

Field Detail

EMPTY_SELECTIONback to summary
private static final SniHandler.Selection EMPTY_SELECTION
loggerback to summary
private static final InternalLogger logger

Hides io.netty5.handler.ssl.SslClientHelloHandler.logger.

mappingback to summary
protected final AsyncMapping<String, SslContext> mapping
selectionback to summary
private volatile SniHandler.Selection selection

Constructor Detail

SniHandlerback to summary
public SniHandler(Mapping<? super String, ? extends SslContext> mapping)

Creates a SNI detection handler with configured SslContext maintained by Mapping

Parameters
mapping:Mapping<? super String, ? extends SslContext>

the mapping of domain name to SslContext

SniHandlerback to summary
public SniHandler(DomainNameMapping<? extends SslContext> mapping)

Deprecated

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

Creates a SNI detection handler with configured SslContext maintained by DomainNameMapping

Parameters
mapping:DomainNameMapping<? extends SslContext>

the mapping of domain name to SslContext

SniHandlerback to summary
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping)

Creates a SNI detection handler with configured SslContext maintained by AsyncMapping

Parameters
mapping:AsyncMapping<? super String, ? extends SslContext>

the mapping of domain name to SslContext

Annotations
@SuppressWarnings:unchecked

Method Detail

hostnameback to summary
public String hostname()
Returns:String

the selected hostname

lookupback to summary
protected Future<SslContext> lookup(ChannelHandlerContext ctx, String hostname) throws Exception

Implements abstract io.netty5.handler.ssl.AbstractSniHandler.lookup.

The default implementation will simply call AsyncMapping#map(Object, Promise) but users can override this method to implement custom behavior.

Annotations
@Override
See Also
AsyncMapping#map(Object, Promise)
newSslHandlerback to summary
protected SslHandler newSslHandler(SslContext context, BufferAllocator allocator)

Returns a new SslHandler using the given SslContext and BufferAllocator. Users may override this method to implement custom behavior.

onLookupCompleteback to summary
protected final void onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<? extends SslContext> future) throws Exception

Implements abstract io.netty5.handler.ssl.AbstractSniHandler.onLookupComplete.

Doc from io.netty5.handler.ssl.AbstractSniHandler.onLookupComplete.

Called upon completion of the lookup(ChannelHandlerContext, String) Future.

Annotations
@Override
replaceHandlerback to summary
protected void replaceHandler(ChannelHandlerContext ctx, String hostname, SslContext sslContext) throws Exception

The default implementation of this method will simply replace this SniHandler instance with a SslHandler. Users may override this method to implement custom behavior. Please be aware that this method may get called after a client has already disconnected and custom implementations must take it into consideration when overriding this method. It's also possible for the hostname argument to be null.

sslContextback to summary
public SslContext sslContext()
Returns:SslContext

the selected SslContext

io.netty5.handler.ssl back to summary

private final Class SniHandler.AsyncMappingAdapter

extends Object
implements AsyncMapping<String, SslContext>
Class Inheritance
All Implemented Interfaces
io.netty5.util.AsyncMapping

Field Summary

Modifier and TypeField and Description
private final Mapping<? super String, ? extends SslContext>

Constructor Summary

AccessConstructor and Description
private
AsyncMappingAdapter(Mapping<? super String, ? extends SslContext> mapping)

Method Summary

Modifier and TypeMethod and Description
public Future<SslContext>
map(String input, Promise<SslContext> promise)

Implements io.netty5.util.AsyncMapping.map.

Returns the Future that will provide the result of the mapping.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mappingback to summary
private final Mapping<? super String, ? extends SslContext> mapping

Constructor Detail

AsyncMappingAdapterback to summary
private AsyncMappingAdapter(Mapping<? super String, ? extends SslContext> mapping)

Method Detail

mapback to summary
public Future<SslContext> map(String input, Promise<SslContext> promise)

Implements io.netty5.util.AsyncMapping.map.

Doc from io.netty5.util.AsyncMapping.map.

Returns the Future that will provide the result of the mapping. The given Promise will be fulfilled when the result is available.

Annotations
@Override
io.netty5.handler.ssl back to summary

private final Class SniHandler.Selection

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final SslContext
pack-priv final String

Constructor Summary

AccessConstructor and Description
pack-priv
Selection(SslContext context, String hostname)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
pack-priv final SslContext context
hostnameback to summary
pack-priv final String hostname

Constructor Detail

Selectionback to summary
pack-priv Selection(SslContext context, String hostname)