Class SignatureSpec.Builder

java.lang.Object
net.visma.autopay.http.signature.SignatureSpec.Builder
Enclosing class:
SignatureSpec

public static class SignatureSpec.Builder extends Object
Builder class to build SignatureSpec objects.

Private key must be provided as either PrivateKey object, or PKCS#8-encoded byte[] or PKCS#8-Base64-encoded String. Signature parameters must be provided, and they must contain the signature algorithm. Signature label must be provided.

  • Method Details

    • parameters

      public SignatureSpec.Builder parameters(SignatureParameters parameters)
      Sets Signature Parameters
      Parameters:
      parameters - Signature Parameters used to create signature
      Returns:
      This builder
    • components

      public SignatureSpec.Builder components(SignatureComponents components)
      Sets required Signature Components

      If related values are not provided in the Signature Context, e.g. missing HTTP header value, an exception will be thrown when computing the signature.

      Parameters:
      components - Required Signature Components
      Returns:
      This builder
    • usedIfPresentComponents

      public SignatureSpec.Builder usedIfPresentComponents(SignatureComponents components)
      Sets Signature Components included in the signature only if related values are present in the Signature Context.

      usedIfPresentComponents are added to Signature-Input after required components

      Parameters:
      components - Signature Components used uif present in the Signature Context
      Returns:
      This builder
    • context

      public SignatureSpec.Builder context(SignatureContext signatureContext)
      Sets Signature Context
      Parameters:
      signatureContext - Signature Context with values obtained from signed request or response
      Returns:
      This builder
    • privateKey

      public SignatureSpec.Builder privateKey(PrivateKey privateKey)
      Sets private key used to create the signature
      Parameters:
      privateKey - PrivateKey object
      Returns:
      This builder
    • privateKey

      public SignatureSpec.Builder privateKey(byte[] privateKey)
      Sets private key, encoded as bytes[] in PKCS#8 format
      Parameters:
      privateKey - PKCS#8-encoded private key
      Returns:
      This builder
    • privateKey

      public SignatureSpec.Builder privateKey(String privateKey)
      Sets private key, provided as PKCS#8-base-64-encoded String

      It can contain multiple lines, including BEGIN PRIVATE KEY and END PRIVATE KEY.

      Parameters:
      privateKey - PKCS#8-base-64-encoded private key
      Returns:
      This builder
    • signatureLabel

      public SignatureSpec.Builder signatureLabel(String signatureLabel)
      Sets signature label
      Parameters:
      signatureLabel - Signature label
      Returns:
      This builder
      See Also:
    • build

      public SignatureSpec build()
      Constructs SignatureSpec object from this builder

      All required data mentioned in SignatureSpec.Builder must be provided (private key, signature algorithm, signature label).

      Returns:
      SignatureSpec object