Class SSLEngineConfigurator

  • All Implemented Interfaces:
    SSLEngineFactory

    public class SSLEngineConfigurator
    extends java.lang.Object
    implements SSLEngineFactory
    Utility class, which helps to configure SSLEngine.
    Author:
    Alexey Stashok
    • Field Detail

      • sslContext

        protected volatile javax.net.ssl.SSLContext sslContext
      • clientMode

        protected boolean clientMode
        Client mode when handshaking.
    • Constructor Detail

      • SSLEngineConfigurator

        public SSLEngineConfigurator​(javax.net.ssl.SSLContext sslContext)
        Create SSL Engine configuration basing on passed SSLContext.
        Parameters:
        sslContext - SSLContext.
      • SSLEngineConfigurator

        public SSLEngineConfigurator​(javax.net.ssl.SSLContext sslContext,
                                     boolean clientMode,
                                     boolean needClientAuth,
                                     boolean wantClientAuth)
        Create SSL Engine configuration basing on passed SSLContext, using passed client mode, need/want client auth parameters.
        Parameters:
        sslContext - SSLContext.
        clientMode -
        needClientAuth -
        wantClientAuth -
      • SSLEngineConfigurator

        public SSLEngineConfigurator​(SSLContextConfigurator sslContextConfiguration,
                                     boolean clientMode,
                                     boolean needClientAuth,
                                     boolean wantClientAuth)
        Create SSL Engine configuration basing on passed SSLContextConfigurator. This constructor makes possible to initialize SSLEngine and SSLContext in lazy fashion on first createSSLEngine() call.
        Parameters:
        sslContextConfiguration - SSLContextConfigurator.
        clientMode -
        needClientAuth -
        wantClientAuth -
      • SSLEngineConfigurator

        protected SSLEngineConfigurator()
    • Method Detail

      • createSSLEngine

        public javax.net.ssl.SSLEngine createSSLEngine()
        Create and configure SSLEngine using this context configuration.
        Returns:
        SSLEngine.
      • createSSLEngine

        public javax.net.ssl.SSLEngine createSSLEngine​(java.lang.String peerHost,
                                                       int peerPort)
        Create and configure SSLEngine using this context configuration using advisory peer information.

        Applications using this factory method are providing hints for an internal session reuse strategy.

        Some cipher suites (such as Kerberos) require remote hostname information, in which case peerHost needs to be specified.

        Specified by:
        createSSLEngine in interface SSLEngineFactory
        Parameters:
        peerHost - the non-authoritative name of the host
        peerPort - the non-authoritative port
        Returns:
        SSLEngine.
      • configure

        public javax.net.ssl.SSLEngine configure​(javax.net.ssl.SSLEngine sslEngine)
        Configure passed SSLEngine, using current configurator settings
        Parameters:
        sslEngine - SSLEngine to configure.
        Returns:
        configured SSLEngine.
      • isClientMode

        public boolean isClientMode()
        Will SSLEngine be configured to work in client mode.
        Returns:
        true, if SSLEngine will be configured to work in client mode, or false for server mode.
      • setClientMode

        public SSLEngineConfigurator setClientMode​(boolean clientMode)
        Set SSLEngine to be configured to work in client mode.
        Parameters:
        clientMode - true, if SSLEngine will be configured to work in client mode, or false for server mode.
        Returns:
        this SSLEngineConfigurator
      • isNeedClientAuth

        public boolean isNeedClientAuth()
      • isWantClientAuth

        public boolean isWantClientAuth()
      • setSSLParameters

        public SSLEngineConfigurator setSSLParameters​(javax.net.ssl.SSLParameters sslParameters)
        Apply SSLParameters to this SSLEngineConfigurator.
        Parameters:
        sslParameters -
        Returns:
        this SSLEngineConfigurator
      • getEnabledCipherSuites

        public java.lang.String[] getEnabledCipherSuites()
        Returns:
        an array of enabled cipher suites. Modifications made on the array content won't be propagated to SSLEngineConfigurator
      • setEnabledCipherSuites

        public SSLEngineConfigurator setEnabledCipherSuites​(java.lang.String[] enabledCipherSuites)
        Sets a list of enabled cipher suites. Note: further modifications made on the passed array won't be propagated to SSLEngineConfigurator.
        Parameters:
        enabledCipherSuites - list of enabled cipher suites
        Returns:
        this SSLEngineConfigurator
      • getEnabledProtocols

        public java.lang.String[] getEnabledProtocols()
        Returns:
        an array of enabled protocols. Modifications made on the array content won't be propagated to SSLEngineConfigurator
      • setEnabledProtocols

        public SSLEngineConfigurator setEnabledProtocols​(java.lang.String[] enabledProtocols)
        Sets a list of enabled protocols. Note: further modifications made on the passed array won't be propagated to SSLEngineConfigurator.
        Parameters:
        enabledProtocols - list of enabled protocols
        Returns:
        this SSLEngineConfigurator
      • getSslContext

        public javax.net.ssl.SSLContext getSslContext()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object