Class OptionalSslConnectionFactory

  • All Implemented Interfaces:
    ConnectionFactory, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.LifeCycle

    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.

    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

        org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

        org.eclipse.jetty.util.component.LifeCycle.Listener
    • Field Summary

      • Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
      • Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

        KEY
    • Constructor Summary

      Constructors 
      Constructor Description
      OptionalSslConnectionFactory​(SslConnectionFactory sslConnectionFactory, java.lang.String otherProtocol)
      Creates a new ConnectionFactory whose connections can upgrade to TLS or another protocol.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.eclipse.jetty.io.Connection newConnection​(Connector connector, org.eclipse.jetty.io.EndPoint endPoint)
      Creates a new Connection with the given parameters
      protected void otherProtocol​(java.nio.ByteBuffer buffer, org.eclipse.jetty.io.EndPoint endPoint)
      Callback method invoked when otherProtocol is null and the first bytes are not TLS.
      protected boolean seemsTLS​(java.nio.ByteBuffer buffer)  
      • Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

        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
      • Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

        dumpSelf
    • Constructor Detail

      • OptionalSslConnectionFactory

        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.

        Parameters:
        sslConnectionFactory - The SslConnectionFactory to use if the first bytes are TLS
        otherProtocol - the protocol of the ConnectionFactory to use if the first bytes are not TLS, or null to explicitly handle the non-TLS case
    • Method Detail

      • newConnection

        public org.eclipse.jetty.io.Connection newConnection​(Connector connector,
                                                             org.eclipse.jetty.io.EndPoint endPoint)
        Description copied from interface: ConnectionFactory

        Creates a new Connection with the given parameters

        Parameters:
        connector - The Connector creating this connection
        endPoint - the EndPoint associated with the connection
        Returns:
        a new Connection
      • seemsTLS

        protected boolean seemsTLS​(java.nio.ByteBuffer buffer)
        Parameters:
        buffer - The buffer with the first bytes of the connection
        Returns:
        whether the bytes seem TLS bytes
      • otherProtocol

        protected void otherProtocol​(java.nio.ByteBuffer buffer,
                                     org.eclipse.jetty.io.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).

        Parameters:
        buffer - The buffer with the first bytes of the connection
        endPoint - The connection EndPoint object
        See Also:
        seemsTLS(ByteBuffer)