Package org.apache.wiki.auth
Class PasswordResetTokenStore
java.lang.Object
org.apache.wiki.auth.PasswordResetTokenStore
In-memory store of single-use, expiring password reset tokens, used by
LostPassword.jsp.
A password reset is a two-step operation: a cryptographically random token is issued and mailed to the
account owner (issue(String)), and the stored credential is only changed when that token is
presented back (redeem(String)). Only a SHA-256 hash of the token is kept server-side, tokens
expire after TOKEN_TTL_MS, are removed on first use, and at most one token per account may be
outstanding at a time (which also acts as a simple per-account throttle). The store itself is bounded
to MAX_PENDING entries as a global backstop.
Note: the store is per-JVM. On a multi-node deployment a token must be redeemed on the node that issued it.
- Since:
- 2.12.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longHow long an issued token stays valid: 30 minutes. -
Method Summary
Modifier and TypeMethodDescriptionstatic PasswordResetTokenStoreReturns the shared store instance.Issues a new reset token for the given login name.Redeems a token: if it matches a stored, non-expired token hash, the token is removed (single use) and the login name it was issued for is returned.
-
Field Details
-
TOKEN_TTL_MS
How long an issued token stays valid: 30 minutes.- See Also:
-
-
Method Details
-
getInstance
Returns the shared store instance.- Returns:
- the shared
PasswordResetTokenStore.
-
issue
Issues a new reset token for the given login name. The raw token is returned exactly once, for inclusion in the reset e-mail; only its SHA-256 hash is retained. If a non-expired token is already outstanding for the account, or the store is full, no token is issued.- Parameters:
loginName- the login name the token is bound to.- Returns:
- the raw token, or
nullif issuance was throttled.
-
redeem
Redeems a token: if it matches a stored, non-expired token hash, the token is removed (single use) and the login name it was issued for is returned. Comparison of the hashed values is constant-time.- Parameters:
token- the raw token as received from the user.- Returns:
- the login name the token was bound to, or
nullif the token is unknown, already used or expired.
-