Class KeyConfig.Builder

java.lang.Object
io.helidon.common.pki.KeyConfig.Builder
All Implemented Interfaces:
Builder<KeyConfig.Builder,KeyConfig>, Supplier<KeyConfig>
Enclosing class:
KeyConfig

public static class KeyConfig.Builder extends Object implements Builder<KeyConfig.Builder,KeyConfig>
Fluent API builder for KeyConfig. Call build() to create an instance. The keys may be loaded from multiple possible sources.
See Also:
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • build

      public KeyConfig build() throws PkiException
      Build a new instance of the configuration based on this builder.
      Specified by:
      build in interface Builder<KeyConfig.Builder,KeyConfig>
      Returns:
      instance from this builder
      Throws:
      PkiException - when keys or certificates fail to load from keystore or when misconfigured
    • privateKey

      public KeyConfig.Builder privateKey(PrivateKey privateKey)
      Configure a private key instance (rather then keystore and alias).
      Parameters:
      privateKey - private key instance
      Returns:
      updated builder instance
    • publicKey

      public KeyConfig.Builder publicKey(PublicKey publicKey)
      Configure a public key instance (rather then keystore and certificate alias).
      Parameters:
      publicKey - private key instance
      Returns:
      updated builder instance
    • publicKeyCert

      public KeyConfig.Builder publicKeyCert(X509Certificate certificate)
      Configure an X.509 certificate instance for public key certificate.
      Parameters:
      certificate - certificate instance
      Returns:
      updated builder instance
    • addCertChain

      public KeyConfig.Builder addCertChain(X509Certificate certificate)
      Add an X.509 certificate instance to the end of certification chain.
      Parameters:
      certificate - certificate to add to certification path
      Returns:
      updated builder instance
    • addCert

      public KeyConfig.Builder addCert(X509Certificate certificate)
      Add a certificate to the list of certificates, used e.g. in a trust store.
      Parameters:
      certificate - X.509 certificate to trust
      Returns:
      updated builder instance
    • updateWith

      public KeyConfig.Builder updateWith(KeyConfig.PemBuilder builder)
      Update this builder with information from a pem builder.
      Parameters:
      builder - builder obtained from KeyConfig.pemBuilder()
      Returns:
      updated builder instance
    • updateWith

      public KeyConfig.Builder updateWith(KeyConfig.KeystoreBuilder builder)
      Update this builder with information from a keystore builder.
      Parameters:
      builder - builder obtained from KeyConfig.keystoreBuilder() ()}
      Returns:
      updated builder instance
    • config

      public KeyConfig.Builder config(Config config)
      Updated this builder instance from configuration. Keys configured will override existing fields in this builder, others will be left intact. If certification path is already defined, configuration based cert-path will be added.
      Parameters:
      config - configuration to update this builder from
      Returns:
      updated builder instance