コード例 #1
0
        /// <summary>
        /// Authenticate user using provided credential.
        /// </summary>
        /// <param name="userName">User identity which needs to be authenticated.</param>
        /// <param name="credential">Credential to be used for authentication.</param>
        /// <returns>Autenticated <see cref="Ticket"/>.</returns>
        public async Task <Ticket> Authenticate(UserName userName, IAuthenticationCredential credential)
        {
            if (userName == null)
            {
                throw new ArgumentNullException("userName");
            }

            if (credential == null)
            {
                throw new ArgumentNullException("credential");
            }

            try
            {
                var urlRequest = HttpHelper.CreateHttpRequest(GetRequestUri("/AuthenticateUser"),
                                                              RequestMethod.Post);

                await urlRequest.WritePostParameters("credential", credential, "user", userName);

                return(await urlRequest.GetResponseData <Ticket>("AuthenticateUserResult"));
            }
            catch (WebException ex)
            {
                throw GetServiceException(ex);
            }
        }
コード例 #2
0
        private void CardOkButton_Click(object sender, RoutedEventArgs e)
        {
            var card = CardsListBox.SelectedItem as Tuple <string, Card>;

            if (card == null)
            {
                return;
            }

            credential   = Credential.Create(new CardAuthenticationData(card.Item2.Id));
            DialogResult = true;
        }
コード例 #3
0
        private void FingerprintOkButton_Click(object sender, RoutedEventArgs e)
        {
            if (fingerprintImage == null)
            {
                return;
            }

            using (var ffe = new FingerprintFeatureExtractor())
            {
                ffe.Initialize();
                var featuries = ffe.Extract(fingerprintImage, ExtractionType.FeatureSetForAuthentication);

                var fpFeatures = new BiometricSample(featuries, BiometricSampleHeaderType.DigitalPersonaFingerprintFeatureSet);

                credential = Credential.Create(new FingerprintAuthenticationData(fpFeatures));
            }

            DialogResult = true;
            Close();
        }
コード例 #4
0
        /// <summary>
        /// Identify user using specific credential.
        /// </summary>
        /// <remarks>
        /// IdentifyUser method allows identify user based on provided credential.
        /// NOTE: Not all credentials support identification for example fingerprints support identification but password not.
        /// </remarks>
        /// <param name="credential">Credential to identification.</param>
        /// <returns>JSON ticket <see cref="Ticket"/>.</returns>
        public async Task <Ticket> Identify(IAuthenticationCredential credential)
        {
            if (credential == null)
            {
                throw new ArgumentNullException("credential");
            }

            try
            {
                var urlRequest = HttpHelper.CreateHttpRequest(GetRequestUri("/IdentifyUser"), RequestMethod.Post);

                await urlRequest.WritePostParameters("credential", credential);

                var ticket = await urlRequest.GetResponseData <Ticket>("IdentifyUserResult");

                return(ticket);
            }
            catch (WebException ex)
            {
                throw GetServiceException(ex);
            }
        }
コード例 #5
0
 private void PasswordOkButton_Click(object sender, RoutedEventArgs e)
 {
     credential   = Credential.Create(new PasswordAuthenticationData(PasswordPasswordTextBox.Password));
     DialogResult = true;
 }
コード例 #6
0
 private void OtpOkButton_Click(object sender, RoutedEventArgs e)
 {
     credential   = Credential.Create(new OtpAuthenticationData(OtpTextBox.Text));
     DialogResult = true;
 }
コード例 #7
0
 private void LiveQuestionOkButton_Click(object sender, RoutedEventArgs e)
 {
     credential   = Credential.Create(new LiveQuestionAuthenticationData(LiveQuestion.Select(p => p.Item2)));
     DialogResult = true;
 }