Package io.gravitee.am.factor.otp.utils
Class TOTP
java.lang.Object
io.gravitee.am.factor.otp.utils.TOTP
This is an example implementation of the OATH
TOTP algorithm.
Visit www.openauthentication.org for more information.
See Appendix A. TOTP Algorithm: Reference Implementation
- Author:
- Johan Rydell, PortWise, Inc., Titouan COMPIEGNE (titouan.compiegne at graviteesource.com), GraviteeSource Team
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgenerateTOTP(String key, long time) This method generates a TOTP value for the given set of parameters.static StringgenerateTOTP(String key, String time, String returnDigits) This method generates a TOTP value for the given set of parameters.static StringgenerateTOTP(String key, String time, String returnDigits, String crypto) This method generates a TOTP value for the given set of parameters.static StringgenerateTOTP256(String key, String time, String returnDigits) This method generates a TOTP value for the given set of parameters.static StringgenerateTOTP512(String key, String time, String returnDigits) This method generates a TOTP value for the given set of parameters.
-
Field Details
-
RETURN_DIGITS
- See Also:
-
TIME_STEP
public static final int TIME_STEP- See Also:
-
-
Method Details
-
generateTOTP
This method generates a TOTP value for the given set of parameters.- Parameters:
key- : the shared secret, HEX encoded
-
generateTOTP
This method generates a 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
-
generateTOTP256
This method generates a 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 digits
-
generateTOTP512
This method generates a 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
-
generateTOTP
This method generates a 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
-