Class JwksStore

java.lang.Object
org.forgerock.json.jose.jwk.store.JwksStore

public class JwksStore extends Object
Store JWKs into a jwkSet from a JWKs_URI and refresh the jwkSet when necessary.
  • Method Details

    • findJwk

      public JWK findJwk(Algorithm algorithm, KeyUse keyUse) throws FailedToLoadJWKException
      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.
      Throws:
      FailedToLoadJWKException - if the jwks can't be reloaded.
    • findJwk

      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
      Throws:
      FailedToLoadJWKException - if the jwks can't be reloaded.
    • getUid

      public String getUid()
      Get the UID.
      Returns:
      the uid.
    • getCacheTimeout

      Get the cache timeout.
      Returns:
      the cache timeout.
    • getCacheMissCacheTime

      Get the cache time before reload the cache in case of cache miss.
      Returns:
      the cache miss cache time.
    • getJwkUrl

      public URL getJwkUrl()
      The JWKs URI.
      Returns:
      the jwk uri.
    • setCacheTimeout

      public void setCacheTimeout(Duration cacheTimeout)
      Update the cache timeout.
      Parameters:
      cacheTimeout - the cache timeout.
    • setCacheMissCacheTime

      public void setCacheMissCacheTime(Duration cacheMissCacheTime)
      Update the cache time before reload the cache in case of cache miss.
      Parameters:
      cacheMissCacheTime - the cache miss cache time.
    • setJwkUrl

      public void setJwkUrl(URL jwkUrl) throws FailedToLoadJWKException
      Update the JWKs URI.
      Parameters:
      jwkUrl - the jwks uri.
      Throws:
      FailedToLoadJWKException - If the URI has changed and the JWK set cannot be loaded.