Interface TotpCredentialRepository


public interface TotpCredentialRepository
Port that stores the TOTP credential of each user.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    advanceLastUsedStep(UUID userId, long step)
    Records the step of an accepted code, in one atomic step that only succeeds when the step is newer than the stored one, so that two concurrent requests cannot both spend the same code.
    void
    confirm(UUID userId)
    Marks the credential of a user as confirmed.
    void
    Deletes the credential of a user.
    findByUser(UUID userId)
    Finds the credential of a user.
    void
    save(TotpCredential credential)
    Stores a credential, replacing any previous one of the same user.
  • Method Details

    • findByUser

      Optional<TotpCredential> findByUser(UUID userId)
      Finds the credential of a user.
      Parameters:
      userId - identifier of the user.
      Returns:
      the credential, or an empty optional when the user has none.
    • save

      void save(TotpCredential credential)
      Stores a credential, replacing any previous one of the same user.
      Parameters:
      credential - the credential to store.
    • confirm

      void confirm(UUID userId)
      Marks the credential of a user as confirmed.
      Parameters:
      userId - identifier of the user.
    • advanceLastUsedStep

      boolean advanceLastUsedStep(UUID userId, long step)
      Records the step of an accepted code, in one atomic step that only succeeds when the step is newer than the stored one, so that two concurrent requests cannot both spend the same code.
      Parameters:
      userId - identifier of the user.
      step - step of the accepted code.
      Returns:
      true when the step was newer and has been recorded.
    • deleteByUser

      void deleteByUser(UUID userId)
      Deletes the credential of a user.
      Parameters:
      userId - identifier of the user.