Interface OtpSource

All Known Implementing Classes:
MGL_OtpProvider

public interface OtpSource
Abstraction for collection of OTP tokens.
Author:
cemp@google.com (Cem Paya)
  • Method Details

    • enumerateAccounts

      int enumerateAccounts(Collection<String> result)
      Enumerate list of accounts that this OTP token supports.
      Parameters:
      result - Collection to append usernames. This object is NOT cleared on entry; if there are existing items, they will not be removed.
      Returns:
      Number of accounts added to the collection.
    • getNextCode

      String getNextCode(String accountName, String key) throws OtpSourceException
      Return the next OTP code for specified username. Invoking this function may change internal state of the OTP generator, for example advancing the counter.
      Parameters:
      accountName - Username, email address or other unique identifier for the account.
      Returns:
      OTP as string code.
      Throws:
      OtpSourceException
    • respondToChallenge

      String respondToChallenge(String accountName, String key, String challenge) throws OtpSourceException
      Generate response to a given challenge based on next OTP code. Subclasses are not required to implement this method.
      Parameters:
      accountName - Username, email address or other unique identifier for the account.
      challenge - Server specified challenge as UTF8 string.
      Returns:
      Response to the challenge.
      Throws:
      UnsupportedOperationException - if the token does not support challenge-response extension for this account.
      OtpSourceException
    • getTotpCounter

      TotpCounter getTotpCounter()
      Gets the counter for generating or verifying TOTP codes.