public IYubicoResponse Verify(string onetimePassword)
        {
            var client = new YubicoClient(this.ClientId);

            client.SetApiKey(this.ApiKey);
            client.SetSync(this.SyncLevel);
            return(client.Verify(onetimePassword));
        }
Beispiel #2
0
        private async void Submit(object sender, EventArgs e)
        {
            var otp      = OtpInput.Text;
            var clientId = ClientIdInput.Text;
            var apiKey   = ApiKeyInput.Text;
            var sync     = SyncInput.Text;
            var nonce    = NonceInput.Text;

            OutputField.Clear();

            var client = new YubicoClient(clientId);

            if (!string.IsNullOrEmpty(apiKey))
            {
                client.SetApiKey(apiKey);
            }
            if (!string.IsNullOrEmpty(sync))
            {
                client.SetSync(sync);
            }
            if (!string.IsNullOrEmpty(nonce))
            {
                client.SetNonce(nonce);
            }
            try
            {
                var sw       = Stopwatch.StartNew();
                var response = await client.VerifyAsync(otp);

                sw.Stop();
                if (response != null)
                {
                    OutputField.AppendText(string.Format("response in: {0}{1}", sw.ElapsedMilliseconds, Environment.NewLine));
                    OutputField.AppendText(string.Format("Status: {0}{1}", response.Status, Environment.NewLine));
                    OutputField.AppendText(string.Format("Public ID: {0}{1}", response.PublicId, Environment.NewLine));
                    OutputField.AppendText(string.Format("Use/Session Counter: {0} {1}{2}", response.UseCounter, response.SessionCounter, Environment.NewLine));
                    OutputField.AppendText(string.Format("Url: {0}", response.Url));
                }
                else
                {
                    OutputField.Text = "Null result returned, error in call";
                }
            }
            catch (YubicoValidationFailure yvf)
            {
                OutputField.Text = string.Format("Failure in validation: {0}{1}", yvf.Message, Environment.NewLine);
            }
        }