UserConsentVerifier 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
확인 디바이스(예: 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
- 상속
- 특성
Windows 요구 사항
디바이스 패밀리 |
Windows 10 (10.0.10240.0에서 도입되었습니다.)
|
API contract |
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)
|
예제
C를 사용하는 데스크톱 앱#
데스크톱 앱의 경우 UserConsentVerifier.RequestVerificationAsync 메서드를 호출하는 대신 다음을 수행해야 합니다.
- 먼저 HWND(창 핸들)를 검색합니다. 이 항목에는 WinUI(Windows UI 라이브러리) 3, WPF(Windows Presentation Foundation) 및 winForms(Windows Forms)에 대한 코드 예제가 포함되어 있습니다. 해당 코드를 아래 코드 목록에 연결합니다.
- 그런 다음 Windows.Security.Credentials.UI.UserConsentVerifierInterop C# interop 클래스의 RequestVerificationForWindowAsync 메서드를 호출합니다. C# interop 클래스에 대한 자세한 내용은 .NET 앱에서 interop API 호출을 참조하세요. 또한 CoreWindow에 의존하는 WinRT UI 개체 표시를 참조하세요.
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 클래스의 예제에 설명되어 있습니다. |
적용 대상
추가 정보
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기