Class PublicKeyInfo.Builder

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

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

Public key can be provided as either PublicKey object or X.509-encoded byte[] or X.509-Base64-encoded String.

  • Method Details

    • algorithm

      public PublicKeyInfo.Builder algorithm(SignatureAlgorithm algorithm)
      Sets signature algorithm for the key.

      The algorithm must be provided here or as alg parameter in Signature-Input header.

      Parameters:
      algorithm - Signature algorithm used to verify the signature
      Returns:
      This builder
    • publicKey

      public PublicKeyInfo.Builder publicKey(PublicKey publicKey)
      Public key provided as an object
      Parameters:
      publicKey - Public key to verify the signature
      Returns:
      This builder
    • publicKey

      public PublicKeyInfo.Builder publicKey(byte[] publicKey)
      Encoded public key provided as bytes[] object
      Parameters:
      publicKey - X.509-encoded public key
      Returns:
      This builder
      See Also:
    • publicKey

      public PublicKeyInfo.Builder publicKey(String publicKey)
      Encoded public key provided as String object

      It must be in X.509 format. It can contain multiple lines, including BEGIN PUBLIC KEY and END PUBLIC KEY. PKCS#1 format, like "BEGIN RSA PUBLIC KEY" is not accepted.

      Parameters:
      publicKey - X.509-base-64-encoded public key
      Returns:
      This builder
    • build

      public PublicKeyInfo build()
      Constructs PublicKeyInfo object from this builder

      Public key data must be provided using any of publicKey() builder methods

      Returns:
      PublicKeyInfo object