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
-
Constructor Summary
ConstructorDescriptionTokenDAOMemory
(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.void
Remove token.void
Removes a token.void
Wipes all tokens from the store.void
removeAll
(long directoryId) Remove all tokens associated with the given directory id.void
removeExcept
(long directoryId, String name, String exclusionToken) Remove all tokens for the user except for the token specified byexclusionToken
.void
removeExpiredTokens
(Date currentTime, long maxLifeInSeconds) Remove all tokens that have expired.void
saveAll
(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:SessionTokenStorage
Finds token by random hash.- Specified by:
findByRandomHash
in 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:SessionTokenStorage
Finds token by identifier hash.- Specified by:
findByIdentifierHash
in 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:SessionTokenStorage
Persists a new token.- Specified by:
add
in interfaceSessionTokenStorage
- Parameters:
token
- Token.- Returns:
- The persisted token.
- Throws:
ObjectAlreadyExistsException
- if a token with the same identifier hash already exists.
-
update
- Specified by:
update
in interfaceSessionTokenStorage
- Parameters:
token
- token to update.- Returns:
- updates the last accessed date on the token (sets it to now).
-
remove
Description copied from interface:SessionTokenStorage
Removes a token.- Specified by:
remove
in interfaceSessionTokenStorage
- Parameters:
token
- Token.
-
search
Description copied from interface:SearchableTokenStorage
Searches for token based on criteria.- Specified by:
search
in interfaceSearchableTokenStorage
- Parameters:
query
- Query.- Returns:
- List of tokens which qualify for the criteria.
-
remove
Description copied from interface:SessionTokenStorage
Remove token.- Specified by:
remove
in interfaceSessionTokenStorage
- Parameters:
directoryId
- Directory id.name
- User or application name.
-
removeExcept
Description copied from interface:SessionTokenStorage
Remove all tokens for the user except for the token specified byexclusionToken
.- Specified by:
removeExcept
in 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:SessionTokenStorage
Remove all tokens associated with the given directory id.- Specified by:
removeAll
in interfaceSessionTokenStorage
- Parameters:
directoryId
- Directory id.
-
removeExpiredTokens
Description copied from interface:SessionTokenStorage
Remove all tokens that have expired. For a store that performs expiry asynchronously this may be a no-op.- Specified by:
removeExpiredTokens
in interfaceSessionTokenStorage
- Parameters:
currentTime
- Current datemaxLifeInSeconds
- Max lifespan for tokens, unless they specific a shorter one.
-
loadAll
Description copied from interface:TokenDAO
Used 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:TokenDAO
Used 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:SessionTokenStorage
Wipes all tokens from the store.- Specified by:
removeAll
in interfaceSessionTokenStorage
-