Class OidcConfigurationServiceWithCache
java.lang.Object
com.sap.cloud.security.token.validation.validators.OidcConfigurationServiceWithCache
Decorates
OidcConfigurationService
with a cache, which gets looked up
before the identity service is requested via http.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Creates a new instance.getOrRetrieveEndpoints
(URI discoveryEndpointUri) Returns the cached key by id and type or requests the keys from the jwks URI of the identity service.withCacheSize
(int size) Caches the Json web keys.withCacheTime
(int timeInSeconds) Caches the Json web keys.withOidcConfigurationService
(OidcConfigurationService oidcConfigurationService) Overwrites the service to be used to request the oidc configuration.
-
Method Details
-
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
Caches the Json web keys. Overwrite the cache time (default: 900 seconds).- Parameters:
timeInSeconds
- time to cache the signing keys- Returns:
- this
-
withCacheSize
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()
-