Class TokenManagerInMemory<T extends Token>
- java.lang.Object
-
- org.bardframework.commons.security.token.manager.TokenManagerInMemory<T>
-
- All Implemented Interfaces:
TokenManager<T>
public abstract class TokenManagerInMemory<T extends Token> extends Object implements TokenManager<T>
Implements simple token manager, that keeps a single token for each user. If user logs in again, older token is invalidated.
-
-
Field Summary
Fields Modifier and Type Field Description protected longtokenExpirationMillsmillisecond token expire timeprotected Map<String,T>tokensMap
-
Constructor Summary
Constructors Modifier Constructor Description protectedTokenManagerInMemory(long tokenExpirationMills)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanExpired()clean expired tokensTget(String tokenId)Returns user details for a token.longgetTokenExpirationMills()Map<String,T>getTokensMap()Stringput(T token)Creates a new token for the user and returns it.booleanremove(String tokenId)Removes a single token.
-
-
-
Method Detail
-
put
public String put(T token)
Description copied from interface:TokenManagerCreates a new token for the user and returns it. It may add it to the token list or replace the previous one for the user. Never returnsnull.- Specified by:
putin interfaceTokenManager<T extends Token>
-
remove
public boolean remove(String tokenId)
Description copied from interface:TokenManagerRemoves a single token.- Specified by:
removein interfaceTokenManager<T extends Token>
-
get
public T get(String tokenId)
Description copied from interface:TokenManagerReturns user details for a token.- Specified by:
getin interfaceTokenManager<T extends Token>
-
getTokenExpirationMills
public long getTokenExpirationMills()
-
cleanExpired
@Scheduled(cron="${token.manager.cleaner.cron:0 */1 * * * *}") public void cleanExpired()clean expired tokens
-
-