C# UWP和Windows Store 8.1生物识别授权
我们有一个应用程序,使用电子邮件+密码登录。为了舒适,我们实现了4位PIN码逻辑。所有这些逻辑都是自行创建的,不使用任何microsoft内置功能 在1台设备上可能有许多用户。因此,我们还希望实现生物特征认证的可能性 我在谷歌上搜索了这些信息,似乎所有的生物识别授权选项都是基于微软账户的 我想象过这样的情况:C# UWP和Windows Store 8.1生物识别授权,c#,uwp,windows-store-apps,biometrics,C#,Uwp,Windows Store Apps,Biometrics,我们有一个应用程序,使用电子邮件+密码登录。为了舒适,我们实现了4位PIN码逻辑。所有这些逻辑都是自行创建的,不使用任何microsoft内置功能 在1台设备上可能有许多用户。因此,我们还希望实现生物特征认证的可能性 我在谷歌上搜索了这些信息,似乎所有的生物识别授权选项都是基于微软账户的 我想象过这样的情况: var hash = GetBiometricHash(); // reuqest user to make biometric authorization and the hash w
var hash = GetBiometricHash();
// reuqest user to make biometric authorization and the hash we could store on our servers.
是否存在这种可能性,或者我们将不得不集成Microsoft帐户使用?您可以通过以下代码添加到您的通用Windows平台(UWP)应用程序中。当用户必须同意某个特定操作时,包括指纹身份验证请求可以提高应用程序的安全性。但是如果你换了一台没有指纹信息的设备。应用程序将无法验证您的指纹。目前没有这样的api将指纹信息保存到您自己的web服务中。因此,您可以集成使用
private async System.Threading.Tasks.Task requestapprove(字符串
用户信息)
{
字符串返回消息;
if(String.IsNullOrEmpty(userMessage))
{
userMessage=“请提供指纹验证。”;
}
尝试
{
//通过指纹扫描请求登录用户的同意。
var approverresult=wait Windows.Security.Credentials.UI.UserApproverVerifier.RequestVerificationAsync(userMessage);
开关(结果)
{
案例Windows.Security.Credentials.UI.UserApprovementVerificationResult.Verified:
returnMessage=“指纹已验证。”;
打破
案例Windows.Security.Credentials.UI.UserApprovementVerificationResult.DeviceBusy:
returnMessage=“生物识别设备正忙。”;
打破
案例Windows.Security.Credentials.UI.UserApprovementVerificationResult.DeviceNotPresent:
returnMessage=“未找到生物识别设备。”;
打破
案例Windows.Security.Credentials.UI.UserApprovementVerificationResult.DisabledByPolicy:
returnMessage=“生物识别验证已被策略禁用。”;
打破
案例Windows.Security.Credentials.UI.UserApprovementVerificationResult.NotConfiguredForUser:
returnMessage=“用户没有注册指纹。请将指纹添加到”+
“指纹数据库,然后重试。”;
打破
案例Windows.Security.Credentials.UI.UserApprovementVerificationResult.RetriesHausted:
returnMessage=“尝试失败的次数太多。指纹身份验证已取消。”;
打破
案例Windows.Security.Credentials.UI.UserApprovementVerificationResult.Cancelled:
returnMessage=“指纹身份验证已取消。”;
打破
违约:
returnMessage=“指纹身份验证当前不可用。”;
打破
}
}
捕获(例外情况除外)
{
returnMessage=“指纹身份验证失败:”+ex.ToString();
}
返回消息;
}
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;
}