@ThreadSafe @Transactional public class SwitchableTokenManagerImpl extends Object implements SwitchableTokenManager, SearchableTokenService
Constructor and Description |
---|
SwitchableTokenManagerImpl(boolean initialUseIsMemory,
TokenDAO daoMemory,
TokenDAO daoHibernate,
PropertyManager propertyManager,
ClusterService clusterService) |
SwitchableTokenManagerImpl(TokenDAO daoMemory,
TokenDAO daoHibernate,
PropertyManager propertyManager,
ClusterService clusterService) |
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
isUsingDatabaseStorage()
Returns true if the memory token manager is in use.
|
void |
remove(long directoryID,
String name)
Remove token.
|
void |
remove(Token token)
Removes a token.
|
void |
removeAll()
Removes all tokens from all implementations.
|
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 maxLifeSeconds)
Remove all tokens that have expired.
|
List<AuthenticationToken> |
search(EntityQuery<? extends AuthenticationToken> query)
Searches for token based on criteria.
|
void |
setUsingDatabaseStorage(boolean useDatabaseStorage)
Performs the switch, if necessary.
|
void |
switchToHibernate()
If the In-memory DAO is in use, transparently switches to Hibernate DAO.
|
void |
switchToMemory()
If the Hibernate DAO is in use, transparently switches to In-memory DAO.
|
Token |
update(Token token) |
void |
updateTokenStorage()
Updates the switchable token manager to match the current configuration.
|
public SwitchableTokenManagerImpl(boolean initialUseIsMemory, TokenDAO daoMemory, TokenDAO daoHibernate, PropertyManager propertyManager, ClusterService clusterService)
public SwitchableTokenManagerImpl(TokenDAO daoMemory, TokenDAO daoHibernate, PropertyManager propertyManager, ClusterService clusterService)
public Token findByRandomHash(String randomHash) throws org.springframework.dao.DataAccessException, ObjectNotFoundException
SessionTokenStorage
findByRandomHash
in interface SessionTokenStorage
randomHash
- Random hash.ObjectNotFoundException
- if the token identified by the random hash cannot be found.org.springframework.dao.DataAccessException
public Token findByIdentifierHash(String identifierHash) throws ObjectNotFoundException
SessionTokenStorage
findByIdentifierHash
in interface SessionTokenStorage
identifierHash
- Identifier hash.ObjectNotFoundException
- if the token identified by the identifier hash cannot be found.public Token add(Token token) throws org.springframework.dao.DataAccessException, ObjectAlreadyExistsException
SessionTokenStorage
add
in interface SessionTokenStorage
token
- Token.ObjectAlreadyExistsException
- if a token with the same identifier hash already exists.org.springframework.dao.DataAccessException
public Token update(Token token) throws ObjectNotFoundException
update
in interface SessionTokenStorage
token
- token to update.ObjectNotFoundException
public void remove(Token token) throws org.springframework.dao.DataAccessException
SessionTokenStorage
remove
in interface SessionTokenStorage
token
- Token.org.springframework.dao.DataAccessException
public List<AuthenticationToken> search(EntityQuery<? extends AuthenticationToken> query)
SearchableTokenStorage
search
in interface SearchableTokenStorage
query
- Query.public void remove(long directoryID, String name) throws org.springframework.dao.DataAccessException
SessionTokenStorage
remove
in interface SessionTokenStorage
directoryID
- Directory id.name
- User or application name.org.springframework.dao.DataAccessException
public void removeExcept(long directoryId, String name, String exclusionToken)
SessionTokenStorage
exclusionToken
.removeExcept
in interface SessionTokenStorage
directoryId
- Directory id.name
- User or application name.exclusionToken
- the random hash of the token to retain, if presentpublic void removeAll(long directoryId)
SessionTokenStorage
removeAll
in interface SessionTokenStorage
directoryId
- Directory id.public void removeExpiredTokens(Date currentTime, long maxLifeSeconds)
SessionTokenStorage
removeExpiredTokens
in interface SessionTokenStorage
currentTime
- Current datemaxLifeSeconds
- Max lifespan for tokens, unless they specific a shorter one.public void removeAll()
removeAll
in interface SessionTokenStorage
public boolean isUsingDatabaseStorage()
isUsingDatabaseStorage
in interface SwitchableTokenManager
public void setUsingDatabaseStorage(boolean useDatabaseStorage) throws PropertyManagerException
setUsingDatabaseStorage
in interface SwitchableTokenManager
PropertyManagerException
public void switchToMemory()
public void switchToHibernate()
public void updateTokenStorage()
SwitchableTokenManager
SwitchableTokenManager.setUsingDatabaseStorage(boolean)
),
for instance, after a backup restore.updateTokenStorage
in interface SwitchableTokenManager
Copyright © 2020 Atlassian. All rights reserved.