Class TrustedDeviceTokens

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

@Component public class TrustedDeviceTokens extends Object
Creates the random tokens that identify a trusted device and hashes them, so only the SHA-256 hash is ever stored.
  • Field Details

    • TOKEN_BYTES

      public static final int TOKEN_BYTES
      Size of a token in bytes (256 bits).
      See Also:
    • HASH_ALGORITHM

      private static final String HASH_ALGORITHM
      Name of the hash algorithm.
      See Also:
    • random

      private final SecureRandom random
      Source of randomness.
  • Constructor Details

    • TrustedDeviceTokens

      public TrustedDeviceTokens()
  • Method Details

    • newToken

      public String newToken()
      Creates a new random token.
      Returns:
      the URL-safe token, to be handed to the browser once.
    • hash

      public String hash(String token)
      Hashes a token.
      Parameters:
      token - the raw token.
      Returns:
      the lowercase hexadecimal SHA-256 hash.