Package com.atlassian.crowd.dao.token
Class TokenDAOMemory
java.lang.Object
com.atlassian.crowd.dao.token.TokenDAOMemory
- All Implemented Interfaces:
SearchableTokenStorage,SessionTokenStorage,TokenDAO
An in-memory implementation of the TokenDAO. This will use the caching manager.
This class is thread-safe.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTokenDAOMemory(com.atlassian.cache.Cache<String, Token> randomHashCache, com.atlassian.cache.Cache<String, Token> identifierHashCache) TokenDAOMemory(com.atlassian.cache.CacheFactory cacheManager) -
Method Summary
Modifier and TypeMethodDescriptionPersists a new token.findByIdentifierHash(String identifierHash) Finds token by identifier hash.findByRandomHash(String randomHash) Finds token by random hash.loadAll()Used when switching implementations.voidRemove token.voidRemoves a token.voidWipes all tokens from the store.voidremoveAll(long directoryId) Remove all tokens associated with the given directory id.voidremoveExcept(long directoryId, String name, String exclusionToken) Remove all tokens for the user except for the token specified byexclusionToken.voidremoveExpiredTokens(Date currentTime, long maxLifeInSeconds) Remove all tokens that have expired.voidsaveAll(Collection<Token> tokens) Used when switching implementations.search(EntityQuery<? extends AuthenticationToken> query) Searches for token based on criteria.
-
Field Details
-
RANDOM_HASH_CACHE
-
IDENTIFIER_HASH_CACHE
-
-
Constructor Details
-
TokenDAOMemory
public TokenDAOMemory(com.atlassian.cache.CacheFactory cacheManager) -
TokenDAOMemory
-
-
Method Details
-
findByRandomHash
Description copied from interface:SessionTokenStorageFinds token by random hash.- Specified by:
findByRandomHashin interfaceSessionTokenStorage- Parameters:
randomHash- Random hash.- Returns:
- Token.
- Throws:
ObjectNotFoundException- if the token identified by the random hash cannot be found.
-
findByIdentifierHash
Description copied from interface:SessionTokenStorageFinds token by identifier hash.- Specified by:
findByIdentifierHashin interfaceSessionTokenStorage- Parameters:
identifierHash- Identifier hash.- Returns:
- Token.
- Throws:
ObjectNotFoundException- if the token identified by the identifier hash cannot be found.
-
add
Description copied from interface:SessionTokenStoragePersists a new token.- Specified by:
addin interfaceSessionTokenStorage- Parameters:
token- Token.- Returns:
- The persisted token.
- Throws:
ObjectAlreadyExistsException- if a token with the same identifier hash already exists.
-
update
- Specified by:
updatein interfaceSessionTokenStorage- Parameters:
token- token to update.- Returns:
- updates the last accessed date on the token (sets it to now).
-
remove
Description copied from interface:SessionTokenStorageRemoves a token.- Specified by:
removein interfaceSessionTokenStorage- Parameters:
token- Token.
-
search
Description copied from interface:SearchableTokenStorageSearches for token based on criteria.- Specified by:
searchin interfaceSearchableTokenStorage- Parameters:
query- Query.- Returns:
- List of tokens which qualify for the criteria.
-
remove
Description copied from interface:SessionTokenStorageRemove token.- Specified by:
removein interfaceSessionTokenStorage- Parameters:
directoryId- Directory id.name- User or application name.
-
removeExcept
Description copied from interface:SessionTokenStorageRemove all tokens for the user except for the token specified byexclusionToken.- Specified by:
removeExceptin interfaceSessionTokenStorage- Parameters:
directoryId- Directory id.name- User or application name.exclusionToken- the random hash of the token to retain, if present
-
removeAll
public void removeAll(long directoryId) Description copied from interface:SessionTokenStorageRemove all tokens associated with the given directory id.- Specified by:
removeAllin interfaceSessionTokenStorage- Parameters:
directoryId- Directory id.
-
removeExpiredTokens
Description copied from interface:SessionTokenStorageRemove all tokens that have expired. For a store that performs expiry asynchronously this may be a no-op.- Specified by:
removeExpiredTokensin interfaceSessionTokenStorage- Parameters:
currentTime- Current datemaxLifeInSeconds- Max lifespan for tokens, unless they specific a shorter one.
-
loadAll
Description copied from interface:TokenDAOUsed when switching implementations. Synchronisation is the caller's responsibility; don't allow calls to other methods while this is in progress if you need to guarantee that the data are complete. -
saveAll
Description copied from interface:TokenDAOUsed when switching implementations. Synchronization is the caller's reponsibility; don't allow calls to other methods while this is in progress if you need to guarantee that the data are complete. -
removeAll
public void removeAll()Description copied from interface:SessionTokenStorageWipes all tokens from the store.- Specified by:
removeAllin interfaceSessionTokenStorage
-