Class TlsConfig.BuilderBase<BUILDER extends TlsConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends TlsConfig>

java.lang.Object
io.helidon.common.tls.TlsMaterial.BuilderBase<BUILDER, PROTOTYPE>
io.helidon.common.tls.TlsConfig.BuilderBase<BUILDER, PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER, PROTOTYPE>, ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
Direct Known Subclasses:
TlsConfig.Builder
Enclosing interface:
TlsConfig

public abstract static class TlsConfig.BuilderBase<BUILDER extends TlsConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends TlsConfig> extends TlsMaterial.BuilderBase<BUILDER, PROTOTYPE> implements ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
Fluent API builder base for TlsConfig.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(TlsConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(TlsConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • config

      public BUILDER config(Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface ConfigBuilderSupport.ConfiguredBuilder<BUILDER extends TlsConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends TlsConfig>
      Overrides:
      config in class TlsMaterial.BuilderBase<BUILDER extends TlsConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends TlsConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • clearSslContext

      public BUILDER clearSslContext()
      Clear existing value of sslContext.
      Returns:
      updated builder instance
      See Also:
    • sslContext

      public BUILDER sslContext(SSLContext sslContext)
      Provide a fully configured SSLContext. If defined, a custom TLS manager and options for context creation, key or trust material, session cache size, and session timeout cannot be configured, and reload of Tls is not supported and will throw an exception. Engine-level options such as enabled protocols, cipher suites, client authentication, and application protocols are supported and are applied to engines created by the context.
      Parameters:
      sslContext - SSL context to use
      Returns:
      updated builder instance
      See Also:
    • manager

      public BUILDER manager(TlsManager manager)
      The configured TLS manager. If one is not explicitly defined in the config then a default manager will be created. Default is either a configuration based TLS manager, or an explicit manager when sslContext() is provided. A Tls instance backed by the default ConfiguredTlsManager uses an isolated runtime manager, so this method returns its configured prototype rather than its runtime manager. Use Tls.generation() to obtain the runtime manager's material generation.
      Parameters:
      manager - the configured TLS manager
      Returns:
      updated builder instance
      See Also:
    • clearSslParameters

      public BUILDER clearSslParameters()
      Clear existing value of sslParameters.
      Returns:
      updated builder instance
      See Also:
    • sslParameters

      public BUILDER sslParameters(SSLParameters sslParameters)
      Configure SSL parameters. This will always have a value, as we compute ssl parameters in a builder interceptor from configured options.
      Parameters:
      sslParameters - SSL parameters to use
      Returns:
      updated builder instance
      See Also:
    • clearApplicationProtocols

      public BUILDER clearApplicationProtocols()
      Clear all applicationProtocols.
      Returns:
      updated builder instance
      See Also:
    • applicationProtocols

      public BUILDER applicationProtocols(List<String> applicationProtocols)
      Configure list of supported application protocols (such as h2) for application layer protocol negotiation (ALPN).
      Parameters:
      applicationProtocols - application protocols
      Returns:
      updated builder instance
      See Also:
    • addApplicationProtocols

      public BUILDER addApplicationProtocols(List<String> applicationProtocols)
      Configure list of supported application protocols (such as h2) for application layer protocol negotiation (ALPN).
      Parameters:
      applicationProtocols - application protocols
      Returns:
      updated builder instance
      See Also:
    • addApplicationProtocol

      public BUILDER addApplicationProtocol(String applicationProtocol)
      Configure list of supported application protocols (such as h2) for application layer protocol negotiation (ALPN).
      Parameters:
      applicationProtocol - add single application protocols
      Returns:
      updated builder instance
      See Also:
    • endpointIdentificationAlgorithm

      public BUILDER endpointIdentificationAlgorithm(String endpointIdentificationAlgorithm)
      Identification algorithm for SSL endpoints.
      Parameters:
      endpointIdentificationAlgorithm - configure endpoint identification algorithm, or set to NONE to disable endpoint identification (equivalent to hostname verification). Defaults to "HTTPS"
      Returns:
      updated builder instance
      See Also:
    • enabled

      public BUILDER enabled(boolean enabled)
      Flag indicating whether Tls is enabled. When disabled, all other configuration is ignored.
      Parameters:
      enabled - enabled flag
      Returns:
      updated builder instance
      See Also:
    • clientAuth

      public BUILDER clientAuth(TlsClientAuth clientAuth)
      Configure requirement for mutual TLS.
      Parameters:
      clientAuth - what type of mutual TLS to use, defaults to TlsClientAuth.NONE
      Returns:
      updated builder instance
      See Also:
    • protocol

      public BUILDER protocol(String protocol)
      Configure the protocol used to obtain an instance of SSLContext.
      Parameters:
      protocol - protocol to use, defaults to "TLS"
      Returns:
      updated builder instance
      See Also:
    • clearProvider

      public BUILDER clearProvider()
      Clear existing value of provider.
      Returns:
      updated builder instance
      See Also:
    • provider

      public BUILDER provider(String provider)
      Use explicit provider to obtain an instance of SSLContext.
      Parameters:
      provider - provider to use, defaults to none (only protocol() is used by default)
      Returns:
      updated builder instance
      See Also:
    • clearEnabledCipherSuites

      public BUILDER clearEnabledCipherSuites()
      Clear all enabledCipherSuites.
      Returns:
      updated builder instance
      See Also:
    • enabledCipherSuites

      public BUILDER enabledCipherSuites(List<String> enabledCipherSuites)
      Enabled cipher suites for TLS communication.
      Parameters:
      enabledCipherSuites - cipher suites to enable, by default (or if list is empty), all available cipher suites are enabled
      Returns:
      updated builder instance
      See Also:
    • addEnabledCipherSuites

      public BUILDER addEnabledCipherSuites(List<String> enabledCipherSuites)
      Enabled cipher suites for TLS communication.
      Parameters:
      enabledCipherSuites - cipher suites to enable, by default (or if list is empty), all available cipher suites are enabled
      Returns:
      updated builder instance
      See Also:
    • addEnabledCipherSuite

      public BUILDER addEnabledCipherSuite(String enabledCipherSuite)
      Enabled cipher suites for TLS communication.
      Parameters:
      enabledCipherSuite - add single cipher suites to enable, by default (or if list is empty), all available cipher suites are enabled
      Returns:
      updated builder instance
      See Also:
    • clearEnabledProtocols

      public BUILDER clearEnabledProtocols()
      Clear all enabledProtocols.
      Returns:
      updated builder instance
      See Also:
    • enabledProtocols

      public BUILDER enabledProtocols(List<String> enabledProtocols)
      Enabled protocols for TLS communication. Example of valid values for TLS protocol: TLSv1.3, TLSv1.2
      Parameters:
      enabledProtocols - protocols to enable, by default (or if list is empty), all available protocols are enabled
      Returns:
      updated builder instance
      See Also:
    • addEnabledProtocols

      public BUILDER addEnabledProtocols(List<String> enabledProtocols)
      Enabled protocols for TLS communication. Example of valid values for TLS protocol: TLSv1.3, TLSv1.2
      Parameters:
      enabledProtocols - protocols to enable, by default (or if list is empty), all available protocols are enabled
      Returns:
      updated builder instance
      See Also:
    • addEnabledProtocol

      public BUILDER addEnabledProtocol(String enabledProtocol)
      Enabled protocols for TLS communication. Example of valid values for TLS protocol: TLSv1.3, TLSv1.2
      Parameters:
      enabledProtocol - add single protocols to enable, by default (or if list is empty), all available protocols are enabled
      Returns:
      updated builder instance
      See Also:
    • sessionCacheSize

      public BUILDER sessionCacheSize(int sessionCacheSize)
      SSL session cache size.
      Parameters:
      sessionCacheSize - session cache size, defaults to 20480.
      Returns:
      updated builder instance
      See Also:
    • sessionTimeout

      public BUILDER sessionTimeout(Duration sessionTimeout)
      SSL session timeout.
      Parameters:
      sessionTimeout - session timeout, defaults to "PT24H".
      Returns:
      updated builder instance
      See Also:
    • managerDiscoverServices

      public BUILDER managerDiscoverServices(boolean managerDiscoverServices)
      Service discovery flag for manager(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Parameters:
      managerDiscoverServices - whether to enable automatic service discovery
      Returns:
      updated builder instance
      See Also:
    • sslContext

      public Optional<SSLContext> sslContext()
      Provide a fully configured SSLContext. If defined, a custom TLS manager and options for context creation, key or trust material, session cache size, and session timeout cannot be configured, and reload of Tls is not supported and will throw an exception. Engine-level options such as enabled protocols, cipher suites, client authentication, and application protocols are supported and are applied to engines created by the context.
      Returns:
      SSL context to use
    • manager

      public Optional<TlsManager> manager()
      The configured TLS manager. If one is not explicitly defined in the config then a default manager will be created. Default is either a configuration based TLS manager, or an explicit manager when sslContext() is provided. A Tls instance backed by the default ConfiguredTlsManager uses an isolated runtime manager, so this method returns its configured prototype rather than its runtime manager. Use Tls.generation() to obtain the runtime manager's material generation.
      Returns:
      the configured TLS manager
      See Also:
    • sslParameters

      public Optional<SSLParameters> sslParameters()
      Configure SSL parameters. This will always have a value, as we compute ssl parameters in a builder interceptor from configured options.
      Returns:
      SSL parameters to use
    • applicationProtocols

      public List<String> applicationProtocols()
      Configure list of supported application protocols (such as h2) for application layer protocol negotiation (ALPN).
      Returns:
      application protocols
    • endpointIdentificationAlgorithm

      public String endpointIdentificationAlgorithm()
      Identification algorithm for SSL endpoints.
      Returns:
      configure endpoint identification algorithm, or set to NONE to disable endpoint identification (equivalent to hostname verification). Defaults to "HTTPS"
    • enabled

      public boolean enabled()
      Flag indicating whether Tls is enabled. When disabled, all other configuration is ignored.
      Returns:
      enabled flag
    • clientAuth

      public TlsClientAuth clientAuth()
      Configure requirement for mutual TLS.
      Returns:
      what type of mutual TLS to use, defaults to TlsClientAuth.NONE
    • protocol

      public String protocol()
      Configure the protocol used to obtain an instance of SSLContext.
      Returns:
      protocol to use, defaults to "TLS"
    • provider

      public Optional<String> provider()
      Use explicit provider to obtain an instance of SSLContext.
      Returns:
      provider to use, defaults to none (only protocol() is used by default)
    • enabledCipherSuites

      public List<String> enabledCipherSuites()
      Enabled cipher suites for TLS communication.
      Returns:
      cipher suites to enable, by default (or if list is empty), all available cipher suites are enabled
    • enabledProtocols

      public List<String> enabledProtocols()
      Enabled protocols for TLS communication. Example of valid values for TLS protocol: TLSv1.3, TLSv1.2
      Returns:
      protocols to enable, by default (or if list is empty), all available protocols are enabled
    • sessionCacheSize

      public int sessionCacheSize()
      SSL session cache size.
      Returns:
      session cache size, defaults to 20480.
    • sessionTimeout

      public Duration sessionTimeout()
      SSL session timeout.
      Returns:
      session timeout, defaults to "PT24H".
    • managerDiscoverServices

      public boolean managerDiscoverServices()
      Service discovery flag for manager(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Returns:
      whether to enable automatic service discovery
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class TlsMaterial.BuilderBase<BUILDER extends TlsConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends TlsConfig>
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
      Overrides:
      preBuildPrototype in class TlsMaterial.BuilderBase<BUILDER extends TlsConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends TlsConfig>
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.
      Overrides:
      validatePrototype in class TlsMaterial.BuilderBase<BUILDER extends TlsConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends TlsConfig>