Interface TokenHolder
-
- All Known Implementing Classes:
InMemoryTokenHolder
public interface TokenHolderInterface used for storing and manipulating tokens across the solution. Methods of this class should only be used through theTokenServiceand its relevant subclass(es)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringcreateMasterTokenIfAbsent(String sessionKey, Supplier<String> valueSupplier)Creates and returns a new master token bound to the provided session key if there wasn't any or returns the existing value.StringcreatePageTokenIfAbsent(String sessionKey, String resourceUri, Supplier<String> valueSupplier)Creates and returns a new page token bound to the provided resource URI and mapped to the session key if there wasn't any or returns the existing value.StringgetPageToken(String sessionKey, String resourceUri)Returns the page token based on the desired HTTP resource URI and logical session keyMap<String,String>getPageTokens(String sessionKey)Returns all page tokens associated to the provided logical session keyTokengetToken(String sessionKey)Returns the master and page tokens associated to a logical session keyvoidregenerateUsedPageToken(String sessionKey, String tokenFromRequest, Supplier<String> tokenValueSupplier)Re-generates the value of a used page tokenvoidremove(String sessionKey)Removes all tokens related to a specific logical session keyvoidrotateAllPageTokens(String sessionKey, Supplier<String> tokenValueSupplier)Re-generates all existing tokens associated to the provided logical session keyvoidsetMasterToken(String sessionKey, String value)Sets or overwrites the master token bound to a specific session key.voidsetPageToken(String sessionKey, String resourceUri, String value)Sets the value of a page token based on the desired HTTP resource URI and logical session keyvoidsetPageTokens(String sessionKey, Map<String,String> pageTokens)Sets/overwrites the page tokens with the provided values
-
-
-
Method Detail
-
setMasterToken
void setMasterToken(String sessionKey, String value)
Sets or overwrites the master token bound to a specific session key. It does not overwrite the session key associated page tokens.- Parameters:
sessionKey- identifies the current logical session uniquelyvalue- the value to be used as master token
-
createMasterTokenIfAbsent
String createMasterTokenIfAbsent(String sessionKey, Supplier<String> valueSupplier)
Creates and returns a new master token bound to the provided session key if there wasn't any or returns the existing value.- Parameters:
sessionKey- identifies the current logical session uniquelyvalueSupplier- produces a new master token value lazily/on demand- Returns:
- the created master token
-
createPageTokenIfAbsent
String createPageTokenIfAbsent(String sessionKey, String resourceUri, Supplier<String> valueSupplier)
Creates and returns a new page token bound to the provided resource URI and mapped to the session key if there wasn't any or returns the existing value. If there are no tokens associated to the session key it also creates a new master token.- Parameters:
sessionKey- identifies the current logical session uniquelyresourceUri- the URI of the desired HTTP resourcevalueSupplier- produces a new page token value lazily/on demand- Returns:
- the existing or newly created page token
-
getToken
Token getToken(String sessionKey)
Returns the master and page tokens associated to a logical session key- Parameters:
sessionKey- identifies the current logical session uniquely- Returns:
- a token object containing the master and page tokens
-
getPageToken
String getPageToken(String sessionKey, String resourceUri)
Returns the page token based on the desired HTTP resource URI and logical session key- Parameters:
sessionKey- identifies the current logical session uniquelyresourceUri- the URI of the desired HTTP resource- Returns:
- a page token bound to a resource URI and associated to a logical session key or NULL if there is no token with identified by the session key
-
setPageToken
void setPageToken(String sessionKey, String resourceUri, String value)
Sets the value of a page token based on the desired HTTP resource URI and logical session key- Parameters:
sessionKey- identifies the current logical session uniquelyresourceUri- the URI of the desired HTTP resourcevalue- the value to be used as token for the page
-
setPageTokens
void setPageTokens(String sessionKey, Map<String,String> pageTokens)
Sets/overwrites the page tokens with the provided values- Parameters:
sessionKey- identifies the current logical session uniquelypageTokens- page tokens mapped to their resource URIs
-
getPageTokens
Map<String,String> getPageTokens(String sessionKey)
Returns all page tokens associated to the provided logical session key- Parameters:
sessionKey- identifies the current logical session uniquely- Returns:
- page tokens mapped to their resource URIs
-
remove
void remove(String sessionKey)
Removes all tokens related to a specific logical session key- Parameters:
sessionKey- identifies the current logical session uniquely
-
rotateAllPageTokens
void rotateAllPageTokens(String sessionKey, Supplier<String> tokenValueSupplier)
Re-generates all existing tokens associated to the provided logical session key- Parameters:
sessionKey- identifies the current logical session uniquelytokenValueSupplier- produces a new page token value lazily/on demand
-
regenerateUsedPageToken
void regenerateUsedPageToken(String sessionKey, String tokenFromRequest, Supplier<String> tokenValueSupplier)
Re-generates the value of a used page token- Parameters:
sessionKey- identifies the current logical session uniquelytokenFromRequest- the token extracted from the requesttokenValueSupplier- produces a new page token value lazily/on demand
-
-