Class TokenDigestService
java.lang.Object
com.svenruppert.jsentinel.credential.token.TokenDigestService
Selector/verifier token issuance and verification.
A reset-, email-verification- or remember-me token consists of a non-secret selector (looked up in the store) and a secret verifier (compared against the stored digest in constant time). The password-hashing pipeline is deliberately not used here: random-salt KDFs cannot be looked up by hash, and using one would either force an O(n) scan or leak timing information (CWE-208 / CWE-640).
Verifier digest = SHA-256 of the verifier bytes. The verifier
itself comes from SecureRandom with at least 32 bytes of
entropy (CWE-330), so a plain unkeyed digest is unforgeable without
the verifier.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondigest(SelectorVerifierToken token) Returns the persistable digest record for the supplied token.generate()Generates a fresh token from the suppliedSecureRandom.Parses the wire formselector.verifier.verifyVerifier(SelectorVerifierToken candidate, TokenDigestRecord stored) Verifies the supplied token's verifier against the stored digest record.
-
Constructor Details
-
TokenDigestService
public TokenDigestService() -
TokenDigestService
-
-
Method Details
-
generate
Generates a fresh token from the suppliedSecureRandom. -
digest
Returns the persistable digest record for the supplied token. -
parse
Parses the wire formselector.verifier. ReturnsOptional.empty()for malformed input — the caller maps that to the same generic public failure as a wrong verifier so timing stays uniform (CWE-208). -
verifyVerifier
public TokenVerificationResult verifyVerifier(SelectorVerifierToken candidate, TokenDigestRecord stored) Verifies the supplied token's verifier against the stored digest record. Constant-time comparison viaMessageDigest.isEqual(byte[], byte[]).
-