Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class JdbcRecoveryCodeRepository
- Object
- JdbcRecoveryCodeRepository
ImplementsRecoveryCodeRepository
Recovery codes kept in the server’s database, in the
cn1_mfa_recovery_code table of SecuritySchema. A code is used up by one
DELETE that names it, and counted as used only when that removed exactly
one row.Constructors
public JdbcRecoveryCodeRepository(DataSource dataSource) |
Methods
public void replace(String username, List<String> codeHashes) | Replaces every code of username with these hashes. |
public List<String> findHashes(String username) | A snapshot of the user’s salted password hashes, for checking a presented code. |
public boolean consume(String username, String codeHash) | Uses one code up. |
public int count(String username) | How many codes username has left. |
Inherited methods
Constructor details
JdbcRecoveryCodeRepository
public JdbcRecoveryCodeRepository(DataSource dataSource)Method details
replace
public void replace(String username, List<String> codeHashes)Replaces every code of
username with these hashes.findHashes
public List<String> findHashes(String username)A snapshot of the user’s salted password hashes, for checking a presented code.
An unknown user has an empty list. Consumption still goes through
consume.consume
public boolean consume(String username, String codeHash)Uses one code up.
The test and the removal are one step: a code is good once, however many requests present it at the same moment.
Returns
whether this call removed it
count
public int count(String username)How many codes
username has left.