Package org.keycloak.models.utils
Class HmacOTP
java.lang.Object
org.keycloak.models.utils.HmacOTP
- Direct Known Subclasses:
TimeBasedOTP
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongenerateHOTP
(byte[] key, int counter) generateHOTP
(String key, int counter) generateOTP
(byte[] key, String counter, int returnDigits, String crypto) This method generates an OTP value for the given set of parameters.static String
generateSecret
(int length) int
validateHOTP
(String token, byte[] key, int counter) int
validateHOTP
(String token, String key, int counter)
-
Field Details
-
HMAC_SHA1
- See Also:
-
HMAC_SHA256
- See Also:
-
HMAC_SHA512
- See Also:
-
DEFAULT_ALGORITHM
- See Also:
-
DEFAULT_NUMBER_DIGITS
public static final int DEFAULT_NUMBER_DIGITS- See Also:
-
algorithm
-
numberDigits
protected final int numberDigits -
lookAroundWindow
protected final int lookAroundWindow
-
-
Constructor Details
-
HmacOTP
-
-
Method Details
-
generateSecret
-
generateHOTP
-
generateHOTP
-
validateHOTP
- Parameters:
token
-key
-counter
-- Returns:
- -1 if not a match. A positive number means successful validation. This positive number is also the new value of the counter
-
validateHOTP
-
generateOTP
This method generates an OTP value for the given set of parameters.- Parameters:
key
- the shared secret, HEX encodedcounter
- a value that reflects a timereturnDigits
- number of digits to returncrypto
- the crypto function to use- Returns:
- A numeric String in base 10 that includes return digits
- Throws:
GeneralSecurityException
-