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 |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public class DemoSignInActivity extends Activity implements SurePassIdU2fSign.Listener { private SurePassIdU2fSign mU2fSign; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initUiresult){ switch (result) { case SUCCESS: gotoTargetActivity(); break; case CANCELED: fidoClientCanceled(); break; case ALTERNATE_VERIFICATION: gotoAlternateVerificationActivity(); mU2fSign = new SurePassIdU2fSign(this, this); break; } } void afterLoginSuccess(String username) { mU2fSign.u2fSign("https://u2f.server.com/example", username); } /** * Called if there was an error during the U2F Sign Operation. * * @param errorMessage The error that occurred. */ @Override public void onActivityResultfidoClientError(intCharSequence requestCode,errorMessage) int{ resultCode, Intent intent) { // Handle the error mU2fSign.onActivityResult(requestCode, resultCode, intentmessage. displayMessage(errorMessage); } /** * 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); intent.putExtra(EXTRA_USERNAME, mUsername); intent.putExtra(EXTRA_SESSION_TOKEN, mSessionToken); startActivity(intent); } /** * Method used to go to an activity that provides the @Overrideuser the ability * to use a different second factor method if they are unable to use * a U2F Authenticator. */ public void gotoAlternateVerificationActivity() { Intent intent = new Intent(this, DemoEnterOtpActivity.class); startActivity(intent); } @Override/** public void* u2fSignCanceled()Called {if the U2F Sign operation resetFormValues();was canceled by the user. enableForm(); */ displayMessage("Sign In canceled."); }public void fidoClientCanceled() { resetFormValues(); @Override public void u2fSignError(CharSequence errorMessage) {enableForm(); displayMessage(errorMessage);"Sign enableForm(In canceled."); } } |
Upon successfully authenticating the user it should call
...
That method will perform all the necessary U2F operations.