Class JWKMatcher.Builder

java.lang.Object
com.nimbusds.jose.jwk.JWKMatcher.Builder
Enclosing class:
JWKMatcher

public static class JWKMatcher.Builder extends Object
Builder for constructing JWK matchers.

Example usage:

 JWKMatcher matcher = new JWKMatcher().keyID("123").build();
 
  • Constructor Details

    • Builder

      public Builder()
      Creates a new builder for constructing JWK matchers.
    • Builder

      public Builder(JWKMatcher jwkMatcher)
      Creates a new builder for constructing JWK matchers using the specified matcher.
      Parameters:
      jwkMatcher - The JWK matcher to use. Must not be null.
  • Method Details

    • keyType

      Sets a single key type to match.
      Parameters:
      kty - The key type, null if not specified.
      Returns:
      This builder.
    • keyTypes

      public JWKMatcher.Builder keyTypes(KeyType... types)
      Sets multiple key types to match.
      Parameters:
      types - The key types.
      Returns:
      This builder.
    • keyTypes

      Sets multiple key types to match.
      Parameters:
      types - The key types, null if not specified.
      Returns:
      This builder.
    • keyUse

      Sets a single public key use to match.
      Parameters:
      use - The public key use, null if not specified.
      Returns:
      This builder.
    • keyUses

      public JWKMatcher.Builder keyUses(KeyUse... uses)
      Sets multiple public key uses to match.
      Parameters:
      uses - The public key uses.
      Returns:
      This builder.
    • keyUses

      Sets multiple public key uses to match.
      Parameters:
      uses - The public key uses, null if not specified.
      Returns:
      This builder.
    • keyOperation

      Sets a single key operation to match.
      Parameters:
      op - The key operation, null if not specified.
      Returns:
      This builder.
    • keyOperations

      Sets multiple key operations to match.
      Parameters:
      ops - The key operations.
      Returns:
      This builder.
    • keyOperations

      Sets multiple key operations to match.
      Parameters:
      ops - The key operations, null if not specified.
      Returns:
      This builder.
    • algorithm

      Sets a single JOSE algorithm to match.
      Parameters:
      alg - The JOSE algorithm, null if not specified.
      Returns:
      This builder.
    • algorithms

      Sets multiple JOSE algorithms to match.
      Parameters:
      algs - The JOSE algorithms.
      Returns:
      This builder.
    • algorithms

      Sets multiple JOSE algorithms to match.
      Parameters:
      algs - The JOSE algorithms, null if not specified.
      Returns:
      This builder.
    • keyID

      Sets a single key ID to match.
      Parameters:
      id - The key ID, null if not specified.
      Returns:
      This builder.
    • keyIDs

      public JWKMatcher.Builder keyIDs(String... ids)
      Sets multiple key IDs to match.
      Parameters:
      ids - The key IDs.
      Returns:
      This builder.
    • keyIDs

      Sets multiple key IDs to match.
      Parameters:
      ids - The key IDs, null if not specified.
      Returns:
      This builder.
    • hasKeyUse

      @Deprecated public JWKMatcher.Builder hasKeyUse(boolean hasUse)
      Deprecated.
      Sets the key use presence matching.
      Parameters:
      hasUse - true to match a key with a specified use only.
      Returns:
      This builder.
    • withKeyUseOnly

      public JWKMatcher.Builder withKeyUseOnly(boolean withUseOnly)
      Sets the key use presence matching.
      Parameters:
      withUseOnly - true to match a key with a specified use only.
      Returns:
      This builder.
    • hasKeyID

      @Deprecated public JWKMatcher.Builder hasKeyID(boolean hasID)
      Deprecated.
      Sets the key ID presence matching.
      Parameters:
      hasID - true to match a key a specified ID only.
      Returns:
      This builder.
    • withKeyIDOnly

      public JWKMatcher.Builder withKeyIDOnly(boolean withIDOnly)
      Sets the key ID presence matching.
      Parameters:
      withIDOnly - true to match a key a specified ID only.
      Returns:
      This builder.
    • privateOnly

      public JWKMatcher.Builder privateOnly(boolean privateOnly)
      Sets the private key matching.
      Parameters:
      privateOnly - true to match a private key only.
      Returns:
      This builder.
    • publicOnly

      public JWKMatcher.Builder publicOnly(boolean publicOnly)
      Sets the public key matching.
      Parameters:
      publicOnly - true to match a public key only.
      Returns:
      This builder.
    • nonRevokedOnly

      public JWKMatcher.Builder nonRevokedOnly(boolean nonRevokedOnly)
      Sets the non-revoked key matching.
      Parameters:
      nonRevokedOnly - true to match a non-revoked key only.
      Returns:
      This builder.
    • revokedOnly

      public JWKMatcher.Builder revokedOnly(boolean revokedOnly)
      Sets the revoked key matching.
      Parameters:
      revokedOnly - true to match a revoked key only.
      Returns:
      This builder.
    • minKeySize

      public JWKMatcher.Builder minKeySize(int minSizeBits)
      Sets the minimal key size.
      Parameters:
      minSizeBits - The minimum key size in bits, zero implies no minimum key size limit.
      Returns:
      This builder.
    • maxKeySize

      public JWKMatcher.Builder maxKeySize(int maxSizeBits)
      Sets the maximum key size.
      Parameters:
      maxSizeBits - The maximum key size in bits, zero implies no maximum key size limit.
      Returns:
      This builder.
    • keySize

      public JWKMatcher.Builder keySize(int keySizeBits)
      Sets the key size.
      Parameters:
      keySizeBits - The key size in bits, zero if not specified.
      Returns:
      This builder.
    • keySizes

      public JWKMatcher.Builder keySizes(int... keySizesBits)
      Sets the key sizes.
      Parameters:
      keySizesBits - The key sizes in bits.
      Returns:
      This builder.
    • keySizes

      public JWKMatcher.Builder keySizes(Set<Integer> keySizesBits)
      Sets the key sizes.
      Parameters:
      keySizesBits - The key sizes in bits.
      Returns:
      This builder.
    • curve

      public JWKMatcher.Builder curve(Curve curve)
      Sets a single curve to match (for EC and OKP keys).
      Parameters:
      curve - The curve, null if not specified.
      Returns:
      This builder.
    • curves

      public JWKMatcher.Builder curves(Curve... curves)
      Sets multiple curves to match (for EC and OKP keys).
      Parameters:
      curves - The curves.
      Returns:
      This builder.
    • curves

      public JWKMatcher.Builder curves(Set<Curve> curves)
      Sets multiple curves to match (for EC and OKP keys).
      Parameters:
      curves - The curves, null if not specified.
      Returns:
      This builder.
    • x509CertSHA256Thumbprint

      Sets a single X.509 certificate SHA-256 thumbprint to match.
      Parameters:
      x5tS256 - The thumbprint, null if not specified.
      Returns:
      This builder.
    • x509CertSHA256Thumbprints

      Sets multiple X.509 certificate SHA-256 thumbprints to match.
      Parameters:
      x5tS256s - The thumbprints.
      Returns:
      This builder.
    • x509CertSHA256Thumbprints

      Sets multiple X.509 certificate SHA-256 thumbprints to match.
      Parameters:
      x5tS256s - The thumbprints, null if not specified.
      Returns:
      This builder.
    • hasX509CertChain

      Deprecated.
      Sets the X.509 certificate chain presence matching.
      Parameters:
      hasX5C - true to match a key with a specified X.509 certificate chain only.
      Returns:
      This builder.
    • withX509CertChainOnly

      public JWKMatcher.Builder withX509CertChainOnly(boolean withX5CONly)
      Sets the X.509 certificate chain presence matching.
      Parameters:
      withX5CONly - true to match a key with a specified X.509 certificate chain only.
      Returns:
      This builder.
    • build

      public JWKMatcher build()
      Builds a new JWK matcher.
      Returns:
      The JWK matcher.