コード例 #1
0
        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);
        }
コード例 #2
0
        private void OnClickRegistration(object sender, EventArgs e)
        {
            string Tag = "OnClickRegistration";

            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 = GetRegServerPublicKeyCredentialCreationOptionsRequest();

            if (request == null)
            {
                return;
            }
            // Obtain the challenge value and related policy from the FIDO server, and initiate a Fido2RegistrationRequest
            // request.
            ServerPublicKeyCredentialCreationOptionsResponse response = fidoServer.GetAttestationOptions(request);

            if (!ServerStatus.Ok.Equals(response.GetStatus()))
            {
                log.Error(Tag, GetString(Resource.String.reg_fail) + response.GetErrorMessage());
            }
            PublicKeyCredentialCreationOptions publicKeyCredentialCreationOptions =
                ServerUtils.ConvertToPublicKeyCredentialCreationOptions(fido2Client, response);

            RegisterToFido2Client(publicKeyCredentialCreationOptions);
        }