Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class InMemoryRecoveryCodeRepository

  1. Object
  2. InMemoryRecoveryCodeRepository

ImplementsRecoveryCodeRepository

Recovery codes kept in this process: gone when it stops. For development and tests; see JdbcRecoveryCodeRepository otherwise.

Constructors

public InMemoryRecoveryCodeRepository()

Methods

public synchronized void replace(String username, List<String> codeHashes)Replaces every code of username with these hashes.
public synchronized List<String> findHashes(String username)A snapshot of the user’s salted password hashes, for checking a presented code.
public synchronized boolean consume(String username, String codeHash)Uses one code up.
public synchronized int count(String username)How many codes username has left.

Inherited methods

Constructor details

InMemoryRecoveryCodeRepository

public InMemoryRecoveryCodeRepository()

Method details

replace

public synchronized void replace(String username, List<String> codeHashes)
Replaces every code of username with these hashes.

findHashes

public synchronized 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 synchronized 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 synchronized int count(String username)
How many codes username has left.