public class TimeBasedOTP extends HmacOTP
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_DELAY_WINDOW |
static int |
DEFAULT_INTERVAL_SECONDS |
algorithm, DEFAULT_ALGORITHM, DEFAULT_NUMBER_DIGITS, HMAC_SHA1, HMAC_SHA256, HMAC_SHA512, lookAheadWindow, numberDigits| Constructor and Description |
|---|
TimeBasedOTP() |
TimeBasedOTP(String algorithm,
int numberDigits,
int timeIntervalInSeconds,
int lookAheadWindow) |
| Modifier and Type | Method and Description |
|---|---|
String |
generateTOTP(String secretKey)
Generates a token.
|
void |
setCalendar(Calendar calendar) |
boolean |
validateTOTP(String token,
byte[] secret)
Validates a token using a secret key.
|
generateHOTP, generateOTP, generateSecret, validateHOTPpublic static final int DEFAULT_INTERVAL_SECONDS
public static final int DEFAULT_DELAY_WINDOW
public TimeBasedOTP()
public TimeBasedOTP(String algorithm, int numberDigits, int timeIntervalInSeconds, int lookAheadWindow)
algorithm - the encryption algorithmnumberDigits - the number of digits for tokenstimeIntervalInSeconds - the number of seconds a token is validlookAheadWindow - the number of previous intervals that should be used to validate tokens.public String generateTOTP(String secretKey)
Generates a token.
secretKey - the secret key to derive the token from.public boolean validateTOTP(String token, byte[] secret)
Validates a token using a secret key.
token - OTP string to validatesecret - Shared secretpublic void setCalendar(Calendar calendar)
Copyright © 2016 JBoss by Red Hat. All rights reserved.