Class InfinispanSingleUseObjectProvider
java.lang.Object
org.keycloak.models.sessions.infinispan.InfinispanSingleUseObjectProvider
- All Implemented Interfaces:
SingleUseObjectProvider,Provider
TODO: Check if Boolean can be used as single-use cache argument instead of SingleUseObjectValueEntity. With respect to other single-use cache usecases like "Revoke Refresh Token" .
Also with respect to the usage of streams iterating over "actionTokens" cache (check there are no ClassCastExceptions when casting values directly to SingleUseObjectValueEntity)
- Author:
- Marek Posolda
-
Field Summary
FieldsFields inherited from interface org.keycloak.models.SingleUseObjectProvider
REVOKED_KEY -
Constructor Summary
ConstructorsConstructorDescriptionInfinispanSingleUseObjectProvider(KeycloakSession session, org.infinispan.commons.api.BasicCache<String, SingleUseObjectValueEntity> singleUseObjectCache, boolean persistRevokedTokens, InfinispanKeycloakTransaction tx) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanChecks if there is a record in the store for the given key.Gets data associated with the given key.voidStores the given data and guarantees that data should be available in the store for at least the time specified by parameterbooleanputIfAbsent(String key, long lifespanInSeconds) Will try to put the key into the cache.This method returns data just if removal was successful.booleanReplaces data associated with the given key in the store if the store contains the key.
-
Field Details
-
logger
public static final org.jboss.logging.Logger logger
-
-
Constructor Details
-
InfinispanSingleUseObjectProvider
public InfinispanSingleUseObjectProvider(KeycloakSession session, org.infinispan.commons.api.BasicCache<String, SingleUseObjectValueEntity> singleUseObjectCache, boolean persistRevokedTokens, InfinispanKeycloakTransaction tx)
-
-
Method Details
-
put
Description copied from interface:SingleUseObjectProviderStores the given data and guarantees that data should be available in the store for at least the time specified by parameter- Specified by:
putin interfaceSingleUseObjectProvider- Parameters:
key- StringlifespanSeconds- Minimum lifespan for which successfully added key will be kept in the cache.notes- For revoked tokens, this must be an empty Map.
-
get
Description copied from interface:SingleUseObjectProviderGets data associated with the given key.- Specified by:
getin interfaceSingleUseObjectProvider- Parameters:
key- String- Returns:
- Map<String, String> Data associated with the given key or
nullif there is no associated data.
-
remove
Description copied from interface:SingleUseObjectProviderThis method returns data just if removal was successful. Implementation should guarantee that "remove" is single-use. So if 2 threads (even on different cluster nodes or on different multi-site nodes) calls "remove(123)" concurrently, then just one of them is allowed to succeed and return data back. It can't happen that both will succeed.- Specified by:
removein interfaceSingleUseObjectProvider- Parameters:
key- String- Returns:
- context data associated to the key. It returns
nullif there are no context data available.
-
replace
Description copied from interface:SingleUseObjectProviderReplaces data associated with the given key in the store if the store contains the key.- Specified by:
replacein interfaceSingleUseObjectProvider- Parameters:
key- Stringnotes- Map<String, String> New data to be stored- Returns:
trueif the store contains the key and data was replaced, otherwisefalse.
-
putIfAbsent
Description copied from interface:SingleUseObjectProviderWill try to put the key into the cache. It will succeed just if key is not already there.- Specified by:
putIfAbsentin interfaceSingleUseObjectProviderlifespanInSeconds- Minimum lifespan for which successfully added key will be kept in the cache.- Returns:
- true if the key was successfully put into the cache. This means that same key wasn't in the cache before
-
contains
Description copied from interface:SingleUseObjectProviderChecks if there is a record in the store for the given key.- Specified by:
containsin interfaceSingleUseObjectProvider- Parameters:
key- String- Returns:
trueif the record is present in the store,falseotherwise.
-
close
public void close()
-