Package org.keycloak.models.utils
Class TimeBasedOTP
- java.lang.Object
- 
- org.keycloak.models.utils.HmacOTP
- 
- org.keycloak.models.utils.TimeBasedOTP
 
 
- 
 public class TimeBasedOTP extends HmacOTP 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 SummaryFields Modifier and Type Field Description static intDEFAULT_DELAY_WINDOWstatic intDEFAULT_INTERVAL_SECONDS- 
Fields inherited from class org.keycloak.models.utils.HmacOTPalgorithm, DEFAULT_ALGORITHM, DEFAULT_NUMBER_DIGITS, HMAC_SHA1, HMAC_SHA256, HMAC_SHA512, lookAheadWindow, numberDigits
 
- 
 - 
Constructor SummaryConstructors Constructor Description TimeBasedOTP()TimeBasedOTP(String algorithm, int numberDigits, int timeIntervalInSeconds, int lookAroundWindow)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgenerateTOTP(String secretKey)Generates a token.voidsetCalendar(Calendar calendar)booleanvalidateTOTP(String token, byte[] secret)Validates a token using a secret key.- 
Methods inherited from class org.keycloak.models.utils.HmacOTPgenerateHOTP, generateOTP, generateSecret, validateHOTP
 
- 
 
- 
- 
- 
Field Detail- 
DEFAULT_INTERVAL_SECONDSpublic static final int DEFAULT_INTERVAL_SECONDS - See Also:
- Constant Field Values
 
 - 
DEFAULT_DELAY_WINDOWpublic static final int DEFAULT_DELAY_WINDOW - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
TimeBasedOTPpublic TimeBasedOTP() 
 - 
TimeBasedOTPpublic TimeBasedOTP(String algorithm, int numberDigits, int timeIntervalInSeconds, int lookAroundWindow) - Parameters:
- algorithm- the encryption algorithm
- numberDigits- the number of digits for tokens
- timeIntervalInSeconds- the number of seconds a token is valid
- lookAroundWindow- the number of previous and following intervals that should be used to validate tokens.
 
 
- 
 - 
Method Detail- 
generateTOTPpublic String generateTOTP(String secretKey) Generates a token. - Parameters:
- secretKey- the secret key to derive the token from.
 
 - 
validateTOTPpublic boolean validateTOTP(String token, byte[] secret) Validates a token using a secret key. - Parameters:
- token- OTP string to validate
- secret- Shared secret
- Returns:
- true of the token is valid
 
 - 
setCalendarpublic void setCalendar(Calendar calendar) 
 
- 
 
-