用户认证功能有哪些?

一是涉密系统,需要高度安全防护地方;二是针对大规模人群的身份鉴别的技术;三是针对城市公共事务的市民应用;四是从现实生活进入互联网虚拟世界的认证应用。

HarmonyOS
2024-05-28 21:30:45
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
宇宙无敌超英俊

核心代码解释

通过navigationButtonText属性进行用户认证。

import userAuth from '@ohos.userIAM.userAuth' 
import PermissionManager from '../util/PermissionManager' 
  
@Component 
export struct UserAuth { 
  
  build() { 
    Column() { 
      Text('用户认证').fontSize(50) 
      Button('用户认证 身份认证类型:PIN码,信任等级 ATL4').width('80%') 
        .onClick(async () => { 
          const authParam : userAuth.AuthParam = { 
            challenge: new Uint8Array([49, 49, 49, 49, 49, 49]), 
            authType: [userAuth.UserAuthType.PIN], 
            authTrustLevel: userAuth.AuthTrustLevel.ATL4, 
          }; 
          const widgetParam :userAuth.WidgetParam = { 
            title: '请输入锁屏密钥' 
          }; 
          try { 
            const userAuthInstance = userAuth.getUserAuthInstance(authParam, widgetParam); 
            userAuthInstance.on('result', { 
              onResult(result) { 
                console.log('wsf: userAuthInstance callback result = ' + JSON.stringify(result)); 
              } 
            }) 
            await PermissionManager.getInstance().requestPermission(['ohos.permission.ACCESS_BIOMETRIC']) 
            userAuthInstance.start() 
          } catch (error) { 
            console.error('wsf: auth catch error: ' + JSON.stringify(error)); 
          } 
        }) 
  
      Button('用户认证 身份认证类型:FACE').width('80%') 
        .onClick(async () => { 
          const authParam : userAuth.AuthParam = { 
            challenge: new Uint8Array([49, 49, 49, 49, 49, 49]), 
            authType: [userAuth.UserAuthType.FACE], 
            authTrustLevel: userAuth.AuthTrustLevel.ATL1, 
          }; 
          const widgetParam :userAuth.WidgetParam = { 
            title: '请输入密钥', 
          }; 
          try { 
            const userAuthInstance = userAuth.getUserAuthInstance(authParam, widgetParam); 
            userAuthInstance.on('result', { 
              onResult(result) { 
                console.log('wsf: userAuthInstance callback result = ' + JSON.stringify(result)); 
              } 
            }) 
            await PermissionManager.getInstance().requestPermission(['ohos.permission.ACCESS_BIOMETRIC']) 
            userAuthInstance.start() 
          } catch (error) { 
            console.error('wsf: auth catch error: ' + JSON.stringify(error)); 
          } 
        }) 
  
      Button('用户认证 身份认证类型:指纹').width('80%') 
        .onClick(async () => { 
          const authParam : userAuth.AuthParam = { 
            challenge: new Uint8Array([49, 49, 49, 49, 49, 49]), 
            authType: [userAuth.UserAuthType.FINGERPRINT], 
            authTrustLevel: userAuth.AuthTrustLevel.ATL1, 
          }; 
          const widgetParam :userAuth.WidgetParam = { 
            title: '把手指头放上面', 
            navigationButtonText: "我是导航按键" // 只能在指纹,人脸类型设置;暂不生效 
          }; 
          try { 
            const userAuthInstance = userAuth.getUserAuthInstance(authParam, widgetParam); 
            userAuthInstance.on('result', { 
              onResult(result) { 
                console.log('wsf: userAuthInstance callback result = ' + JSON.stringify(result)); 
              } 
            }) 
            await PermissionManager.getInstance().requestPermission(['ohos.permission.ACCESS_BIOMETRIC']) 
            userAuthInstance.start() 
          } catch (error) { 
            console.error('wsf: auth catch error: ' + JSON.stringify(error)); 
          } 
        }) 
  
      Button('用户认证 5s后自动取消').width('80%') 
        .onClick(async () => { 
          const authParam : userAuth.AuthParam = { 
            challenge: new Uint8Array([49, 49, 49, 49, 49, 49]), 
            authType: [userAuth.UserAuthType.PIN], 
            authTrustLevel: userAuth.AuthTrustLevel.ATL4, 
          }; 
          const widgetParam :userAuth.WidgetParam = { 
            title: '请输入锁屏密钥', 
          }; 
          try { 
            const userAuthInstance = userAuth.getUserAuthInstance(authParam, widgetParam); 
            userAuthInstance.on('result', { 
              onResult(result) { 
                console.log('wsf: userAuthInstance callback result = ' + JSON.stringify(result)); 
              } 
            }) 
            await PermissionManager.getInstance().requestPermission(['ohos.permission.ACCESS_BIOMETRIC']) 
            userAuthInstance.start() 
            setTimeout(() => { 
              userAuthInstance.cancel() 
            }, 5000) 
          } catch (error) { 
            console.error('wsf: auth catch error: ' + JSON.stringify(error)); 
          } 
        }) 
    } 
  } 
}

分享
微博
QQ
微信
回复
2024-05-29 22:41:44
相关问题
HUKS用户认证通过PIN生成密钥
916浏览 • 1回复 待解决
按照Api进行指纹认证功能调不起来
260浏览 • 1回复 待解决
物联网平台中物模型的功能有什么?
5181浏览 • 1回复 待解决
证书锁定功能示例有哪些
655浏览 • 1回复 待解决
PolarDB支持哪些备份功能
3044浏览 • 1回复 待解决
如何实现向用户申请授权的功能
1762浏览 • 1回复 待解决
PolarDB拥有哪些诊断和优化的功能
2334浏览 • 1回复 待解决
侧滑删除功能的列表有哪些
701浏览 • 1回复 待解决
实名认证Button的实现
275浏览 • 1回复 待解决
HarmonyOS 录音,希望能有录音Demo
91浏览 • 1回复 待解决
mqtt emqx_auth_mysql认证
2346浏览 • 1回复 待解决