UserConsentVerifier 클래스

정의

확인 디바이스(예: Microsoft Passport PIN, Windows Hello 생체 인식 또는 지문 판독기)의 가용성을 확인하고 확인을 수행합니다.

public ref class UserConsentVerifier abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class UserConsentVerifier final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public static class UserConsentVerifier
Public Class UserConsentVerifier
상속
Object Platform::Object IInspectable UserConsentVerifier
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

C를 사용하는 데스크톱 앱#

데스크톱 앱의 경우 UserConsentVerifier.RequestVerificationAsync 메서드를 호출하는 대신 다음을 수행해야 합니다.

private async System.Threading.Tasks.Task<string> RequestConsent(string userMessage)
{
    string returnMessage;

    if (String.IsNullOrEmpty(userMessage))
    {
        userMessage = "Please provide fingerprint verification.";
    }

    try
    {
        // Retrieve the window handle by passing a reference to the WinUI 3 window object 
        var hwnd = ...
        // Request the logged on user's consent via fingerprint swipe using the interop interface
        var consentResult = await Windows.Security.Credentials.UI.UserConsentVerifierInterop.RequestVerificationForWindowAsync(hwnd, userMessage);

        switch (consentResult)
        {
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.Verified:
                returnMessage = "Fingerprint verified.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.DeviceBusy:
                returnMessage = "Biometric device is busy.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.DeviceNotPresent:
                returnMessage = "No biometric device found.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.DisabledByPolicy:
                returnMessage = "Biometric verification is disabled by policy.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.NotConfiguredForUser:
                returnMessage = "The user has no fingerprints registered. Please add a fingerprint to the " +
                                "fingerprint database and try again.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.RetriesExhausted:
                returnMessage = "There have been too many failed attempts. Fingerprint authentication canceled.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.Canceled:
                returnMessage = "Fingerprint authentication canceled.";
                break;
            default:
                returnMessage = "Fingerprint authentication is currently unavailable.";
                break;
        }
    }
    catch (Exception ex)
    {
        returnMessage = "Fingerprint authentication failed: " + ex.ToString();
    }

    return returnMessage;
}

C를 사용하는 UWP(유니버설 Windows 플랫폼) 앱#

이 코드 예제는 UWP(유니버설 Windows 플랫폼) 앱용입니다. 지문 확인 요청을 표시한 다음 결과를 설명하는 메시지를 반환합니다. 이 코드는 UWP 앱에 적합한 UserConsentVerifier.RequestVerificationAsync 메서드를 호출합니다.

private async System.Threading.Tasks.Task<string> RequestConsent(string userMessage)
{
    string returnMessage;

    if (String.IsNullOrEmpty(userMessage))
    {
        userMessage = "Please provide fingerprint verification.";
    }

    try
    {
        // Request the logged on user's consent via fingerprint swipe.
        var consentResult = await Windows.Security.Credentials.UI.UserConsentVerifier.RequestVerificationAsync(userMessage);

        switch (consentResult)
        {
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.Verified:
                returnMessage = "Fingerprint verified.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.DeviceBusy:
                returnMessage = "Biometric device is busy.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.DeviceNotPresent:
                returnMessage = "No biometric device found.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.DisabledByPolicy:
                returnMessage = "Biometric verification is disabled by policy.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.NotConfiguredForUser:
                returnMessage = "The user has no fingerprints registered. Please add a fingerprint to the " +
                                "fingerprint database and try again.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.RetriesExhausted:
                returnMessage = "There have been too many failed attempts. Fingerprint authentication canceled.";
                break;
            case Windows.Security.Credentials.UI.UserConsentVerificationResult.Canceled:
                returnMessage = "Fingerprint authentication canceled.";
                break;
            default:
                returnMessage = "Fingerprint authentication is currently unavailable.";
                break;
        }
    }
    catch (Exception ex)
    {
        returnMessage = "Fingerprint authentication failed: " + ex.ToString();
    }

    return returnMessage;
}

설명

UserConsentVerifier를 사용하여 사용자가 특정 작업에 동의해야 할 때마다 확인 요청을 포함하여 앱의 보안을 강화할 수 있습니다. 예를 들어 앱 내 구매 또는 제한된 리소스에 대한 액세스 권한을 부여하기 전에 지문 인증을 요구할 수 있습니다. UserConsentVerifier를 사용하여 CheckAvailabilityAsync 메서드를 사용하여 현재 컴퓨터에 지문 인증이 지원되는지 여부를 확인한 다음 RequestVerificationAsync 메서드를 사용하여 지문 검사에서 사용자 동의를 요청할 수 있습니다.

메서드

CheckAvailabilityAsync()

Microsoft Passport PIN, Windows Hello 또는 지문 판독기 같은 검증 도구 디바이스를 사용할 수 있는지 확인합니다.

RequestVerificationAsync(String)

Microsoft Passport PIN, Windows Hello 또는 지문 판독기 같은 디바이스를 사용하여 확인을 수행합니다. 이 API는 UWP(유니버설 Windows 플랫폼) 앱용입니다. 데스크톱 앱에 사용할 대체 API는 UserConsentVerifier 클래스의 예제에 설명되어 있습니다.

적용 대상

추가 정보