Class JWKSet

java.lang.Object
org.forgerock.json.jose.jwt.JWObject
org.forgerock.json.jose.jwk.JWKSet

public class JWKSet extends JWObject
Holds a Set of JWKs.
  • Constructor Details

    • JWKSet

      public JWKSet()
      Constructs an empty JWKSet.
    • JWKSet

      public JWKSet(JWK jwk)
      Construct a JWKSet from a single JWK.
      Parameters:
      jwk - the jwk to construct the set from
    • JWKSet

      public JWKSet(JsonValue jwks)
      Construct a JWKSet from a single JWK.
      Parameters:
      jwks - contains a list of json web keys
    • JWKSet

      public JWKSet(List<JWK> jwkList)
      Construct a JWKSet from a List of JWKs.
      Parameters:
      jwkList - a list of jwks
  • Method Details

    • getJWKsAsList

      public List<JWK> getJWKsAsList()
      Get the JWKs in the set.
      Returns:
      a list of JWKs
    • getJWKsAsJsonValue

      public JsonValue getJWKsAsJsonValue()
      Get the JWKs in the set.
      Returns:
      a list of JWKs as JsonValues
    • toJsonValue

      protected static JsonValue toJsonValue(String json)
      Converts a json string to a jsonValue.
      Parameters:
      json - a json jwk set object string
      Returns:
      a json value of the son string
      Throws:
      JsonException - if unable to parse
    • parse

      public static JWKSet parse(String json)
      Parses a JWKSet object from a string json object.
      Parameters:
      json - string json object
      Returns:
      a JWKSet
    • parse

      public static JWKSet parse(JsonValue json)
      Parses a JWKSet object from a jsonValue object.
      Parameters:
      json - an JsonValue object
      Returns:
      a JWKSet
    • toJsonString

      public String toJsonString()
      Prints the JWK Set as a json string.
      Returns:
      A String representing JWK
    • findJwk

      public JWK findJwk(Algorithm algorithm, String keyUse)
      Search for a JWK that matches the algorithm and the key usage.
      Parameters:
      algorithm - the algorithm needed
      keyUse - the key usage. If null, only the algorithm will be used as a search criteria.
      Returns:
      A jwk that matches the search criteria. If no JWK found for the key usage, then it searches for a JWK without key usage defined. If still no JWK found, then returns null.
    • findJwk

      public JWK findJwk(String kid)
      Search for a JWK that matches the kid.
      Parameters:
      kid - Key ID
      Returns:
      A jwk that matches the kid. If no JWK found, returns null
    • findJwks

      public Stream<JWK> findJwks(Predicate<JWK> predicate)
      Return a stream of JWK that matches the JWK predicate.
      Parameters:
      predicate - for the matching JWK
      Returns:
      a stream of JWK matching the predicate.
    • findJwk

      public Optional<JWK> findJwk(Predicate<JWK> predicate)
      Return a JWK that matches the JWK predicate.
      Parameters:
      predicate - for the matching JWK
      Returns:
      the first matching JWK.