Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleSurePassIdU2fSign
linenumberstrue
public class DemoSignInActivity extends Activity implements SurePassIdU2fSign.Listener {

  private SurePassIdU2fSign mU2fSign;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initUi();
    mU2fSign = new SurePassIdU2fSign(this, this);
  }

  void afterLoginSuccessafterSignInSuccess(String username) {
    // AvterAfter the user has successfully signed in start the U2F Sign process.
    mU2fSign.u2fSign("https://u2f.server.com/example", username);
  }

  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    // Call onActivityResult for mU2fSign.
    mU2fSign.onActivityResult(requestCode, resultCode, intent);
  }

  /**
   * Method used to go to the app's target activity after U2F Sign succeeds.
   */
  @Override
  public void gotoTargetActivity() {
    Intent intent = new Intent(this, DemoAppActivity.class);
    startActivity(intent);
  }

  /**
   * Method used to go to an activity that provides the user the ability
   * to use a different second factor method if they are unable to use
   * a U2F Authenticator.
   */
  @Override
  public void gotoAlternateVerificationActivity() {
    Intent intent = new Intent(this, DemoEnterOtpActivity.class);
    startActivity(intent);
  }

  /**
   * Called if the U2F Sign operation was canceled by the user.
   */
  @Override
  public void u2fSignCanceled() {
    resetFormValues();
    enableForm();
    displayMessage("Sign In canceled.");
  }

  /**
   * Called if there was an error during the U2F Sign Operation.
   *
   * @param errorMessage The error that occurred.
   */
  @Override
  public void u2fSignError(CharSequence errorMessage) {
    displayMessage(errorMessage);
    enableForm();
  }
}

...