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

java.lang.Object
io.helidon.common.tls.TlsMaterial.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.BuilderBase, TlsMaterial.Builder
Enclosing interface:
TlsMaterial

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

    • BuilderBase

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

    • from

      public BUILDER from(TlsMaterial 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(TlsMaterial.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 TlsMaterial.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends TlsMaterial>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • clearPrivateKey

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

      public BUILDER privateKey(PrivateKey privateKey)
      Private key to use. This is required when reloading key material and can be omitted when reloading only trust material.
      Parameters:
      privateKey - private key to use
      Returns:
      updated builder instance
      See Also:
    • privateKey

      public BUILDER privateKey(Keys privateKey)
      Private key to use. This is required when reloading key material and can be omitted when reloading only trust material.
      Parameters:
      privateKey - prototype of private key to use
      Returns:
      updated builder instance
      See Also:
    • privateKey

      public BUILDER privateKey(Consumer<Keys.Builder> consumer)
      Private key to use. This is required when reloading key material and can be omitted when reloading only trust material.
      Parameters:
      consumer - consumer of builder of private key to use
      Returns:
      updated builder instance
      See Also:
    • clearPrivateKeyCertChain

      public BUILDER clearPrivateKeyCertChain()
      Clear all privateKeyCertChain.
      Returns:
      updated builder instance
      See Also:
    • privateKeyCertChain

      public BUILDER privateKeyCertChain(List<? extends X509Certificate> privateKeyCertChain)
      Certificate chain of the private key.
      Parameters:
      privateKeyCertChain - private key certificate chain, only used when private key is configured
      Returns:
      updated builder instance
      See Also:
    • privateKeyCertChain

      public BUILDER privateKeyCertChain(Keys privateKeyCertChain)
      Certificate chain of the private key.
      Parameters:
      privateKeyCertChain - prototype of private key certificate chain, only used when private key is configured
      Returns:
      updated builder instance
      See Also:
    • privateKeyCertChain

      public BUILDER privateKeyCertChain(Consumer<Keys.Builder> consumer)
      Certificate chain of the private key.
      Parameters:
      consumer - consumer of builder of private key certificate chain, only used when private key is configured
      Returns:
      updated builder instance
      See Also:
    • addPrivateKeyCertChain

      public BUILDER addPrivateKeyCertChain(List<? extends X509Certificate> privateKeyCertChain)
      Certificate chain of the private key.
      Parameters:
      privateKeyCertChain - private key certificate chain, only used when private key is configured
      Returns:
      updated builder instance
      See Also:
    • addPrivateKeyCertChain

      public BUILDER addPrivateKeyCertChain(X509Certificate privateKeyCertChain)
      Certificate chain of the private key.
      Parameters:
      privateKeyCertChain - add single private key certificate chain, only used when private key is configured
      Returns:
      updated builder instance
      See Also:
    • clearTrust

      public BUILDER clearTrust()
      Clear all trust.
      Returns:
      updated builder instance
      See Also:
    • trust

      public BUILDER trust(List<? extends X509Certificate> trust)
      List of certificates that form the trust manager.
      Parameters:
      trust - certificates to be trusted
      Returns:
      updated builder instance
      See Also:
    • trust

      public BUILDER trust(Keys trust)
      List of certificates that form the trust manager.
      Parameters:
      trust - prototype of certificates to be trusted
      Returns:
      updated builder instance
      See Also:
    • trust

      public BUILDER trust(Consumer<Keys.Builder> consumer)
      List of certificates that form the trust manager.
      Parameters:
      consumer - consumer of builder of certificates to be trusted
      Returns:
      updated builder instance
      See Also:
    • addTrust

      public BUILDER addTrust(List<? extends X509Certificate> trust)
      List of certificates that form the trust manager.
      Parameters:
      trust - certificates to be trusted
      Returns:
      updated builder instance
      See Also:
    • addTrust

      public BUILDER addTrust(X509Certificate trust)
      List of certificates that form the trust manager.
      Parameters:
      trust - add single certificates to be trusted
      Returns:
      updated builder instance
      See Also:
    • clearSecureRandom

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

      public BUILDER secureRandom(SecureRandom secureRandom)
      Explicit secure random to use.
      Parameters:
      secureRandom - secure random to use
      Returns:
      updated builder instance
      See Also:
    • clearSecureRandomProvider

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

      public BUILDER secureRandomProvider(String secureRandomProvider)
      Provider to use when creating a new secure random. When defined, secureRandomAlgorithm() must be defined as well.
      Parameters:
      secureRandomProvider - provider to use, by default no provider is specified
      Returns:
      updated builder instance
      See Also:
    • clearSecureRandomAlgorithm

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

      public BUILDER secureRandomAlgorithm(String secureRandomAlgorithm)
      Algorithm to use when creating a new secure random.
      Parameters:
      secureRandomAlgorithm - algorithm to use, by default uses SecureRandom constructor
      Returns:
      updated builder instance
      See Also:
    • clearKeyManagerFactoryAlgorithm

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

      public BUILDER keyManagerFactoryAlgorithm(String keyManagerFactoryAlgorithm)
      Algorithm of the key manager factory used when private key is defined. Defaults to KeyManagerFactory.getDefaultAlgorithm().
      Parameters:
      keyManagerFactoryAlgorithm - algorithm to use
      Returns:
      updated builder instance
      See Also:
    • clearKeyManagerFactoryProvider

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

      public BUILDER keyManagerFactoryProvider(String keyManagerFactoryProvider)
      Key manager factory provider.
      Parameters:
      keyManagerFactoryProvider - provider to use
      Returns:
      updated builder instance
      See Also:
    • clearTrustManagerFactoryAlgorithm

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

      public BUILDER trustManagerFactoryAlgorithm(String trustManagerFactoryAlgorithm)
      Trust manager factory algorithm.
      Parameters:
      trustManagerFactoryAlgorithm - algorithm to use
      Returns:
      updated builder instance
      See Also:
    • clearTrustManagerFactoryProvider

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

      public BUILDER trustManagerFactoryProvider(String trustManagerFactoryProvider)
      Trust manager factory provider to use.
      Parameters:
      trustManagerFactoryProvider - provider to use
      Returns:
      updated builder instance
      See Also:
    • trustAll

      public BUILDER trustAll(boolean trustAll)
      Trust any certificate provided by the other side of communication.

      This is a dangerous setting: if set to true, any certificate will be accepted, throwing away most of the security advantages of TLS. NEVER do this in production.

      Parameters:
      trustAll - whether to trust all certificates, do not use in production
      Returns:
      updated builder instance
      See Also:
    • clearInternalKeystoreType

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

      public BUILDER internalKeystoreType(String internalKeystoreType)
      Type of the key stores used internally to create a key and trust manager factories.
      Parameters:
      internalKeystoreType - keystore type, defaults to KeyStore.getDefaultType()
      Returns:
      updated builder instance
      See Also:
    • clearInternalKeystoreProvider

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

      public BUILDER internalKeystoreProvider(String internalKeystoreProvider)
      Provider of the key stores used internally to create a key and trust manager factories.
      Parameters:
      internalKeystoreProvider - keystore provider, if not defined, provider is not specified
      Returns:
      updated builder instance
      See Also:
    • clearRevocation

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

      public BUILDER revocation(RevocationConfig revocation)
      Certificate revocation check configuration.
      Parameters:
      revocation - certificate revocation configuration
      Returns:
      updated builder instance
      See Also:
    • revocation

      public BUILDER revocation(Consumer<RevocationConfig.Builder> consumer)
      Certificate revocation check configuration.
      Parameters:
      consumer - consumer of builder of certificate revocation configuration
      Returns:
      updated builder instance
      See Also:
    • revocation

      public BUILDER revocation(Supplier<? extends RevocationConfig> supplier)
      Certificate revocation check configuration.
      Parameters:
      supplier - supplier of certificate revocation configuration
      Returns:
      updated builder instance
      See Also:
    • privateKey

      public Optional<PrivateKey> privateKey()
      Private key to use. This is required when reloading key material and can be omitted when reloading only trust material.
      Returns:
      private key to use
    • privateKeyCertChain

      public List<X509Certificate> privateKeyCertChain()
      Certificate chain of the private key.
      Returns:
      private key certificate chain, only used when private key is configured
    • trust

      public List<X509Certificate> trust()
      List of certificates that form the trust manager.
      Returns:
      certificates to be trusted
    • secureRandom

      public Optional<SecureRandom> secureRandom()
      Explicit secure random to use.
      Returns:
      secure random to use
    • secureRandomProvider

      public Optional<String> secureRandomProvider()
      Provider to use when creating a new secure random. When defined, secureRandomAlgorithm() must be defined as well.
      Returns:
      provider to use, by default no provider is specified
    • secureRandomAlgorithm

      public Optional<String> secureRandomAlgorithm()
      Algorithm to use when creating a new secure random.
      Returns:
      algorithm to use, by default uses SecureRandom constructor
    • keyManagerFactoryAlgorithm

      public Optional<String> keyManagerFactoryAlgorithm()
      Algorithm of the key manager factory used when private key is defined. Defaults to KeyManagerFactory.getDefaultAlgorithm().
      Returns:
      algorithm to use
    • keyManagerFactoryProvider

      public Optional<String> keyManagerFactoryProvider()
      Key manager factory provider.
      Returns:
      provider to use
    • trustManagerFactoryAlgorithm

      public Optional<String> trustManagerFactoryAlgorithm()
      Trust manager factory algorithm.
      Returns:
      algorithm to use
    • trustManagerFactoryProvider

      public Optional<String> trustManagerFactoryProvider()
      Trust manager factory provider to use.
      Returns:
      provider to use
    • trustAll

      public boolean trustAll()
      Trust any certificate provided by the other side of communication.

      This is a dangerous setting: if set to true, any certificate will be accepted, throwing away most of the security advantages of TLS. NEVER do this in production.

      Returns:
      whether to trust all certificates, do not use in production
    • internalKeystoreType

      public Optional<String> internalKeystoreType()
      Type of the key stores used internally to create a key and trust manager factories.
      Returns:
      keystore type, defaults to KeyStore.getDefaultType()
    • internalKeystoreProvider

      public Optional<String> internalKeystoreProvider()
      Provider of the key stores used internally to create a key and trust manager factories.
      Returns:
      keystore provider, if not defined, provider is not specified
    • revocation

      public Optional<RevocationConfig> revocation()
      Certificate revocation check configuration.
      Returns:
      certificate revocation configuration
    • toString

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

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.
    • config

      protected Optional<Config> config()
      Configuration used to configure this instance.
      Returns:
      config instance