com.atlassian.crowd.dao.token
Class TokenDAOMemory

java.lang.Object
  extended by com.atlassian.crowd.dao.token.TokenDAOMemory
All Implemented Interfaces:
SearchableTokenStorage, SessionTokenStorage, TokenDAO

public class TokenDAOMemory
extends Object
implements TokenDAO

An in-memory implementation of the TokenDAO. This will use the caching manager. This class is thread-safe.


Field Summary
static String IDENTIFIER_HASH_CACHE
           
static String IDENTIFIER_HASH_CAHE
          Deprecated. 
static String RANDOM_HASH_CACHE
           
 
Constructor Summary
TokenDAOMemory(CacheManager cacheManager)
           
 
Method Summary
 Token add(Token token)
          Persists a new token.
 Token findByIdentifierHash(String identifierHash)
          Finds token by identifier hash.
 Token findByRandomHash(String randomHash)
          Finds token by random hash.
 Collection<Token> loadAll()
          Used when switching implementations.
 void remove(long directoryId, String name)
          Remove token.
 void remove(Token token)
          Removes a token.
 void removeAll()
          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 by exclusionToken.
 void removeExpiredTokens(Date currentTime, long maxLifeInSeconds)
          Remove all tokens that have expired.
 void saveAll(Collection<Token> tokens)
          Used when switching implementations.
 List<Token> search(EntityQuery<? extends Token> query)
          Searches for token based on criteria.
 Token update(Token token)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RANDOM_HASH_CACHE

public static final String RANDOM_HASH_CACHE

IDENTIFIER_HASH_CACHE

public static final String IDENTIFIER_HASH_CACHE

IDENTIFIER_HASH_CAHE

@Deprecated
public static final String IDENTIFIER_HASH_CAHE
Deprecated. 
Constructor Detail

TokenDAOMemory

public TokenDAOMemory(CacheManager cacheManager)
Method Detail

findByRandomHash

public Token findByRandomHash(String randomHash)
                       throws ObjectNotFoundException
Description copied from interface: SessionTokenStorage
Finds token by random hash.

Specified by:
findByRandomHash in interface SessionTokenStorage
Parameters:
randomHash - Random hash.
Returns:
Token.
Throws:
ObjectNotFoundException - if the token identified by the random hash cannot be found.

findByIdentifierHash

public Token findByIdentifierHash(String identifierHash)
                           throws ObjectNotFoundException
Description copied from interface: SessionTokenStorage
Finds token by identifier hash.

Specified by:
findByIdentifierHash in interface SessionTokenStorage
Parameters:
identifierHash - Identifier hash.
Returns:
Token.
Throws:
ObjectNotFoundException - if the token identified by the identifier hash cannot be found.

add

public Token add(Token token)
          throws ObjectAlreadyExistsException
Description copied from interface: SessionTokenStorage
Persists a new token.

Specified by:
add in interface SessionTokenStorage
Parameters:
token - Token.
Returns:
The persisted token.
Throws:
ObjectAlreadyExistsException - if a token with the same identifier hash already exists.

update

public Token update(Token token)
Specified by:
update in interface SessionTokenStorage
Parameters:
token - token to update.
Returns:
updates the last accessed date on the token (sets it to now).

remove

public void remove(Token token)
Description copied from interface: SessionTokenStorage
Removes a token.

Specified by:
remove in interface SessionTokenStorage
Parameters:
token - Token.

search

public List<Token> search(EntityQuery<? extends Token> query)
Description copied from interface: SearchableTokenStorage
Searches for token based on criteria.

Specified by:
search in interface SearchableTokenStorage
Parameters:
query - Query.
Returns:
List of tokens which qualify for the criteria.

remove

public void remove(long directoryId,
                   String name)
Description copied from interface: SessionTokenStorage
Remove token.

Specified by:
remove in interface SessionTokenStorage
Parameters:
directoryId - Directory id.
name - User or application name.

removeExcept

public void removeExcept(long directoryId,
                         String name,
                         String exclusionToken)
Description copied from interface: SessionTokenStorage
Remove all tokens for the user except for the token specified by exclusionToken.

Specified by:
removeExcept in interface SessionTokenStorage
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 interface SessionTokenStorage
Parameters:
directoryId - Directory id.

removeExpiredTokens

public void removeExpiredTokens(Date currentTime,
                                long maxLifeInSeconds)
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 interface SessionTokenStorage
Parameters:
currentTime - Current date
maxLifeInSeconds - Max lifespan for tokens, unless they specific a shorter one.

loadAll

public Collection<Token> 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.

Specified by:
loadAll in interface TokenDAO
Returns:
Collection of all active tokens.

saveAll

public void saveAll(Collection<Token> tokens)
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.

Specified by:
saveAll in interface TokenDAO
Parameters:
tokens - all tokens to add.

removeAll

public void removeAll()
Description copied from interface: SessionTokenStorage
Wipes all tokens from the store.

Specified by:
removeAll in interface SessionTokenStorage


Copyright © 2016 Atlassian. All Rights Reserved.