Package org.keycloak.models
Interface SingleUseObjectProvider
- All Superinterfaces:
Provider
- All Known Implementing Classes:
InfinispanSingleUseObjectProvider
,RemoteInfinispanSingleUseObjectProvider
Provides a cache to store data for single-use use case or the details about used action tokens.
- Author:
- Marek Posolda
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Suffix to a key to indicate that token is considered revoked. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if there is a record in the store for the given key.Gets data associated with the given key.void
Stores the given data and guarantees that data should be available in the store for at least the time specified by parameterboolean
putIfAbsent
(String key, long lifespanInSeconds) Will try to put the key into the cache.This method returns data just if removal was successful.boolean
Replaces data associated with the given key in the store if the store contains the key.
-
Field Details
-
REVOKED_KEY
Suffix to a key to indicate that token is considered revoked. For revoked tokens, only the methodsput(java.lang.String, long, java.util.Map<java.lang.String, java.lang.String>)
andcontains(java.lang.String)
must be used.- See Also:
-
-
Method Details
-
put
Stores the given data and guarantees that data should be available in the store for at least the time specified by parameter- 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
Gets data associated with the given key.- Parameters:
key
- String- Returns:
- Map<String, String> Data associated with the given key or
null
if there is no associated data.
-
remove
This 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 cross-dc 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.- Parameters:
key
- String- Returns:
- context data associated to the key. It returns
null
if there are no context data available.
-
replace
Replaces data associated with the given key in the store if the store contains the key.- Parameters:
key
- Stringnotes
- Map<String, String> New data to be stored- Returns:
true
if the store contains the key and data was replaced, otherwisefalse
.
-
putIfAbsent
Will try to put the key into the cache. It will succeed just if key is not already there.- Parameters:
key
-lifespanInSeconds
- 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
Checks if there is a record in the store for the given key.- Parameters:
key
- String- Returns:
true
if the record is present in the store,false
otherwise.
-