private void AuthenticateToFido2Client(PublicKeyCredentialRequestOptions publicKeyCredentialCreationOptions) { NativeFido2AuthenticationOptions authenticationOptions = NativeFido2AuthenticationOptions.DefaultOptions; Fido2AuthenticationRequest authenticationRequest = new Fido2AuthenticationRequest(publicKeyCredentialCreationOptions, null); // Call IFido2Client.GetAuthenticationIntent to obtain a Fido2Intent instance and start the FIDO client // authentication process. fido2Client.GetAuthenticationIntent(authenticationRequest, authenticationOptions, new Fido2IntentCallback( (fido2Intent) => { // Start the FIDO client authentication process through Fido2ClientCommon.AuthenticationRequest. fido2Intent.LaunchFido2Activity(this, Fido2ClientCommon.AuthenticationRequest); }, (errorCode, errString) => { log.Error(Tag, GetString(Resource.String.authn_fail) + errorCode + "=" + errString); } )); }
private void OnClickAuthentication(object sender, EventArgs e) { string Tag = "OnClickAuthentication"; if (!fido2Client.IsSupported) { log.Info(Tag, "FIDO2 is not supported."); return; } IFidoServer fidoServer = new FidoServerSimulator(); if (fidoServer == null) { log.Error(Tag, GetString(Resource.String.connect_server_err)); return; } ServerPublicKeyCredentialCreationOptionsRequest request = GetAuthnServerPublicKeyCredentialCreationOptionsRequest(); if (request == null) { return; } // Obtain the challenge value and related policy from the FIDO server, and initiate a Fido2AuthenticationRequest // request. ServerPublicKeyCredentialCreationOptionsResponse response = fidoServer.GetAssertionOptions(request); if (!ServerStatus.Ok.Equals(response.GetStatus())) { log.Error(Tag, GetString(Resource.String.authn_fail) + response.GetErrorMessage()); return; } string attachmentMode = GetSpinnerSelect(attachmentSp.SelectedItem); bool isUseSelectedPlatformAuthenticator = Attachment.Platform.Value.Equals(attachmentMode); PublicKeyCredentialRequestOptions publicKeyCredentialCreationOptions = ServerUtils.ConvertToPublicKeyCredentialRequestOptions(fido2Client, response, isUseSelectedPlatformAuthenticator); AuthenticateToFido2Client(publicKeyCredentialCreationOptions); }