public class OptionalSslConnectionFactory extends AbstractConnectionFactory
A ConnectionFactory whose connections detect whether the first bytes are TLS bytes and upgrades to either a TLS connection or to another configurable connection.
Modifier and Type | Class and Description |
---|---|
private class |
OptionalSslConnectionFactory.OptionalSslConnection |
AbstractLifeCycle.AbstractLifeCycleListener
ConnectionFactory.Upgrading
Container.InheritedListener, Container.Listener
LifeCycle.Listener
Modifier and Type | Field and Description |
---|---|
private static Logger |
LOG |
private java.lang.String |
otherProtocol |
private SslConnectionFactory |
sslConnectionFactory |
private static int |
TLS_ALERT_FRAME_TYPE |
private static int |
TLS_HANDSHAKE_FRAME_TYPE |
private static int |
TLS_MAJOR_VERSION |
Constructor and Description |
---|
OptionalSslConnectionFactory(SslConnectionFactory sslConnectionFactory,
java.lang.String otherProtocol)
Creates a new ConnectionFactory whose connections can upgrade to TLS or another protocol.
|
Modifier and Type | Method and Description |
---|---|
Connection |
newConnection(Connector connector,
EndPoint endPoint)
Creates a new
Connection with the given parameters |
protected void |
otherProtocol(java.nio.ByteBuffer buffer,
EndPoint endPoint)
Callback method invoked when
otherProtocol is null
and the first bytes are not TLS. |
protected boolean |
seemsTLS(java.nio.ByteBuffer buffer) |
configure, getFactories, getInputBufferSize, getProtocol, getProtocols, setInputBufferSize, toString
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, doStop, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dumpContainer, dumpIterable, dumpMapEntries, dumpObjects, dumpSelf, named
private static final Logger LOG
private static final int TLS_ALERT_FRAME_TYPE
private static final int TLS_HANDSHAKE_FRAME_TYPE
private static final int TLS_MAJOR_VERSION
private final SslConnectionFactory sslConnectionFactory
private final java.lang.String otherProtocol
public OptionalSslConnectionFactory(SslConnectionFactory sslConnectionFactory, java.lang.String otherProtocol)
Creates a new ConnectionFactory whose connections can upgrade to TLS or another protocol.
If otherProtocol
is null
, and the first bytes are not TLS, then
otherProtocol(ByteBuffer, EndPoint)
is called.
sslConnectionFactory
- The SslConnectionFactory to use if the first bytes are TLSotherProtocol
- the protocol of the ConnectionFactory to use if the first bytes are not TLS,
or null to explicitly handle the non-TLS casepublic Connection newConnection(Connector connector, EndPoint endPoint)
ConnectionFactory
Creates a new Connection
with the given parameters
connector
- The Connector
creating this connectionendPoint
- the EndPoint
associated with the connectionConnection
protected boolean seemsTLS(java.nio.ByteBuffer buffer)
buffer
- The buffer with the first bytes of the connectionprotected void otherProtocol(java.nio.ByteBuffer buffer, EndPoint endPoint)
Callback method invoked when otherProtocol
is null
and the first bytes are not TLS.
This typically happens when a client is trying to connect to a TLS
port using the http
scheme (and not the https
scheme).
buffer
- The buffer with the first bytes of the connectionendPoint
- The connection EndPoint objectseemsTLS(ByteBuffer)