Class SSLEngineConfigurator

java.lang.Object
org.glassfish.grizzly.ssl.SSLEngineConfigurator
All Implemented Interfaces:
SSLEngineFactory

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

    • sslContextConfiguration

      protected volatile SSLContextConfigurator sslContextConfiguration
    • sslContext

      protected volatile SSLContext sslContext
    • clientMode

      protected boolean clientMode
      Client mode when handshaking.
  • Constructor Details

    • SSLEngineConfigurator

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

      public SSLEngineConfigurator(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)
      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.
    • 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

      public SSLEngineConfigurator(SSLEngineConfigurator pattern)
    • SSLEngineConfigurator

      protected SSLEngineConfigurator()
  • Method Details

    • createSSLEngine

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

      public SSLEngine createSSLEngine(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 SSLEngine configure(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()
    • setNeedClientAuth

      public SSLEngineConfigurator setNeedClientAuth(boolean needClientAuth)
    • isWantClientAuth

      public boolean isWantClientAuth()
    • setWantClientAuth

      public SSLEngineConfigurator setWantClientAuth(boolean wantClientAuth)
    • setSSLParameters

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

      public 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(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 String[] getEnabledProtocols()
      Returns:
      an array of enabled protocols. Modifications made on the array content won't be propagated to SSLEngineConfigurator
    • setEnabledProtocols

      public SSLEngineConfigurator setEnabledProtocols(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 SSLContext getSslContext()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • copy

      public SSLEngineConfigurator copy()