Package org.keycloak.models.utils
Class TimeBasedOTP
java.lang.Object
org.keycloak.models.utils.HmacOTP
org.keycloak.models.utils.TimeBasedOTP
TOTP: Time-based One-time Password Algorithm Based on http://tools.ietf.org/html/draft-mraihi-totp-timebased-06
- Since:
- Sep 20, 2010
- Author:
- anil saldhana
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
Fields inherited from class org.keycloak.models.utils.HmacOTP
algorithm, DEFAULT_ALGORITHM, DEFAULT_NUMBER_DIGITS, HMAC_SHA1, HMAC_SHA256, HMAC_SHA512, lookAroundWindow, numberDigits
-
Constructor Summary
ConstructorDescriptionTimeBasedOTP
(String algorithm, int numberDigits, int timeIntervalInSeconds, int lookAroundWindow) -
Method Summary
Modifier and TypeMethodDescriptiongenerateTOTP
(byte[] secretKey) Generates a token.generateTOTP
(String secretKey) void
setCalendar
(Calendar calendar) boolean
validateTOTP
(String token, byte[] secret) Validates a token using a secret key.Methods inherited from class org.keycloak.models.utils.HmacOTP
generateHOTP, generateHOTP, generateOTP, generateSecret, validateHOTP, validateHOTP
-
Field Details
-
DEFAULT_INTERVAL_SECONDS
public static final int DEFAULT_INTERVAL_SECONDS- See Also:
-
DEFAULT_DELAY_WINDOW
public static final int DEFAULT_DELAY_WINDOW- See Also:
-
-
Constructor Details
-
TimeBasedOTP
public TimeBasedOTP() -
TimeBasedOTP
public TimeBasedOTP(String algorithm, int numberDigits, int timeIntervalInSeconds, int lookAroundWindow) - Parameters:
algorithm
- the encryption algorithmnumberDigits
- the number of digits for tokenstimeIntervalInSeconds
- the number of seconds a token is validlookAroundWindow
- the number of previous and following intervals that should be used to validate tokens.
-
-
Method Details
-
generateTOTP
Generates a token.
- Parameters:
secretKey
- the secret key to derive the token from.
-
generateTOTP
-
validateTOTP
Validates a token using a secret key.
- Parameters:
token
- OTP string to validatesecret
- Shared secret- Returns:
- true of the token is valid
-
setCalendar
-