用户认证功能有哪些?

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

HarmonyOS
2024-05-28 21:30:45
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
chunter

核心代码解释

通过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生成密钥
450浏览 • 1回复 待解决
物联网平台中物模型的功能有什么?
4035浏览 • 1回复 待解决
PolarDB支持哪些备份功能
2097浏览 • 1回复 待解决
证书锁定功能示例有哪些
294浏览 • 1回复 待解决
如何实现向用户申请授权的功能
635浏览 • 1回复 待解决
PolarDB拥有哪些诊断和优化的功能
1157浏览 • 1回复 待解决
侧滑删除功能的列表有哪些
425浏览 • 1回复 待解决
一个帖子能有几个精华和采纳
1341浏览 • 1回复 待解决
什么时候能有个OHM刷机包?
2659浏览 • 1回复 待解决
HVD Manager登录失败 已实名认证
7109浏览 • 1回复 待解决
mqtt emqx_auth_mysql认证
1271浏览 • 1回复 待解决