Class InMemoryOneTimeTokenService
java.lang.Object
org.springframework.security.authentication.ott.InMemoryOneTimeTokenService
- All Implemented Interfaces:
OneTimeTokenService
Provides an in-memory implementation of the
OneTimeTokenService
interface that
uses a ConcurrentHashMap
to store the generated OneTimeToken
. A random
UUID
is used as the token value. A clean-up of the expired tokens is made if
there is more or equal than 100 tokens stored in the map.- Since:
- 6.4
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconsume
(OneTimeTokenAuthenticationToken authenticationToken) Consumes a one-time token based on the provided authentication token.generate
(GenerateOneTimeTokenRequest request) Generates a one-time token based on the provided generate request.void
Sets theClock
used when generating one-time token and checking token expiry.
-
Constructor Details
-
InMemoryOneTimeTokenService
public InMemoryOneTimeTokenService()
-
-
Method Details
-
generate
Description copied from interface:OneTimeTokenService
Generates a one-time token based on the provided generate request.- Specified by:
generate
in interfaceOneTimeTokenService
- Parameters:
request
- the generate request containing the necessary information to generate the token- Returns:
- the generated
OneTimeToken
, nevernull
.
-
consume
Description copied from interface:OneTimeTokenService
Consumes a one-time token based on the provided authentication token.- Specified by:
consume
in interfaceOneTimeTokenService
- Parameters:
authenticationToken
- the authentication token containing the one-time token value to be consumed- Returns:
- the consumed
OneTimeToken
ornull
if the token is invalid
-
setClock
Sets theClock
used when generating one-time token and checking token expiry.- Parameters:
clock
- the clock
-