Package org.conscrypt

Class Java8EngineWrapper


  • final class Java8EngineWrapper
    extends AbstractConscryptEngine
    A wrapper around ConscryptEngine that adapts to the new Java 9 (and potentially later patches of 8) setHandshakeApplicationProtocolSelector API (which requires Java 8 for compilation, due to the use of BiFunction).
    • Field Detail

      • selector

        private java.util.function.BiFunction<javax.net.ssl.SSLEngine,​java.util.List<java.lang.String>,​java.lang.String> selector
    • Constructor Detail

    • Method Detail

      • getDelegate

        static javax.net.ssl.SSLEngine getDelegate​(javax.net.ssl.SSLEngine engine)
      • wrap

        public javax.net.ssl.SSLEngineResult wrap​(java.nio.ByteBuffer[] byteBuffers,
                                                  java.nio.ByteBuffer byteBuffer)
                                           throws javax.net.ssl.SSLException
        Overrides:
        wrap in class javax.net.ssl.SSLEngine
        Throws:
        javax.net.ssl.SSLException
      • getSSLParameters

        public javax.net.ssl.SSLParameters getSSLParameters()
        Overrides:
        getSSLParameters in class javax.net.ssl.SSLEngine
      • setSSLParameters

        public void setSSLParameters​(javax.net.ssl.SSLParameters sslParameters)
        Overrides:
        setSSLParameters in class javax.net.ssl.SSLEngine
      • getChannelId

        byte[] getChannelId()
                     throws javax.net.ssl.SSLException
        Description copied from class: AbstractConscryptEngine
        Gets the TLS Channel ID for this server engine. Channel ID is only available once the handshake completes.
        Specified by:
        getChannelId in class AbstractConscryptEngine
        Returns:
        channel ID or null if not available.
        Throws:
        javax.net.ssl.SSLException - if channel ID is available but could not be obtained.
      • setChannelIdPrivateKey

        void setChannelIdPrivateKey​(java.security.PrivateKey privateKey)
        Description copied from class: AbstractConscryptEngine
        Sets the PrivateKey to be used for TLS Channel ID by this client engine.

        This method needs to be invoked before the handshake starts.

        Specified by:
        setChannelIdPrivateKey in class AbstractConscryptEngine
        Parameters:
        privateKey - private key (enables TLS Channel ID) or null for no key (disables TLS Channel ID). The private key must be an Elliptic Curve (EC) key based on the NIST P-256 curve (aka SECG secp256r1 or ANSI X9.62 prime256v1).
      • beginHandshake

        public void beginHandshake()
                            throws javax.net.ssl.SSLException
        Specified by:
        beginHandshake in class javax.net.ssl.SSLEngine
        Throws:
        javax.net.ssl.SSLException
      • closeInbound

        public void closeInbound()
                          throws javax.net.ssl.SSLException
        Specified by:
        closeInbound in class javax.net.ssl.SSLEngine
        Throws:
        javax.net.ssl.SSLException
      • closeOutbound

        public void closeOutbound()
        Specified by:
        closeOutbound in class javax.net.ssl.SSLEngine
      • getDelegatedTask

        public java.lang.Runnable getDelegatedTask()
        Specified by:
        getDelegatedTask in class javax.net.ssl.SSLEngine
      • getEnabledCipherSuites

        public java.lang.String[] getEnabledCipherSuites()
        Specified by:
        getEnabledCipherSuites in class javax.net.ssl.SSLEngine
      • getEnabledProtocols

        public java.lang.String[] getEnabledProtocols()
        Specified by:
        getEnabledProtocols in class javax.net.ssl.SSLEngine
      • getEnableSessionCreation

        public boolean getEnableSessionCreation()
        Specified by:
        getEnableSessionCreation in class javax.net.ssl.SSLEngine
      • getHandshakeStatus

        public javax.net.ssl.SSLEngineResult.HandshakeStatus getHandshakeStatus()
        Specified by:
        getHandshakeStatus in class javax.net.ssl.SSLEngine
      • getNeedClientAuth

        public boolean getNeedClientAuth()
        Specified by:
        getNeedClientAuth in class javax.net.ssl.SSLEngine
      • getSession

        public javax.net.ssl.SSLSession getSession()
        Specified by:
        getSession in class javax.net.ssl.SSLEngine
      • getSupportedCipherSuites

        public java.lang.String[] getSupportedCipherSuites()
        Specified by:
        getSupportedCipherSuites in class javax.net.ssl.SSLEngine
      • getSupportedProtocols

        public java.lang.String[] getSupportedProtocols()
        Specified by:
        getSupportedProtocols in class javax.net.ssl.SSLEngine
      • getUseClientMode

        public boolean getUseClientMode()
        Specified by:
        getUseClientMode in class javax.net.ssl.SSLEngine
      • getWantClientAuth

        public boolean getWantClientAuth()
        Specified by:
        getWantClientAuth in class javax.net.ssl.SSLEngine
      • isInboundDone

        public boolean isInboundDone()
        Specified by:
        isInboundDone in class javax.net.ssl.SSLEngine
      • isOutboundDone

        public boolean isOutboundDone()
        Specified by:
        isOutboundDone in class javax.net.ssl.SSLEngine
      • setEnabledCipherSuites

        public void setEnabledCipherSuites​(java.lang.String[] suites)
        Specified by:
        setEnabledCipherSuites in class javax.net.ssl.SSLEngine
      • setEnabledProtocols

        public void setEnabledProtocols​(java.lang.String[] protocols)
        Specified by:
        setEnabledProtocols in class javax.net.ssl.SSLEngine
      • setEnableSessionCreation

        public void setEnableSessionCreation​(boolean flag)
        Specified by:
        setEnableSessionCreation in class javax.net.ssl.SSLEngine
      • setNeedClientAuth

        public void setNeedClientAuth​(boolean need)
        Specified by:
        setNeedClientAuth in class javax.net.ssl.SSLEngine
      • setUseClientMode

        public void setUseClientMode​(boolean mode)
        Specified by:
        setUseClientMode in class javax.net.ssl.SSLEngine
      • setWantClientAuth

        public void setWantClientAuth​(boolean want)
        Specified by:
        setWantClientAuth in class javax.net.ssl.SSLEngine
      • unwrap

        public javax.net.ssl.SSLEngineResult unwrap​(java.nio.ByteBuffer src,
                                                    java.nio.ByteBuffer dst)
                                             throws javax.net.ssl.SSLException
        Specified by:
        unwrap in class AbstractConscryptEngine
        Throws:
        javax.net.ssl.SSLException
      • unwrap

        public javax.net.ssl.SSLEngineResult unwrap​(java.nio.ByteBuffer src,
                                                    java.nio.ByteBuffer[] dsts)
                                             throws javax.net.ssl.SSLException
        Specified by:
        unwrap in class AbstractConscryptEngine
        Throws:
        javax.net.ssl.SSLException
      • unwrap

        public javax.net.ssl.SSLEngineResult unwrap​(java.nio.ByteBuffer src,
                                                    java.nio.ByteBuffer[] dsts,
                                                    int offset,
                                                    int length)
                                             throws javax.net.ssl.SSLException
        Specified by:
        unwrap in class AbstractConscryptEngine
        Throws:
        javax.net.ssl.SSLException
      • unwrap

        javax.net.ssl.SSLEngineResult unwrap​(java.nio.ByteBuffer[] srcs,
                                             java.nio.ByteBuffer[] dsts)
                                      throws javax.net.ssl.SSLException
        Specified by:
        unwrap in class AbstractConscryptEngine
        Throws:
        javax.net.ssl.SSLException
      • unwrap

        javax.net.ssl.SSLEngineResult unwrap​(java.nio.ByteBuffer[] srcs,
                                             int srcsOffset,
                                             int srcsLength,
                                             java.nio.ByteBuffer[] dsts,
                                             int dstsOffset,
                                             int dstsLength)
                                      throws javax.net.ssl.SSLException
        Specified by:
        unwrap in class AbstractConscryptEngine
        Throws:
        javax.net.ssl.SSLException
      • wrap

        public javax.net.ssl.SSLEngineResult wrap​(java.nio.ByteBuffer src,
                                                  java.nio.ByteBuffer dst)
                                           throws javax.net.ssl.SSLException
        Specified by:
        wrap in class AbstractConscryptEngine
        Throws:
        javax.net.ssl.SSLException
      • wrap

        public javax.net.ssl.SSLEngineResult wrap​(java.nio.ByteBuffer[] srcs,
                                                  int srcsOffset,
                                                  int srcsLength,
                                                  java.nio.ByteBuffer dst)
                                           throws javax.net.ssl.SSLException
        Specified by:
        wrap in class AbstractConscryptEngine
        Throws:
        javax.net.ssl.SSLException
      • getTlsUnique

        byte[] getTlsUnique()
        Description copied from class: AbstractConscryptEngine
        Returns the tls-unique channel binding value for this connection, per RFC 5929. This will return null if there is no such value available, such as if the handshake has not yet completed or this connection is closed.
        Specified by:
        getTlsUnique in class AbstractConscryptEngine
      • exportKeyingMaterial

        byte[] exportKeyingMaterial​(java.lang.String label,
                                    byte[] context,
                                    int length)
                             throws javax.net.ssl.SSLException
        Description copied from class: AbstractConscryptEngine
        Exports a value derived from the TLS master secret as described in RFC 5705.
        Specified by:
        exportKeyingMaterial in class AbstractConscryptEngine
        Parameters:
        label - the label to use in calculating the exported value. This must be an ASCII-only string.
        context - the application-specific context value to use in calculating the exported value. This may be null to use no application context, which is treated differently than an empty byte array.
        length - the number of bytes of keying material to return.
        Returns:
        a value of the specified length, or null if the handshake has not yet completed or the connection has been closed.
        Throws:
        javax.net.ssl.SSLException - if the value could not be exported.
      • setHandshakeApplicationProtocolSelector

        public void setHandshakeApplicationProtocolSelector​(java.util.function.BiFunction<javax.net.ssl.SSLEngine,​java.util.List<java.lang.String>,​java.lang.String> selector)
        Overrides:
        setHandshakeApplicationProtocolSelector in class javax.net.ssl.SSLEngine
      • getHandshakeApplicationProtocolSelector

        public java.util.function.BiFunction<javax.net.ssl.SSLEngine,​java.util.List<java.lang.String>,​java.lang.String> getHandshakeApplicationProtocolSelector()
        Overrides:
        getHandshakeApplicationProtocolSelector in class javax.net.ssl.SSLEngine
      • toApplicationProtocolSelector

        private static ApplicationProtocolSelector toApplicationProtocolSelector​(java.util.function.BiFunction<javax.net.ssl.SSLEngine,​java.util.List<java.lang.String>,​java.lang.String> selector)