掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流

目前創(chuàng)新互聯(lián)公司已為成百上千家的企業(yè)提供了網(wǎng)站建設、域名、雅安服務器托管、網(wǎng)站托管、服務器托管、企業(yè)網(wǎng)站設計、沅江網(wǎng)站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
當前生物特征識別支持 2D 人臉識別、3D 人臉識別,可應用于設備解鎖、應用登錄、支付等身份認證場景。
BiometricAuthentication 類提供了生物認證的相關方法,包括檢測認證能力、認證和取消認證等,用戶可以通過人臉等生物特征信息進行認證操作。在執(zhí)行認證前,需要檢查設備是否支持該認證能力,具體指認證類型、安全級別和是否本地認證。如果不支持,需要考慮使用其他認證能力。
| 接口名 | 功能描述 |
|---|---|
| getInstance(Ability ability) | 獲取 BiometricAuthentication的單例對象。 |
| checkAuthenticationAvailability(AuthType type, SecureLevel level, boolean isLocalAuth) | 檢測設備是否具有生物認證能力。 |
| execAuthenticationAction(AuthType type, SecureLevel level, boolean isLocalAuth,boolean isAppAuthDialog, SystemAuthDialogInfo information) | 調(diào)用者使用該方法進行生物認證??梢允褂米远x的認證界面,也可以使用系統(tǒng)提供的認證界面。當使用系統(tǒng)認證界面時,調(diào)用者可以自定義提示語。該方法直到認證結束才返回認證結果。 |
| getAuthenticationTips() | 獲取生物認證過程中的提示信息。 |
| cancelAuthenticationAction() | 取消生物認證操作。 |
| setSecureObjectSignature(Signature sign) | 設置需要關聯(lián)認證結果的Signature 對象,在進行認證操作后,如果認證成功則Signature 對象被授權可以使用。設置前 Signature 對象需要正確初始化,且配置為認證成功才能使用。 |
| getSecureObjectSignature() | 在認證成功后,可通過該方法獲取已授權的 Signature 對象。如果未設置過 Signature 對象,則返回 null。 |
| setSecureObjectCipher(Cipher cipher) | 設置需要關聯(lián)認證結果的 Cipher 對象,在進行認證操作后,如果認證成功則 Cipher 對象被授權可以使用。設置前 Cipher 對象需要正確初始化,且配置為認證成功才能使用。 |
| getSecureObjectCipher() | 在認證成功后,可通過該方法獲取已授權的 Cipher 對象。如果未設置過 Cipher 對象,則返回 null。 |
| setSecureObjectMac(Mac mac) | 設置需要關聯(lián)認證結果的 Mac 對象,在進行認證操作后,如果認證成功則 Mac 對象被授權可以使用。設置前 Mac 對象需要正確初始化,且配置為認證成功才能使用。 |
| getSecureObjectMac() | 在認證成功后,可通過該方法獲取已授權的 Mac 對象。如果未設置過 Mac 對象,則返回 null。 |
開發(fā)前請完成以下準備工作:
開發(fā)過程:
BiometricAuthentication mBiometricAuthentication = BiometricAuthentication.getInstance(MainAbility.mAbility);
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);
// 定義一個Signature對象sign;
mBiometricAuthentication.setSecureObjectSignature(sign);
// 定義一個Cipher對象cipher;
mBiometricAuthentication.setSecureObjectCipher(cipher);
// 定義一個Mac對象mac;
mBiometricAuthentication.setSecureObjectMac(mac);
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();
AuthenticationTips mTips = mBiometricAuthentication.getAuthenticationTips();
Signature sign = mBiometricAuthentication.getSecureObjectSignature();
Cipher cipher = mBiometricAuthentication.getSecureObjectCipher();
Mac mac = mBiometricAuthentication.getSecureObjectMac();
int ret = mBiometricAuthentication.cancelAuthenticationAction(); 
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流