Interface TrustedDeviceRepository


public interface TrustedDeviceRepository
Port that stores the devices users trust.
  • Method Details

    • store

      void store(TrustedDevice device)
      Stores a new trusted device.
      Parameters:
      device - the device to store.
    • findUsable

      Optional<TrustedDevice> findUsable(UUID userId, String hashedToken, Instant now)
      Finds a device that is still trusted.
      Parameters:
      userId - identifier of the user.
      hashedToken - hash of the device token presented by the browser.
      now - current instant, compared against the expiry.
      Returns:
      the device, or an empty optional when there is no such unexpired device.
    • findByUser

      List<TrustedDevice> findByUser(UUID userId, Instant now)
      Lists the devices of a user that are still trusted.
      Parameters:
      userId - identifier of the user.
      now - current instant, compared against the expiry.
      Returns:
      the unexpired devices, possibly empty.
    • revoke

      boolean revoke(UUID userId, UUID id)
      Revokes a device of a user.
      Parameters:
      userId - identifier of the user, so nobody can revoke another user's device.
      id - identifier of the device.
      Returns:
      true when a device was revoked.
    • deleteByUser

      int deleteByUser(UUID userId)
      Revokes every device of a user, for example when the second factor they skip is removed.
      Parameters:
      userId - identifier of the user.
      Returns:
      the number of revoked devices.
    • deleteExpired

      int deleteExpired(Instant now)
      Deletes the devices that expired before an instant.
      Parameters:
      now - current instant.
      Returns:
      the number of deleted devices.