Interface TrustedDeviceRepository
- All Known Implementing Classes:
JdbcTrustedDeviceRepository
public interface TrustedDeviceRepository
Port that stores the devices users trust.
-
Method Summary
Modifier and TypeMethodDescriptionintdeleteByUser(UUID userId) Revokes every device of a user, for example when the second factor they skip is removed.intdeleteExpired(Instant now) Deletes the devices that expired before an instant.findByUser(UUID userId, Instant now) Lists the devices of a user that are still trusted.findUsable(UUID userId, String hashedToken, Instant now) Finds a device that is still trusted.booleanRevokes a device of a user.voidstore(TrustedDevice device) Stores a new trusted device.
-
Method Details
-
store
Stores a new trusted device.- Parameters:
device- the device to store.
-
findUsable
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
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
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:
truewhen a device was revoked.
-
deleteByUser
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
Deletes the devices that expired before an instant.- Parameters:
now- current instant.- Returns:
- the number of deleted devices.
-