Explain that first factor and other forms of second factor authentication is up to the developer as to how they want to implement it.
SurePassIdU2fSign
The Sign In Activity must extend SurePassIdU2fSignActivity. It must implement the following abstract methods.
...
Below is the code related to processing a FIDO U2F sign operation.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
import com.surepassid.fido.u2f.FidoClientListener; import com.surepassid.fido.u2f.SurePassIdU2f; public class DemoSignInActivity extends Activity implements FidoClientListener { public static final String SERVER_URL = "https://fidocert.surepassid.com/server.aspx"; private SurePassIdU2f mU2f; private String mSessionToken; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initUi(); mU2f = new SurePassIdU2f(this, this); } void afterSignInSuccess(String username) { // After the user has successfully signed in start the U2F Sign process. mU2f.sign(SERVER_URL, sessionToken); } @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { switch (requestCode) { case U2fClientIntent.REQUEST_CODE_SIGN: // 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: gotoTargetActivity(); break; case CANCELED: fidoClientCanceled(); break; case ALTERNATE_VERIFICATION: gotoAlternateVerificationActivity(); break; } } /** * Called if there was an error during the U2F Sign Operation. |
...
* |
...
* @param errorMessage The error that occurred. |
...
*/ |
...
@Override public void |
...
fidoClientError(CharSequence errorMessage) |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public class DemoSignInActivity extends Activity implements SurePassIdU2fSign.Listener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initUi(); mU2fSign = new SurePassIdU2fSign(this, this); } @Override { // Handle the error message. displayMessage(errorMessage); } /** * Method used to go to the app's target activity after U2F Sign succeeds. */ public void gotoTargetActivity() { Intent intent = new Intent(this, DemoAppActivity.class); intent.putExtra(EXTRA_USERNAME, mUsername); intent.putExtra(EXTRA_SESSION_TOKEN, mSessionToken); 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 @Override* a U2F Authenticator. */ public void gotoAlternateVerificationActivity() { Intent intent = new Intent(this, DemoEnterOtpActivity.class); startActivity(intent); } @Override public void u2fSignCanceled() {/** * Called if resetFormValues();the U2F Sign operation was enableForm();canceled by the user. displayMessage("Sign In canceled."); } */ @Override public void u2fSignErrorfidoClientCanceled(CharSequence errorMessage) { displayMessageresetFormValues(errorMessage); enableForm(); displayMessage("Sign In canceled."); } } |
Upon successfully authenticating the user it should call
...
That method will perform all the necessary U2F operations.