Package org.jboss.security.otp
Class TimeBasedOTP
- java.lang.Object
-
- org.jboss.security.otp.TimeBasedOTP
-
public class TimeBasedOTP extends Object
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@redhat.com
-
-
Field Summary
Fields Modifier and Type Field Description static String
HMAC_SHA1
static String
HMAC_SHA256
static String
HMAC_SHA512
-
Constructor Summary
Constructors Constructor Description TimeBasedOTP()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
generateTOTP(String key, int returnDigits)
Generate a TOTP value using HMAC_SHA1static String
generateTOTP(String key, String time, int returnDigits)
This method generates an TOTP value for the given set of parameters.static String
generateTOTP(String key, String time, int returnDigits, String crypto)
This method generates an TOTP value for the given set of parameters.static String
generateTOTP256(String key, int returnDigits)
Generate a TOTP value using HMAC_SHA256static String
generateTOTP256(String key, String time, int returnDigits)
This method generates an TOTP value for the given set of parameters.static String
generateTOTP512(String key, int returnDigits)
Generate a TOTP value using HMAC_SHA512static String
generateTOTP512(String key, String time, int returnDigits)
This method generates an TOTP value for the given set of parameters.
-
-
-
Field Detail
-
HMAC_SHA1
public static final String HMAC_SHA1
- See Also:
- Constant Field Values
-
HMAC_SHA256
public static final String HMAC_SHA256
- See Also:
- Constant Field Values
-
HMAC_SHA512
public static final String HMAC_SHA512
- See Also:
- Constant Field Values
-
-
Method Detail
-
generateTOTP
public static String generateTOTP(String key, int returnDigits) throws GeneralSecurityException
Generate a TOTP value using HMAC_SHA1- Parameters:
key
-returnDigits
-- Returns:
- Throws:
GeneralSecurityException
-
generateTOTP256
public static String generateTOTP256(String key, int returnDigits) throws GeneralSecurityException
Generate a TOTP value using HMAC_SHA256- Parameters:
key
-returnDigits
-- Returns:
- Throws:
GeneralSecurityException
-
generateTOTP512
public static String generateTOTP512(String key, int returnDigits) throws GeneralSecurityException
Generate a TOTP value using HMAC_SHA512- Parameters:
key
-returnDigits
-- Returns:
- Throws:
GeneralSecurityException
-
generateTOTP
public static String generateTOTP(String key, String time, int returnDigits) throws GeneralSecurityException
This method generates an TOTP value for the given set of parameters.- Parameters:
key
- the shared secret, HEX encodedtime
- a value that reflects a timereturnDigits
- number of digits to return- Returns:
- A numeric String in base 10 that includes
truncationDigits
digits - Throws:
GeneralSecurityException
-
generateTOTP256
public static String generateTOTP256(String key, String time, int returnDigits) throws GeneralSecurityException
This method generates an TOTP value for the given set of parameters.- Parameters:
key
- the shared secret, HEX encodedtime
- a value that reflects a timereturnDigits
- number of digits to return- Returns:
- A numeric String in base 10 that includes
truncationDigits
digits - Throws:
GeneralSecurityException
-
generateTOTP512
public static String generateTOTP512(String key, String time, int returnDigits) throws GeneralSecurityException
This method generates an TOTP value for the given set of parameters.- Parameters:
key
- the shared secret, HEX encodedtime
- a value that reflects a timereturnDigits
- number of digits to return- Returns:
- A numeric String in base 10 that includes
truncationDigits
digits - Throws:
GeneralSecurityException
-
generateTOTP
public static String generateTOTP(String key, String time, int returnDigits, String crypto) throws GeneralSecurityException
This method generates an TOTP value for the given set of parameters.- Parameters:
key
- the shared secret, HEX encodedtime
- a value that reflects a timereturnDigits
- number of digits to returncrypto
- the crypto function to use- Returns:
- A numeric String in base 10 that includes
truncationDigits
digits - Throws:
GeneralSecurityException
-
-