Package com.atlassian.crowd.dao.token
Class TokenDAOHibernate
java.lang.Object
com.atlassian.crowd.util.persistence.hibernate.StatelessDao
com.atlassian.crowd.util.persistence.hibernate.HibernateDao<Token>
com.atlassian.crowd.dao.token.TokenDAOHibernate
- All Implemented Interfaces:
SearchableTokenStorage
,SessionTokenStorage
,TokenDAO
-
Field Summary
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
batchFinder, batchProcessor, logger, statelessSessionBatchProcessor, timeSource
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
sessionFactory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPersists a new token.findByID
(long ID) findByIdentifierHash
(String identifierHash) Finds token by identifier hash.findByRandomHash
(String randomHash) Finds token by random hash.All subclasses of HibernateDao must implement this method forHibernateDao.load(Serializable)
to work correctly.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.Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
createDeleteQuery, createDeleteQuery, createQuery, createQuery, executeHQLQuery, findAllInternal, findByProperties, findByPropertiesOptional, findByProperty, findByProperty, findByPropertyOptional, findByPropertyOrThrow, getCountByProperties, load, load, loadOptional, loadReference, loadReference, remove, removeByIdIfPresent, save, saveOrUpdate, session, setBatchFinder, setBatchProcessor, setClock, setStatelessSessionBatchProcessor, toPredicates, update
Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
setSessionFactory, withStatelessSession
-
Constructor Details
-
TokenDAOHibernate
-
-
Method Details
-
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.
-
findByID
- Throws:
ObjectNotFoundException
-
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.
-
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.
-
getPersistentClass
Description copied from class:HibernateDao
All subclasses of HibernateDao must implement this method forHibernateDao.load(Serializable)
to work correctly.- Specified by:
getPersistentClass
in classHibernateDao<Token>
- Returns:
- the entity class for this DAO
-
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. -
remove
Description copied from interface:SessionTokenStorage
Removes a token.- Specified by:
remove
in interfaceSessionTokenStorage
- Parameters:
token
- Token.
-
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
-
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.
-
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.
-
removeAll
public void removeAll()Description copied from interface:SessionTokenStorage
Wipes all tokens from the store.- Specified by:
removeAll
in interfaceSessionTokenStorage
-
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. -
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.
-
update
- Specified by:
update
in interfaceSessionTokenStorage
- Parameters:
token
- token to update.- Returns:
- updates the last accessed date on the token (sets it to now).
-