Class FindTrustedDeviceUseCase

java.lang.Object
com.irurueta.authserver.authorization.application.mfa.FindTrustedDeviceUseCase

@Service @Transactional(readOnly=true) public class FindTrustedDeviceUseCase extends Object
Use case that finds the usable (not revoked, not expired) trusted device of a user from the value of the cookie. The signature of the value is checked first, in constant time: a forged or unsigned value is rejected before the account or the device is looked up.
  • Field Details

    • trustedDeviceTokenSigner

      private final TrustedDeviceTokenSigner trustedDeviceTokenSigner
      Port that checks the signature of the cookie value.
    • userAccountRepository

      private final UserAccountRepository userAccountRepository
      Port that provides the user accounts.
    • trustedDeviceRepository

      private final TrustedDeviceRepository trustedDeviceRepository
      Port that stores the trusted devices.
    • trustedDeviceTokens

      private final TrustedDeviceTokens trustedDeviceTokens
      Creator and hasher of the tokens.
    • clock

      private final Clock clock
      Source of the current time.
  • Constructor Details

    • FindTrustedDeviceUseCase

      public FindTrustedDeviceUseCase()
  • Method Details

    • execute

      public Optional<TrustedDevice> execute(String username, String cookieValue)
      Finds the device.
      Parameters:
      username - name the user signed in with.
      cookieValue - the signed value presented by the browser.
      Returns:
      the device, or empty if the signature is wrong, the account does not exist, or the token is unknown, expired, revoked or belongs to another user.