Class SecureRandomOneTimeCodeGenerator
java.lang.Object
com.irurueta.authserver.authorization.application.ott.SecureRandomOneTimeCodeGenerator
- All Implemented Interfaces:
OneTimeCodeGenerator
Generates numeric one-time codes with a cryptographically strong random number generator. Every digit is drawn
independently and uniformly, so leading zeros are kept (
004217).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intNumber of decimal digits.private final SecureRandomSource of randomness. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
RADIX
private static final int RADIXNumber of decimal digits.- See Also:
-
secureRandom
Source of randomness.
-
-
Constructor Details
-
SecureRandomOneTimeCodeGenerator
public SecureRandomOneTimeCodeGenerator()
-
-
Method Details
-
generate
Generates a code.- Specified by:
generatein interfaceOneTimeCodeGenerator- Parameters:
digits- number of digits, at least one.- Returns:
- the zero-padded code.
- Throws:
IllegalArgumentException- ifdigitsis not positive.
-