Class JWK.Builder<B extends JWK.Builder>

java.lang.Object
org.forgerock.json.jose.jwk.JWK.Builder<B>
Type Parameters:
B - The current builder.
Direct Known Subclasses:
EcJWK.Builder, OctJWK.Builder, OkpJWK.Builder, RsaJWK.Builder
Enclosing class:
JWK

public abstract static class JWK.Builder<B extends JWK.Builder> extends Object
JWK builder.
  • Field Details

    • keyType

      protected KeyType keyType
      The key type, required.
    • use

      protected String use
      The key use, optional.
    • keyOperations

      protected Set<KeyOperation> keyOperations
      The key operations, optional.
    • algorithm

      protected Algorithm algorithm
      The intended JOSE algorithm for the key, optional.
    • keyId

      protected String keyId
      The key ID, optional.
    • x509url

      protected String x509url
      X.509 certificate URL, optional.
    • x509Thumbnail

      protected String x509Thumbnail
      X.509 certificate thumbprint, optional.
    • x509Chain

      protected List<String> x509Chain
      The X.509 certificate chain, optional.
  • Constructor Details

    • Builder

      protected Builder(KeyType keyType)
      The builder constructor.
      Parameters:
      keyType - the JWK key type
  • Method Details

    • keyUse

      public B keyUse(String use)
      Set the key use parameter of the JWK.
      Parameters:
      use - the JWK use
      Returns:
      the current builder
    • keyOperations

      public B keyOperations(Set<KeyOperation> keyOperations)
      Set the key operations parameter of the JWK.
      Parameters:
      keyOperations - the JWK key Operations
      Returns:
      the current builder
    • algorithm

      public B algorithm(Algorithm algorithm)
      Sets the algorithm parameter of the JWK.
      Parameters:
      algorithm - the JWK algorithm
      Returns:
      the current builder
    • algorithm

      public B algorithm(String algorithm)
      Sets the algorithm parameter of the JWK.
      Parameters:
      algorithm - the JWK algorithm
      Returns:
      the current builder
    • keyId

      public B keyId(String keyId)
      Sets the keyId parameter of the JWK.
      Parameters:
      keyId - the JWK key id
      Returns:
      the current builder
    • x509Url

      public B x509Url(String x509url)
      Gets the X509 URL.
      Parameters:
      x509url - the x509 url for the key
      Returns:
      the current builder
    • x509Thumbnail

      @Deprecated public B x509Thumbnail(String x509Thumbnail)
      Sets the X509 thumbprint.
      Parameters:
      x509Thumbnail - the x509 thumbprint for the key
      Returns:
      the current builder
    • x509Thumbprint

      public B x509Thumbprint(String x509Thumbprint)
      Sets the SHA-1 X509 thumbprint. You should prefer to use x509ThumbprintS256(String) instead in most cases.
      Parameters:
      x509Thumbprint - the x509 thumbprint for the key
      Returns:
      the current builder
    • withX509Thumbprint

      public B withX509Thumbprint()
      Sets the SHA-1 X509 thumbprint based on the configured x509Chain(List).
      Returns:
      the current builder
      Throws:
      IllegalStateException - if no X509 certificate has been set.
    • x509ThumbprintS256

      public B x509ThumbprintS256(String x509Thumbprint)
      Sets the SHA-256 X509 thumbprint.
      Parameters:
      x509Thumbprint - the SHA-256 x509 thumbprint for the key
      Returns:
      the current builder
    • withX509ThumbprintS256

      public B withX509ThumbprintS256()
      Sets the SHA-256 X509 thumbprint based on the configured x509Chain(List).
      Returns:
      the current builder
      Throws:
      IllegalStateException - if no X509 certificate has been set.
    • x509Chain

      public B x509Chain(List<String> x509Chain)
      Set the X509 certificates attributes.
      Parameters:
      x509Chain - the x509 chain as a list of Base64 encoded strings
      Returns:
      the current builder
    • build

      public abstract JWK build()
      Builds the JWK.
      Returns:
      the JWK.