日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OS生物特征識別開發(fā)指導(dǎo)

場景介紹

目前創(chuàng)新互聯(lián)公司已為成百上千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、雅安服務(wù)器托管、網(wǎng)站托管、服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計、沅江網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

當(dāng)前生物特征識別支持 2D 人臉識別、3D 人臉識別,可應(yīng)用于設(shè)備解鎖、應(yīng)用登錄、支付等身份認(rèn)證場景。

接口說明

BiometricAuthentication 類提供了生物認(rèn)證的相關(guān)方法,包括檢測認(rèn)證能力、認(rèn)證和取消認(rèn)證等,用戶可以通過人臉等生物特征信息進(jìn)行認(rèn)證操作。在執(zhí)行認(rèn)證前,需要檢查設(shè)備是否支持該認(rèn)證能力,具體指認(rèn)證類型、安全級別和是否本地認(rèn)證。如果不支持,需要考慮使用其他認(rèn)證能力。

接口名 功能描述
getInstance(Ability ability)獲取 BiometricAuthentication的單例對象。
checkAuthenticationAvailability(AuthType type, SecureLevel level, boolean isLocalAuth)檢測設(shè)備是否具有生物認(rèn)證能力。
execAuthenticationAction(AuthType type, SecureLevel level, boolean isLocalAuth,boolean isAppAuthDialog, SystemAuthDialogInfo information)調(diào)用者使用該方法進(jìn)行生物認(rèn)證??梢允褂米远x的認(rèn)證界面,也可以使用系統(tǒng)提供的認(rèn)證界面。當(dāng)使用系統(tǒng)認(rèn)證界面時,調(diào)用者可以自定義提示語。該方法直到認(rèn)證結(jié)束才返回認(rèn)證結(jié)果。
getAuthenticationTips()獲取生物認(rèn)證過程中的提示信息。
cancelAuthenticationAction()取消生物認(rèn)證操作。
setSecureObjectSignature(Signature sign)設(shè)置需要關(guān)聯(lián)認(rèn)證結(jié)果的Signature 對象,在進(jìn)行認(rèn)證操作后,如果認(rèn)證成功則Signature 對象被授權(quán)可以使用。設(shè)置前 Signature 對象需要正確初始化,且配置為認(rèn)證成功才能使用。
getSecureObjectSignature()在認(rèn)證成功后,可通過該方法獲取已授權(quán)的 Signature 對象。如果未設(shè)置過 Signature 對象,則返回 null。
setSecureObjectCipher(Cipher cipher)設(shè)置需要關(guān)聯(lián)認(rèn)證結(jié)果的 Cipher 對象,在進(jìn)行認(rèn)證操作后,如果認(rèn)證成功則 Cipher 對象被授權(quán)可以使用。設(shè)置前 Cipher 對象需要正確初始化,且配置為認(rèn)證成功才能使用。
getSecureObjectCipher()在認(rèn)證成功后,可通過該方法獲取已授權(quán)的 Cipher 對象。如果未設(shè)置過 Cipher 對象,則返回 null。
setSecureObjectMac(Mac mac)設(shè)置需要關(guān)聯(lián)認(rèn)證結(jié)果的 Mac 對象,在進(jìn)行認(rèn)證操作后,如果認(rèn)證成功則 Mac 對象被授權(quán)可以使用。設(shè)置前 Mac 對象需要正確初始化,且配置為認(rèn)證成功才能使用。
getSecureObjectMac()在認(rèn)證成功后,可通過該方法獲取已授權(quán)的 Mac 對象。如果未設(shè)置過 Mac 對象,則返回 null。

開發(fā)步驟

開發(fā)前請完成以下準(zhǔn)備工作:

  1. 在應(yīng)用配置權(quán)限文件中,增加 ohos.permission.ACCESS_BIOMETRIC 的權(quán)限聲明。
  2. 在使用生物特征識別認(rèn)證能力的代碼文件中增加 import ohos.biometrics.authentication.BiometricAuthentication。

開發(fā)過程:

  1. 獲取 BiometricAuthentication 的單例對象,代碼示例如下:
   BiometricAuthentication  mBiometricAuthentication = BiometricAuthentication.getInstance(MainAbility.mAbility);

  1. 檢測設(shè)備是否具有生物認(rèn)證能力:

2D 人臉識別建議使用 SECURE_LEVEL_S2,3D 人臉識別建議使用 SECURE_LEVEL_S3。代碼示例如下:

   int retChkAuthAvb = mBiometricAuthentication.checkAuthenticationAvailability(
   BiometricAuthentication.AuthType.AUTH_TYPE_BIOMETRIC_FACE_ONLY, BiometricAuthentication.SecureLevel.SECURE_LEVEL_S2, true);

  1. (可選)設(shè)置需要關(guān)聯(lián)認(rèn)證結(jié)果的 Signature 對象或 Cipher 對象或 Mac 對象,代碼示例如下:
   // 定義一個Signature對象sign;
   mBiometricAuthentication.setSecureObjectSignature(sign);

    
   // 定義一個Cipher對象cipher;
   mBiometricAuthentication.setSecureObjectCipher(cipher);

    
   // 定義一個Mac對象mac;
   mBiometricAuthentication.setSecureObjectMac(mac);

  1. 在新線程里面執(zhí)行認(rèn)證操作,避免阻塞其他操作,代碼示例如下:
   new Thread(new Runnable() {
       @Override
       public void run() {
           int retExcAuth;
           retExcAuth = mBiometricAuthentication.execAuthenticationAction(        BiometricAuthentication.AuthType.AUTH_TYPE_BIOMETRIC_FACE_ONLY,        BiometricAuthentication.SecureLevel.SECURE_LEVEL_S2, true, false, null);
       }
   }).start();

  1. 獲得認(rèn)證過程中的提示信息,代碼示例如下:
   AuthenticationTips  mTips = mBiometricAuthentication.getAuthenticationTips();

  1. (可選)認(rèn)證成功后獲取已設(shè)置的 Signature 對象或 Cipher 對象或 Mac 對象,代碼示例如下:
   Signature  sign = mBiometricAuthentication.getSecureObjectSignature();

    
   Cipher cipher = mBiometricAuthentication.getSecureObjectCipher();

    
   Mac mac = mBiometricAuthentication.getSecureObjectMac();

  1. 認(rèn)證過程中取消認(rèn)證,代碼示例如下:
   int  ret = mBiometricAuthentication.cancelAuthenticationAction();

網(wǎng)站欄目:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OS生物特征識別開發(fā)指導(dǎo)
鏈接分享:http://m.5511xx.com/article/dhcjihp.html