public class HmacOTP extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
algorithm |
static String |
DEFAULT_ALGORITHM |
static int |
DEFAULT_NUMBER_DIGITS |
static String |
HMAC_SHA1 |
static String |
HMAC_SHA256 |
static String |
HMAC_SHA512 |
protected int |
lookAheadWindow |
protected int |
numberDigits |
Constructor and Description |
---|
HmacOTP(int numberDigits,
String algorithm,
int delayWindow) |
Modifier and Type | Method and Description |
---|---|
String |
generateHOTP(String key,
int counter) |
String |
generateOTP(String 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,
String key,
int counter) |
public static final String HMAC_SHA1
public static final String HMAC_SHA256
public static final String HMAC_SHA512
public static final String DEFAULT_ALGORITHM
public static final int DEFAULT_NUMBER_DIGITS
protected final String algorithm
protected final int numberDigits
protected final int lookAheadWindow
public HmacOTP(int numberDigits, String algorithm, int delayWindow)
public static String generateSecret(int length)
public int validateHOTP(String token, String key, int counter)
token
- key
- counter
- public String generateOTP(String key, String counter, int returnDigits, String crypto)
key
- the shared secret, HEX encodedcounter
- a value that reflects a timereturnDigits
- number of digits to returncrypto
- the crypto function to useGeneralSecurityException
Copyright © 2019 JBoss by Red Hat. All rights reserved.