Versions Compared

Key

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

Table of Contents

General

Requirements

Minimum SDK Version: Android 4.3 4 - 4.3.1 Jelly Bean 4.4 KitKat (API level 1819)

Supported U2F Authenticator Transports

  • NFC (requires 
  • USB HID
  • Bluetooth Low Energy (A.K.A. BLE, Bluetooth Smart) Coming Soon!
  • Virtual (included in client)

...

 

SurePassID FIDO U2F Client App

This app is the U2F Client. It is only run directly to update the settings. Otherwise it is call via an Implicit Intent from an app needing a U2F Client.

surePassIdFidoU2fClient-general-debug-1.0.6.apk

SurePassID U2F Demo App

This app demonstrates how to call the SurePassID U2F Server and U2F client.

surePassIdFidoU2fAppDemo-general-debug-1.0.6.apkExample U2F Sign (authenticate) code.

/**
* Verifies the user's credentials and performs U2F authentication.
*/
public class SignInActivity
extends Activity
implements SurePassIdU2fSign.Listener {
public static final String U2F_SERVER_URL = "https://fidocert.surepassid.com/server.aspx";

///////////////////////
// working variables //
///////////////////////
 private SurePassIdU2fSign mU2fSign;

private VerifyUsernamePasswordTask mVerifyUsernamePasswordTask = null;

///////////////////
// UI references //
///////////////////
 private EditText mUsernameView;
private EditText mPasswordView;
private TextView mStatusMessageView;
private Button mSignInButton;

/**
* Initiate U2F Sign.
*/
 private void doU2f() {
mU2fSign.u2fSign(U2F_SERVER_URL, mUsernameView.getText().toString());
}

/**
* The U2F Sign was successful. Now go to the desired activity.
*/
 @Override
  public void gotoTargetActivity() {
Intent intent = new Intent(this, DemoAppActivity.class);
startActivity(intent);
}

/**
* The user is requesting to use an alternate method for second factor authentication.
* This alternate method is up to the relying party app.
*/
 @Override
 public void gotoAlternateVerificationActivity() {
Intent intent = new Intent(this, DemoCodeActivity.class);
startActivity(intent);
}

/**
* The user aborted the sign in.
*/
 @Override
 public void u2fSignCanceled() {
resetFormValues();
enableForm();
displayMessage("Sign In canceled.");
}

/**
* An error occurred during processing.
*
* @param errorMessage The error that occurred.
*/
 @Override
 public void u2fSignError(CharSequence errorMessage) {
displayMessage(errorMessage);
enableForm();
}

@Override
 protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

initUi();

// Create the U2F Sign object to be used.
 mU2fSign = new SurePassIdU2fSign(this, this);
}

/**
* Call the U2F Sign's onActivityResult method.
* @param requestCode
 * @param resultCode
 * @param intent
 */
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
mU2fSign.onActivityResult(requestCode, resultCode, intent);
}

/**
* Initialize the user interface.
*/
 private void initUi() {
mStatusMessageView = (TextView) findViewById(R.id.status_message);
mUsernameView = (EditText) findViewById(R.id.username);
mPasswordView = (EditText) findViewById(R.id.password);

mSignInButton = (Button) findViewById(R.id.button_sign_in);
mSignInButton.setOnClickListener(new View.OnClickListener() {
@Override
 public void onClick(View view) {
doSignIn();
}
});
}

/**
* Called when the Sign In button is pressed.
*/
 private void doSignIn() {
disableForm();

String username = mUsernameView.getText().toString();
String password = mPasswordView.getText().toString();

// Verify username an password on server.
  displayMessage(R.string.signin_status_signing_in);
mVerifyUsernamePasswordTask = new VerifyUsernamePasswordTask(new AsyncTaskListener() {
@Override
 public void onAsyncTaskFail(String errorMessage) {
mPasswordView.requestFocus();
mPasswordView.selectAll();
enableForm();
displayMessage(errorMessage);
}

/**
* Called when the username and password have successfully validated.
* It then calls U2F Sign.
*/
 @Override
 public void onAsyncTaskSuccess() {
Log.v(TAG, "onAsyncTaskSuccess([]): START");
doU2f();
}
});
mVerifyUsernamePasswordTask.execute(username, password);
}

protected void displayMessage(int messageId) {
mStatusMessageView.setText(messageId);
}

protected void displayMessage(CharSequence message) {
mStatusMessageView.setText(message);
}

protected void resetFormValues() {
mUsernameView.requestFocus();
mUsernameView.setText("");
mPasswordView.setText("");
mStatusMessageView.setText("");
}

private void disableForm() {
mUsernameView.setEnabled(false);
mPasswordView.setEnabled(false);
mSignInButton.setVisibility(GONE);
}

protected void enableForm() {
mUsernameView.setEnabled(true);
mPasswordView.setEnabled(true);
mSignInButton.setVisibility(VISIBLE);
}
}