FIDO U2F Enroll Operation - Android Example
 Below is the code related to processing a FIDO U2F enroll operation.
SurePassIdU2fSign
import com.surepassid.fido.u2f.FidoClientListener; import com.surepassid.fido.u2f.SurePassIdU2f; public class DemoEnrollActivity extends Activity implements FidoClientListener { public static final String SERVER_URL = "https://fidocert.surepassid.com/server.aspx"; /** * Username of the user that is currently signed in. */ private String mUsername = null; /** * Session token for the user's current login. */ private String mSessionToken = null; private SurePassIdU2f mU2f; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initUi(); mUsername = getIntent().getExtras().getString(EXTRA_USERNAME); mSessionToken = getIntent().getExtras().getString(EXTRA_SESSION_TOKEN); } /** * The securityKeyName is optional and can be null. * A default name will be assigned by the server. */ void enrollToken(String securityKeyName) { if (mU2f == null) { mU2f = new SurePassIdU2f(this, this); } mU2f.enroll(SignInActivity.SERVER_URL, mSessionToken, securityKeyName); } @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { switch (requestCode) { case U2fClientIntent.REQUEST_CODE_REGISTER: // Forward the result to SurePassIdU2f.onActivityResult mU2f.onActivityResult(requestCode, resultCode, intent); break; } } /** * Called if there not any errors processing the FIDO request. The * result indicates thte status of the request. */ @Override public void fidoClientResult(Result result){ switch (result) { case SUCCESS: handleSuccessfulEnroll(); break; case CANCELED: handleClientCanceled(); break; } } /** * Called if there was an error during the U2F Sign Operation. * * @param errorMessage The error that occurred. */ @Override public void fidoClientError(CharSequence errorMessage) { // Handle the error message. displayMessage(errorMessage); } }