public class OAuth2TokenKeyServiceWithCache extends Object
OAuth2TokenKeyService with a cache, which gets looked up
before the identity service is requested via http.| Modifier and Type | Method and Description |
|---|---|
void |
clearCache() |
static OAuth2TokenKeyServiceWithCache |
getInstance()
Creates a new instance.
|
PublicKey |
getPublicKey(JwtSignatureAlgorithm keyAlgorithm,
String keyId,
URI keyUri)
Returns the cached key by id and type or requests the keys from the jwks URI
of the identity service.
|
static String |
getUniqueCacheKey(JwtSignatureAlgorithm keyAlgorithm,
String keyId,
URI jwksUri) |
OAuth2TokenKeyServiceWithCache |
withCacheSize(int size)
Caches the Json web keys.
|
OAuth2TokenKeyServiceWithCache |
withCacheTime(int timeInSeconds)
Caches the Json web keys.
|
OAuth2TokenKeyServiceWithCache |
withTokenKeyService(OAuth2TokenKeyService tokenKeyService)
Overwrites the service to be used to request the Json web keys.
|
public static OAuth2TokenKeyServiceWithCache getInstance()
public OAuth2TokenKeyServiceWithCache withCacheTime(int timeInSeconds)
timeInSeconds - time to cache the signing keyspublic OAuth2TokenKeyServiceWithCache withCacheSize(int size)
size - number of cached json web keys.public OAuth2TokenKeyServiceWithCache withTokenKeyService(OAuth2TokenKeyService tokenKeyService)
tokenKeyService - the service to request the json web key set.@Nullable public PublicKey getPublicKey(JwtSignatureAlgorithm keyAlgorithm, String keyId, URI keyUri) throws OAuth2ServiceException, InvalidKeySpecException, NoSuchAlgorithmException
keyAlgorithm - the Key Algorithm of the Access Token.keyId - the Key Id of the Access Token.keyUri - the Token Key Uri (jwks) of the Access Token (can be tenant
specific).OAuth2ServiceException - in case the call to the jwks endpoint of the identity service
failed.InvalidKeySpecException - in case the PublicKey generation for the json web key failed.NoSuchAlgorithmException - in case the algorithm of the json web key is not supported.public void clearCache()
public static String getUniqueCacheKey(JwtSignatureAlgorithm keyAlgorithm, String keyId, URI jwksUri)
Copyright © 2020. All rights reserved.