Class OneTimePassword
java.lang.Object
com.unboundid.ldap.sdk.unboundidds.OneTimePassword
This class provides support for a number of one-time password algorithms.
Supported algorithms include:
NOTE: This class, and other classes within the
com.unboundid.ldap.sdk.unboundidds package structure, are only
supported for use against Ping Identity, UnboundID, and
Nokia/Alcatel-Lucent 8661 server products. These classes provide support
for proprietary functionality or for external specifications that are not
considered stable or mature enough to be guaranteed to work in an
interoperable way with other types of LDAP servers.
Supported algorithms include:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default number of digits to include in generated HOTP passwords.static final intThe default time interval (in seconds) to use when generating TOTP passwords.static final intThe default number of digits to include in generated TOTP passwords. -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringhotp(byte[] sharedSecret, long counter) Generates a six-digit HMAC-based one-time-password using the provided information.static Stringhotp(byte[] sharedSecret, long counter, int numDigits) Generates an HMAC-based one-time-password using the provided information.static Stringtotp(byte[] sharedSecret) Generates a six-digit time-based one-time-password using the provided information and a 30-second time interval.static Stringtotp(byte[] sharedSecret, long authTime, int intervalDurationSeconds, int numDigits) Generates a six-digit time-based one-time-password using the provided information.
-
Field Details
-
DEFAULT_HOTP_NUM_DIGITS
The default number of digits to include in generated HOTP passwords.- See Also:
-
DEFAULT_TOTP_INTERVAL_DURATION_SECONDS
The default time interval (in seconds) to use when generating TOTP passwords.- See Also:
-
DEFAULT_TOTP_NUM_DIGITS
The default number of digits to include in generated TOTP passwords.- See Also:
-
-
Method Details
-
hotp
Generates a six-digit HMAC-based one-time-password using the provided information.- Parameters:
sharedSecret- The secret key shared by both parties that will be using the generated one-time password.counter- The counter value that will be used in the course of generating the one-time password.- Returns:
- The zero-padded string representation of the resulting HMAC-based one-time password.
- Throws:
LDAPException- If an unexpected problem is encountered while attempting to generate the one-time password.
-
hotp
@NotNull public static String hotp(@NotNull byte[] sharedSecret, long counter, int numDigits) throws LDAPException Generates an HMAC-based one-time-password using the provided information.- Parameters:
sharedSecret- The secret key shared by both parties that will be using the generated one-time password.counter- The counter value that will be used in the course of generating the one-time password.numDigits- The number of digits that should be included in the generated one-time password. It must be greater than or equal to six and less than or equal to eight.- Returns:
- The zero-padded string representation of the resulting HMAC-based one-time password.
- Throws:
LDAPException- If an unexpected problem is encountered while attempting to generate the one-time password.
-
totp
Generates a six-digit time-based one-time-password using the provided information and a 30-second time interval.- Parameters:
sharedSecret- The secret key shared by both parties that will be using the generated one-time password.- Returns:
- The zero-padded string representation of the resulting time-based one-time password.
- Throws:
LDAPException- If an unexpected problem is encountered while attempting to generate the one-time password.
-
totp
@NotNull public static String totp(@NotNull byte[] sharedSecret, long authTime, int intervalDurationSeconds, int numDigits) throws LDAPException Generates a six-digit time-based one-time-password using the provided information.- Parameters:
sharedSecret- The secret key shared by both parties that will be using the generated one-time password.authTime- The time (in milliseconds since the epoch, as reported bySystem.currentTimeMillisorDate.getTime) at which the authentication attempt occurred.intervalDurationSeconds- The duration of the time interval, in seconds, that should be used when performing the computation.numDigits- The number of digits that should be included in the generated one-time password. It must be greater than or equal to six and less than or equal to eight.- Returns:
- The zero-padded string representation of the resulting time-based one-time password.
- Throws:
LDAPException- If an unexpected problem is encountered while attempting to generate the one-time password.
-