10Duke Java Core
Loading...
Searching...
No Matches
tenduke.sdk.core.service.JwksPersistentStore Interface Reference

Detailed Description

Interface for persistent storage of JWKS (JSON Web Key Set) public keys.

This interface provides methods for storing, retrieving, and managing public keys used for JWT signature verification in a persistent manner.

The persistent store is designed to work alongside the in-memory cache to optimize API usage by reducing calls to the JWKS endpoint.

Public Member Functions

void storeKey (String keyId, PublicKey publicKey)
 Stores a public key with the given key identifier.
 
void storeKeys (Map< String, PublicKey > keys)
 Stores multiple public keys in a single operation.
 
PublicKey retrieveKey (String keyId)
 Retrieves a public key by its identifier.
 
Map< String, PublicKey > retrieveAllKeys ()
 Retrieves all stored public keys.
 
boolean containsKey (String keyId)
 Checks if a key with the given identifier exists in the persistent store.
 
boolean removeKey (String keyId)
 Removes a key with the given identifier from the persistent store.
 
void clearAll ()
 Removes all keys from the persistent store.
 
int getKeyCount ()
 Returns the number of keys currently stored.
 
boolean isEmpty ()
 Checks if the persistent store is empty.
 
String getStoreInfo ()
 Returns information about the persistent store implementation.
 

Member Function Documentation

◆ clearAll()

void tenduke.sdk.core.service.JwksPersistentStore.clearAll ( )

Removes all keys from the persistent store.

This method clears the entire storage, which might be useful for testing or when a complete refresh is needed.

◆ containsKey()

boolean tenduke.sdk.core.service.JwksPersistentStore.containsKey ( String keyId)

Checks if a key with the given identifier exists in the persistent store.

Parameters
keyIdThe unique identifier for the key.
Returns
true if the key exists, false otherwise.
Exceptions
IllegalArgumentExceptionif keyId is null or blank.

◆ getKeyCount()

int tenduke.sdk.core.service.JwksPersistentStore.getKeyCount ( )

Returns the number of keys currently stored.

Returns
The count of stored keys.

◆ getStoreInfo()

String tenduke.sdk.core.service.JwksPersistentStore.getStoreInfo ( )

Returns information about the persistent store implementation.

This can be useful for logging, debugging, or configuration validation.

Returns
A string describing the store implementation (e.g., "File-based store: /path/to/cache").

◆ isEmpty()

boolean tenduke.sdk.core.service.JwksPersistentStore.isEmpty ( )

Checks if the persistent store is empty.

Returns
true if no keys are stored, false otherwise.

◆ removeKey()

boolean tenduke.sdk.core.service.JwksPersistentStore.removeKey ( String keyId)

Removes a key with the given identifier from the persistent store.

Parameters
keyIdThe unique identifier for the key to remove.
Returns
true if the key was removed, false if it didn't exist.
Exceptions
IllegalArgumentExceptionif keyId is null or blank.

◆ retrieveAllKeys()

Map< String, PublicKey > tenduke.sdk.core.service.JwksPersistentStore.retrieveAllKeys ( )

Retrieves all stored public keys.

Returns
A map of key identifiers to public keys. Returns an empty map if no keys are stored.

◆ retrieveKey()

PublicKey tenduke.sdk.core.service.JwksPersistentStore.retrieveKey ( String keyId)

Retrieves a public key by its identifier.

For key not found errors implementations may choose to use the built-in Exception builder, e.g.:

throw ExceptionBuilder.missingJwtSigningKey( "A public key with id: ".concat(keyId).concat(" does not exist"), null);

Parameters
keyIdThe unique identifier for the key.
Returns
The public key if found.
Exceptions
IllegalArgumentExceptionif keyId is null or blank, TokenException with MISSING_SIGNING_KEY error if a key id does not map to a key.

◆ storeKey()

void tenduke.sdk.core.service.JwksPersistentStore.storeKey ( String keyId,
PublicKey publicKey )

Stores a public key with the given key identifier.

If a key with the same identifier already exists, it should be replaced with the new key.

Parameters
keyIdThe unique identifier for the key.
publicKeyThe public key to store.
Exceptions
IllegalArgumentExceptionif keyId is null or blank, or if publicKey is null.

◆ storeKeys()

void tenduke.sdk.core.service.JwksPersistentStore.storeKeys ( Map< String, PublicKey > keys)

Stores multiple public keys in a single operation.

This method provides an efficient way to store multiple keys at once, which is useful when loading keys from a JWKS endpoint.

Parameters
keysA map of key identifiers to public keys.
Exceptions
IllegalArgumentExceptionif keys is null or contains null values.

The documentation for this interface was generated from the following file: