Class Jwks

java.lang.Object
com.revetsec.jose.Jwks

@Immutable public final class Jwks extends Object
A JSON Web Key Set (RFC 7517 section 5): the usable public verification keys of a key set document, in document order.

Keys that are not usable are skipped, never used in part, and never fail the set: a symmetric or private key, a key for encryption, a curve or key type Revetsec does not support, a weak or malformed key, and the rest of the cases JwkSkipReason lists. Only the document itself can fail: text that is not strict JSON, not an object, without a keys array of objects, or over the size and key-count limits.

The fromJsonResult(String) operation applies the default limits of RemoteJwksSource: 256 KiB and 100 keys, every element of keys counted. So at the default limits a document is accepted the same way from a string as from the network.

Two key sets are equal when they hold equal keys in the same order.

Since:
1.0.0
Author:
Mark Allen
  • Method Details

    • fromJsonResult

      @CheckReturnValue public static @NonNull JwksParseResult fromJsonResult(@NonNull String json)
      Parses a JSON Web Key Set document and returns the usable keys or a fixed structural rejection. Malformed or unusable individual keys are skipped; only the document structure and limits reject the set. This static facade returns usable keys only: it exposes no skipped-key count, original indices or per-key skip reasons and emits no observer events. Remote fetches have separate JoseObserver skip callbacks.
      Parameters:
      json - untrusted document, at most 256 KiB as UTF-8 and 100 elements in its keys array
      Returns:
      the parsing outcome; a successful key set may have no usable keys
      Throws:
      NullPointerException - if the document is null
      Since:
      1.0.0
    • getKeys

      Returns the usable keys.
      Returns:
      an unmodifiable list, in document order; empty if every key was skipped
      Since:
      1.0.0
    • equals

      public boolean equals(@Nullable Object object)
      Compares the keys, in order.
      Overrides:
      equals in class Object
      Parameters:
      object - the other object
      Returns:
      whether object is a key set with equal keys in the same order
      Since:
      1.0.0
    • hashCode

      public int hashCode()
      Returns a hash of the keys, in order.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
      Since:
      1.0.0
    • toString

      Describes the key set by its keys' public facts.
      Overrides:
      toString in class Object
      Returns:
      the description
      Since:
      1.0.0