public async Task <UserConsentVerifierAvailability> GetUserConsentAvailabilityAsync() { UserConsentVerifierAvailability consentAvailability = await UserConsentVerifier.CheckAvailabilityAsync(); return(consentAvailability); }
/// <summary> /// Sets the initial value of <see cref="IdentityVerifiability"/>. /// </summary> /// <returns></returns> public override async Task ActivateAsync() { await this.initialConstruction; await base.ActivateAsync(); IdentityVerifiability = await this.identityService.CheckVerifierAvailabilityAsync(); }
/// <summary> /// This is the click handler for the 'Check Availability' button. It checks the availability of User consent requisition /// via registered fingerprints. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void CheckAvailability_Click(object sender, RoutedEventArgs e) { Button b = sender as Button; b.IsEnabled = false; try { // Check the availability of User Consent with fingerprints facility UserConsentVerifierAvailability consentAvailability = await UserConsentVerifier.CheckAvailabilityAsync(); switch (consentAvailability) { case UserConsentVerifierAvailability.Available: { rootPage.NotifyUser("User consent requisition facility is available.", NotifyType.StatusMessage); break; } case UserConsentVerifierAvailability.DeviceBusy: { rootPage.NotifyUser("Biometric device is busy.", NotifyType.ErrorMessage); break; } case UserConsentVerifierAvailability.DeviceNotPresent: { rootPage.NotifyUser("No biometric device found.", NotifyType.ErrorMessage); break; } case UserConsentVerifierAvailability.DisabledByPolicy: { rootPage.NotifyUser("Biometrics is disabled by policy.", NotifyType.ErrorMessage); break; } case UserConsentVerifierAvailability.NotConfiguredForUser: { rootPage.NotifyUser("User has no fingeprints registered.", NotifyType.ErrorMessage); break; } default: { rootPage.NotifyUser("Consent verification with fingerprints is currently unavailable.", NotifyType.ErrorMessage); break; } } } catch (Exception ex) { rootPage.NotifyUser("Checking the availability of Consent feature failed with exception. Operation: CheckAvailabilityAsync, Exception: " + ex.ToString(), NotifyType.ErrorMessage); } finally { b.IsEnabled = true; } }
/// <summary> /// Method which requests user authentication with Windows Hello if any athentication device /// is available. /// </summary> /// <returns>The authentication status</returns> internal async static Task <bool> Authenticate() { UserConsentVerifierAvailability userConsentVerifierAvailability = await UserConsentVerifier.CheckAvailabilityAsync(); switch (userConsentVerifierAvailability) { // TODO: Implement other UserConsentVerifierAvailability cases case UserConsentVerifierAvailability.Available: return(await UserConsentVerifier.RequestVerificationAsync("WindowsHelloMessage".GetLocalized()) == UserConsentVerificationResult.Verified); default: return(false); } }
// Add reference to Windows.winmd, typically c:\program files (x86)\windows kits\10\UnionMetadata\{version} // Add reference to System.Runtime.WindowsRuntime.dll, typically C:\Windows\Microsoft.NET\Framework\v4.0.30319 public async Task <bool> WindowsHelloSignInAsync() { // Check the availability of Windows Hello authentication through User Consent Verifier. UserConsentVerifierAvailability consentAvailability = await UserConsentVerifier.CheckAvailabilityAsync(); if (consentAvailability == UserConsentVerifierAvailability.Available) { // Request the user's consent using Windows Hello via biometric verification or a PIN. string message = "Please confirm your identity to login to this app"; UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync(message); switch (consentResult) { case UserConsentVerificationResult.Verified: System.Diagnostics.Debug.WriteLine("User verified"); return(true); } } return(false); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); try { UserConsentVerifierAvailability verifierAvailability = await UserConsentVerifier.CheckAvailabilityAsync(); switch (verifierAvailability) { case UserConsentVerifierAvailability.Available: // 验证器可用 lblMsg.Text = "UserConsentVerifierAvailability.Available"; break; case UserConsentVerifierAvailability.DeviceBusy: lblMsg.Text = "UserConsentVerifierAvailability.DeviceBusy"; break; case UserConsentVerifierAvailability.DeviceNotPresent: lblMsg.Text = "UserConsentVerifierAvailability.DeviceNotPresent"; break; case UserConsentVerifierAvailability.DisabledByPolicy: lblMsg.Text = "UserConsentVerifierAvailability.DisabledByPolicy"; break; case UserConsentVerifierAvailability.NotConfiguredForUser: lblMsg.Text = "UserConsentVerifierAvailability.NotConfiguredForUser"; break; default: break; } } catch (Exception ex) { lblMsg.Text = ex.ToString(); } lblMsg.Text += "\n"; }
public async Task <bool> CheckUserConsentAvailabilityAsync() { try { UserConsentVerifierAvailability consentAvailability = await UserConsentVerifier.CheckAvailabilityAsync(); if (consentAvailability == UserConsentVerifierAvailability.Available) { return(true); } else { return(false); } } catch { return(false); } }
/// <summary> /// This is the click handler for the 'Check Availability' button. It checks the availability of Windows Hello via User Consent Verifier /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void CheckAvailability_Click(object sender, RoutedEventArgs e) { Button b = sender as Button; b.IsEnabled = false; try { // Check the availability of Windows Hello authentication through User Consent Verifier. UserConsentVerifierAvailability consentAvailability = await Windows.Security.Credentials.UI.UserConsentVerifier.CheckAvailabilityAsync(); switch (consentAvailability) { case UserConsentVerifierAvailability.Available: { rootPage.NotifyUser("User consent verification available!", NotifyType.StatusMessage); break; } case UserConsentVerifierAvailability.DeviceNotPresent: { rootPage.NotifyUser("No PIN or biometric found, please set one up.", NotifyType.ErrorMessage); break; } default: { rootPage.NotifyUser("User consent verification is currently unavailable.", NotifyType.ErrorMessage); break; } } } catch (Exception ex) { rootPage.NotifyUser("Checking the availability of Consent feature failed with exception. Operation: CheckAvailabilityAsync, Exception: " + ex.ToString(), NotifyType.ErrorMessage); } finally { b.IsEnabled = true; } }
private async void CheckAvailability_Click(object sender, RoutedEventArgs e) { CheckAvailabilityButton.IsEnabled = false; // Check the availability of Windows Hello authentication through User Consent Verifier. UserConsentVerifierAvailability consentAvailability = await UserConsentVerifier.CheckAvailabilityAsync(); switch (consentAvailability) { case UserConsentVerifierAvailability.Available: rootPage.NotifyUser("User consent verification available!", NotifyType.StatusMessage); break; case UserConsentVerifierAvailability.DeviceNotPresent: rootPage.NotifyUser("No PIN or biometric found, please set one up.", NotifyType.ErrorMessage); break; default: rootPage.NotifyUser("User consent verification is currently unavailable.", NotifyType.ErrorMessage); break; } CheckAvailabilityButton.IsEnabled = true; }
/// <summary> /// Simple initialization constructor. /// </summary> /// <param name="skipInitialization">Whether to skip initializating a ViewModel altogether.</param> /// <param name="initDatabase">Whether to initialize the ViewModel's Candidate document file.</param> /// <param name="setPassword">Whether to set the ViewModel's Password.</param> /// <param name="setKeyFile">Whether to set the ViewModel's KeyFile.</param> /// <param name="initSample">Whether to initialize the ViewModel's sample flag.</param> /// <param name="storedCredentials">Whether to initialize the credential provider with /// the database-under-test.</param> /// <param name="identityVerifierAvailable">Whether to treat an identity verifier (e.g. Hello) /// as present and configured for the current user.</param> /// <param name="identityVerified">Whether to treat the user as verified.</param> /// <param name="inAppScope">Whether to treat databases as in scope w.r.t to cache proxies.</param> /// <param name="useRealProxyProvider">Whether a real file proxy provider should be used.</param> public TestDataAttribute( bool skipInitialization = false, bool initDatabase = true, bool setPassword = false, bool setKeyFile = false, bool initSample = false, bool storedCredentials = false, UserConsentVerifierAvailability identityVerifierAvailable = UserConsentVerifierAvailability.NotConfiguredForUser, bool identityVerified = false, bool inAppScope = false, bool useRealProxyProvider = false ) { SkipInitialization = skipInitialization; InitDatabase = initDatabase; SetPassword = setPassword; SetKeyFile = setKeyFile; InitSample = initSample; StoredCredentials = storedCredentials; IdentityVerifierAvailable = identityVerifierAvailable; IdentityVerified = identityVerified; InAppScope = inAppScope; UseRealProxyProvider = useRealProxyProvider; }
public IdentityVerifierAvailabilityEventArgs(UserConsentVerifierAvailability availability) { this.availability = availability; }