Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class InMemoryTokenRepositoryImpl
- Object
- InMemoryTokenRepositoryImpl
ImplementsPersistentTokenRepository
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.Constructors
public InMemoryTokenRepositoryImpl() |
Methods
public synchronized void createNewToken(PersistentRememberMeToken token) | Stores a new series. |
public synchronized boolean updateToken(String series, String expectedTokenHash, String newTokenHash, long lastUsed) | Replaces the token of series, if it is still expectedTokenHash. |
public synchronized PersistentRememberMeToken getTokenForSeries(String series) | The stored token of series, or null. |
public synchronized void removeToken(String series) | Forgets one series: one browser. |
public synchronized void removeUserTokens(String username) | Forgets every series of a user: every browser they were remembered in. |
public synchronized List<PersistentRememberMeToken> getTokensForUser(String username) | How many series are stored. |
public synchronized boolean removeUserToken(String username, String series) | Revokes one series of a user, such as a device chosen on a “signed-in devices” page. |
public synchronized int size() |
Inherited methods
Constructor details
InMemoryTokenRepositoryImpl
public InMemoryTokenRepositoryImpl()Method details
createNewToken
public synchronized void createNewToken(PersistentRememberMeToken token)Stores a new series.
updateToken
public synchronized boolean updateToken(String series, String expectedTokenHash, String newTokenHash, long lastUsed)Replaces the token of series, if it is still expectedTokenHash.
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 expectedTokenHash as the previous hash of the replacement token,
so concurrent requests can recognize the rotation for a bounded grace period.
Returns
whether this call replaced it
getTokenForSeries
public synchronized PersistentRememberMeToken getTokenForSeries(String series)The stored token of
series, or null.removeToken
public synchronized void removeToken(String series)Forgets one series: one browser.
removeUserTokens
public synchronized void removeUserTokens(String username)Forgets every series of a user: every browser they were remembered in.
getTokensForUser
public synchronized List<PersistentRememberMeToken> getTokensForUser(String username)How many series are stored.
Parameters
usernameString- the user, matched ignoring case as sign-in does
removeUserToken
public synchronized boolean removeUserToken(String username, String series)Revokes one series of a user, such as a device chosen on a “signed-in
devices” page. A series of another user is left alone, so a series taken
from a request cannot revoke someone else’s sign-in.
Returns
whether the series belonged to the user and was removed
size
public synchronized int size()