public interface TotpSecret

Represents a TOTP secret that is used for enrolling a TOTP second factor. Contains the shared secret key and other parameters to generate time-based one-time passwords. Implements methods to retrieve the shared secret key, generate a QR code URL, and open the QR code URL in an OTP authenticator app.

Public Method Summary

abstract String
generateQrCodeUrl(String accountName, String issuer)
Returns a QR code URL.
abstract String
generateQrCodeUrl()
Returns a QR code URL.
abstract int
getCodeIntervalSeconds()
Returns the interval (in seconds) when the OTP codes should change.
abstract int
getCodeLength()
Returns the length of the OTP codes to be generated.
abstract long
getEnrollmentCompletionDeadline()
Returns the timestamp (in seconds since epoch) by which enrollment should complete.
abstract String
getHashAlgorithm()
Returns the hashing algorithm used to generate time-based one-time passwords.
abstract String
getSessionInfo()
Returns the enrollment session.
abstract String
getSharedSecretKey()
Returns the shared secret key/seed used to generate time-based one-time passwords.
abstract void
openInOtpApp(String qrCodeUrl)
Opens the specified QR Code URL in an OTP authenticator app on the device as a new Activity.
abstract void
openInOtpApp(String qrCodeUrl, String fallbackUrl, Activity activity)
Opens the specified QR Code URL in an OTP app on the device.

Public Methods

public abstract String generateQrCodeUrl (String accountName, String issuer)

Returns a QR code URL. For more details, see Key-Uri-Format. You can display this URL to the end-user as a QR code to be scanned into an OTP authenticator app, like Google Authenticator. Alternatively, you can automatically load this URL into a TOTP authenticator app using openInOtpApp(String).

Parameters
accountName the name of the account/app along with a user identifier..
issuer issuer of the TOTP (the app name).
Returns
  • A QR code URL String.

public abstract String generateQrCodeUrl ()

Returns a QR code URL. For more details, see Key-Uri-Format. You can display this URL to the end-user as a QR code to be scanned into an OTP authenticator app, like Google Authenticator. Alternatively, you can automatically load this URL into a TOTP authenticator app using openInOtpApp(String).

Returns
  • A QR code URL String.

public abstract int getCodeIntervalSeconds ()

Returns the interval (in seconds) when the OTP codes should change.

Returns
  • The interval (in seconds) when the OTP codes should change.

public abstract int getCodeLength ()

Returns the length of the OTP codes to be generated.

Returns
  • Length of the one-time passwords to be generated.

public abstract long getEnrollmentCompletionDeadline ()

Returns the timestamp (in seconds since epoch) by which enrollment should complete.

Returns
  • The timestamp (in seconds since epoch) by which enrollment should complete.

public abstract String getHashAlgorithm ()

Returns the hashing algorithm used to generate time-based one-time passwords.

Returns
  • Hashing algorithm used.

public abstract String getSessionInfo ()

Returns the enrollment session.

public abstract String getSharedSecretKey ()

Returns the shared secret key/seed used to generate time-based one-time passwords.

Returns
  • Shared secret key for enrolling in TOTP MFA.

public abstract void openInOtpApp (String qrCodeUrl)

Opens the specified QR Code URL in an OTP authenticator app on the device as a new Activity. The shared secret key and account name will be populated in the OTP authenticator app. The URL uses the otpauth:// scheme and will be opened on an app that handles this scheme, if it exists on the device.

If a suitable OTP authenticator app was not found, this opens the Google Play Store instead, using the following URL: //play.google.com/store/search?q=otpauth&c=apps.

Parameters
qrCodeUrl the QR Code URL to open.

public abstract void openInOtpApp (String qrCodeUrl, String fallbackUrl, Activity activity)

Opens the specified QR Code URL in an OTP app on the device. The shared secret key and account name will be populated in the OTP app. The URL uses the otpauth:// scheme and will be opened on an app that handles this scheme, if it exists on the device.

Parameters
qrCodeUrl the QR Code URL to open.
fallbackUrl the URL to open if a suitable OTP authenticator app was not found.
activity a reference to the current activity, to open the OTP authenticator app on.