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 StringHMAC_SHA1static StringHMAC_SHA256static StringHMAC_SHA512
-
Constructor Summary
Constructors Constructor Description TimeBasedOTP()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgenerateTOTP(String key, int returnDigits)Generate a TOTP value using HMAC_SHA1static StringgenerateTOTP(String key, String time, int returnDigits)This method generates an TOTP value for the given set of parameters.static StringgenerateTOTP(String key, String time, int returnDigits, String crypto)This method generates an TOTP value for the given set of parameters.static StringgenerateTOTP256(String key, int returnDigits)Generate a TOTP value using HMAC_SHA256static StringgenerateTOTP256(String key, String time, int returnDigits)This method generates an TOTP value for the given set of parameters.static StringgenerateTOTP512(String key, int returnDigits)Generate a TOTP value using HMAC_SHA512static StringgenerateTOTP512(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
truncationDigitsdigits - 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
truncationDigitsdigits - 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
truncationDigitsdigits - 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
truncationDigitsdigits - Throws:
GeneralSecurityException
-
-