Class InMemoryTokenRepositoryImpl
java.lang.Object
com.codename1.backend.security.rememberme.InMemoryTokenRepositoryImpl
- All Implemented Interfaces:
PersistentTokenRepository
Remembered sign-ins kept in this process: gone when it stops, and unknown to
any other process of the same deployment. For development and for a server
that runs alone; see
JdbcTokenRepository otherwise.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidStores a new series.getTokenForSeries(String series) The stored token ofseries, or null.voidremoveToken(String series) Forgets one series: one browser.voidremoveUserTokens(String username) Forgets every series of a user: every browser they were remembered in.intsize()How many series are stored.booleanupdateToken(String series, String expectedTokenHash, String newTokenHash, long lastUsed) Replaces the token ofseries, if it is stillexpectedTokenHash.
-
Constructor Details
-
InMemoryTokenRepositoryImpl
public InMemoryTokenRepositoryImpl()
-
-
Method Details
-
createNewToken
Description copied from interface:PersistentTokenRepositoryStores a new series.- Specified by:
createNewTokenin interfacePersistentTokenRepository
-
updateToken
public boolean updateToken(String series, String expectedTokenHash, String newTokenHash, long lastUsed) Description copied from interface:PersistentTokenRepositoryReplaces the token of
series, if it is stillexpectedTokenHash.The test and the change are one step: of two requests presenting the same cookie at the same moment, one replaces the token and the other is told it did not. Store
expectedTokenHashas the previous hash of the replacement token, so concurrent requests can recognize the rotation for a bounded grace period.- Specified by:
updateTokenin interfacePersistentTokenRepository- Returns:
- whether this call replaced it
-
getTokenForSeries
Description copied from interface:PersistentTokenRepositoryThe stored token ofseries, or null.- Specified by:
getTokenForSeriesin interfacePersistentTokenRepository
-
removeToken
Description copied from interface:PersistentTokenRepositoryForgets one series: one browser.- Specified by:
removeTokenin interfacePersistentTokenRepository
-
removeUserTokens
Description copied from interface:PersistentTokenRepositoryForgets every series of a user: every browser they were remembered in.- Specified by:
removeUserTokensin interfacePersistentTokenRepository
-
size
public int size()How many series are stored.
-