public final class TwoFactorUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
generateBase32Secret()
Deprecated.
As of release 3.2.0, will be removed in 4.0.0
|
static String |
generateBase32Secret(int length)
Deprecated.
As of release 3.2.0, will be removed in 4.0.0
|
static String |
generateCurrentNumber(String secret)
Return the current number to be checked against the user input, using the
time found in System.currentTimeMillis()
WARNING: This requires a system clock that is in sync with the world.
|
static String |
generateCurrentNumber(String secret,
long currentTimeMillis)
Same as
getNumber(String) except at a particular time in milliseconds |
static String |
generateQRCode(String accountName,
String secret)
Return the QR image URL from Google Charts API.
|
static String |
getNumber(String secret)
Deprecated.
As of release 3.2.0, will be removed in 4.0.0
WARNING: This requires a system clock that is in sync with the world.
For more details of this magic algorithm, see:
http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm
|
static String |
getQRCode(String accountName,
String secret)
Deprecated.
As of release 3.2.0, replaced by
generateQRCode(String, String)
This can be shown to the user and scanned by the authenticator program as an easy way to enter the secret |
static boolean |
validateCurrentNumber(int number,
String secret)
Validate a given code using the secret, defaults to window of 3 either side,
allowing a margin of error equivalent to three windows to adjust for time
discrepancies.
|
static boolean |
validateCurrentNumber(int number,
String secret,
int window)
Validate a given code using the secret, provided number, and number of windows
to check.
|
static boolean |
validateCurrentNumber(int number,
String secret,
int window,
long time)
Validate a given code at a specific time, and specific window
|
static boolean |
validateNumber(int number,
String secret,
int window,
long time)
Deprecated.
As of release 3.2.0, replaced by
validateCurrentNumber(int, String, int, long) |
@Deprecated public static String generateBase32Secret()
@Deprecated public static String generateBase32Secret(int length)
length - how long the key should bepublic static boolean validateCurrentNumber(int number,
String secret)
number - code provided by usersecret - the secret for the users code@Deprecated public static boolean validateNumber(int number, String secret, int window, long time)
validateCurrentNumber(int, String, int, long)number - the code provided by the user.secret - the secret used to generate the users codewindow - the number of windows to check around the timetime - the time in milliseconds at which the code should be checkedpublic static boolean validateCurrentNumber(int number,
String secret,
int window,
long time)
number - the code provided by the user.secret - the secret used to generate the users codewindow - the number of windows to check around the timetime - the time in milliseconds at which the code should be checkedpublic static boolean validateCurrentNumber(int number,
String secret,
int window)
number - the code provided by the usersecret - the secret for the users codewindow - the number of windows to check around the time@Deprecated public static String getNumber(String secret)
secret - The secret to usepublic static String generateCurrentNumber(String secret)
secret - The secret to usepublic static String generateCurrentNumber(String secret, long currentTimeMillis)
getNumber(String) except at a particular time in millisecondssecret - The secret to usecurrentTimeMillis - A provided time in milli seconds@Deprecated public static String getQRCode(String accountName, String secret)
generateQRCode(String, String)
This can be shown to the user and scanned by the authenticator program as an easy way to enter the secretaccountName - The account name used to display to the usersecret - The secret to usepublic static String generateQRCode(String accountName, String secret)
accountName - The account name used to display to the usersecret - The secret to useCopyright © 2016. All rights reserved.