Class OidcConfigurationServiceWithCache

java.lang.Object
com.sap.cloud.security.token.validation.validators.OidcConfigurationServiceWithCache

public class OidcConfigurationServiceWithCache extends Object
Decorates OidcConfigurationService with a cache, which gets looked up before the identity service is requested via http.
  • Method Details

    • getInstance

      public static OidcConfigurationServiceWithCache getInstance()
      Creates a new instance.
      Returns:
      the new instance.
    • withOidcConfigurationService

      public OidcConfigurationServiceWithCache withOidcConfigurationService(OidcConfigurationService oidcConfigurationService)
      Overwrites the service to be used to request the oidc configuration.
      Parameters:
      oidcConfigurationService - * the OidcConfigurationService that will be used to request the oidc configuration.
      Returns:
      this
    • withCacheTime

      public OidcConfigurationServiceWithCache withCacheTime(int timeInSeconds)
      Caches the Json web keys. Overwrite the cache time (default: 900 seconds).
      Parameters:
      timeInSeconds - time to cache the signing keys
      Returns:
      this
    • withCacheSize

      public OidcConfigurationServiceWithCache withCacheSize(int size)
      Caches the Json web keys. Overwrite the size of the cache (default: 100).
      Parameters:
      size - number of cached json web keys.
      Returns:
      this
    • getOrRetrieveEndpoints

      @Nullable public OAuth2ServiceEndpointsProvider getOrRetrieveEndpoints(URI discoveryEndpointUri) throws OAuth2ServiceException
      Returns the cached key by id and type or requests the keys from the jwks URI of the identity service.
      Parameters:
      discoveryEndpointUri - the discovery endpoint URI (issuer specific).
      Returns:
      a PublicKey
      Throws:
      OAuth2ServiceException - in case the call to the jwks endpoint of the identity service failed.
    • clearCache

      public void clearCache()