diff --git a/interfaces/innerkits/native/include/user_auth.h b/interfaces/innerkits/native/include/user_auth.h index be7198471cd8989568e2871fb4bd689734502a9d..4c875e4468b73e8a549a0f9122c7fcfa05b8df1a 100755 --- a/interfaces/innerkits/native/include/user_auth.h +++ b/interfaces/innerkits/native/include/user_auth.h @@ -44,9 +44,9 @@ public: private: class UserAuthDeathRecipient : public IRemoteObject::DeathRecipient { public: - UserAuthDeathRecipient() = default; - ~UserAuthDeathRecipient() = default; - void OnRemoteDied(const wptr& remote) override; + UserAuthDeathRecipient() = default; + ~UserAuthDeathRecipient() = default; + void OnRemoteDied(const wptr& remote) override; private: DISALLOW_COPY_AND_MOVE(UserAuthDeathRecipient); diff --git a/interfaces/innerkits/native/include/userauth_info.h b/interfaces/innerkits/native/include/userauth_info.h index 4284e9b699c31795a60c8b8ff3cde64e44b397e0..7a60d349d6569436667b266f68a2805578173564 100755 --- a/interfaces/innerkits/native/include/userauth_info.h +++ b/interfaces/innerkits/native/include/userauth_info.h @@ -23,12 +23,12 @@ namespace OHOS { namespace UserIAM { namespace UserAuth { -// 认证的类型(口令,人脸) +// Type of authentication (password, face) enum AuthType: uint32_t { PIN = 1, FACE = 2, }; -// 认证子类型(2D人脸,3D人脸...) +// Authentication subtype (2D face, 3D face...) enum AuthSubType: uint64_t { /** * Authentication sub type six number pin. @@ -51,7 +51,7 @@ enum AuthSubType: uint64_t { */ FACE_3D = 20001 }; -// 认证结果可信等级 +// Certification result confidence level enum AuthTurstLevel: uint32_t { // level 1-4 ATL1 = 10000, @@ -59,48 +59,50 @@ enum AuthTurstLevel: uint32_t { ATL3 = 30000, ATL4 = 40000 }; -// 执行器属性列表 +// Actuator get property list enum GetPropertyType: uint32_t { - // 认证子类型(此时认证类型已确认) + // Authentication subtype (at this point the authentication type has been confirmed) AUTH_SUB_TYPE = 1, - // 剩余认证次数 + // Remaining authentication times REMAIN_TIMES = 2, - // 冻结时间 + // Freeze time FREEZING_TIME = 3, }; -// 获得属性请求 +// get attribute request struct GetPropertyRequest { AuthType authType; // GetPropertyType std::vector keys; }; -// 执行器属性 +// Actuator properties struct ExecutorProperty { int32_t result; AuthSubType authSubType; uint32_t remainTimes; uint32_t freezingTime; }; -// 执行器属性列表 +// Actuator property mode list enum AuthPropertyMode: uint32_t { - PROPERMODE_DELETE = 0, - PROPERMODE_GET = 1, - PROPERMODE_SET = 2, - PROPERMODE_FREEZE = 3, - PROPERMODE_UNFREEZE = 4, + PROPERMODE_DELETE = 0, + PROPERMODE_GET = 1, + PROPERMODE_SET = 2, + PROPERMODE_FREEZE = 3, + PROPERMODE_UNFREEZE = 4, + PROPERMODE_INIT_ALGORITHM = 5, + PROPERMODE_RELEASE_ALGORITHM = 6, }; -// 执行器属性列表 +// Actuator property list enum SetPropertyType: uint32_t { - INIT_ALGORITHM = 1, - FREEZE_TEMPLATE = 2, - THAW_TEMPLATE = 3, + INIT_ALGORITHM = 1, + FREEZE_TEMPLATE = 2, + THAW_TEMPLATE = 3, }; struct SetPropertyRequest { AuthType authType; SetPropertyType key; std::vector setInfo; }; -// 认证结果 +// Authentication Result struct AuthResult { std::vector token; uint32_t remainTimes; @@ -121,7 +123,7 @@ struct FreezInfo { AuthType authType; }; -// 结果码 +// Result Code enum ResultCode: int32_t { /** * Indicates that authentication is success or ability is supported. diff --git a/services/include/userauth_adapter.h b/services/include/userauth_adapter.h index 3f2b5a61f2219ccb7fd635d3bc00b19207d81484..7ad3d7ecf78909a8f569b56334b95122a1ed66c2 100644 --- a/services/include/userauth_adapter.h +++ b/services/include/userauth_adapter.h @@ -45,20 +45,24 @@ public: void CoauthSetPropAuthInfo(int32_t resultCode, uint64_t callerUID, std::string pkgName, UserAuthToken authToken, SetPropertyRequest requset, sptr& callback); - /* Set the executor authentication properties */ + /* Set the executor authentication properties for freez or unfreez */ void SetPropAuthInfo(uint64_t callerUID, std::string pkgName, int32_t resultCode, UserAuthToken authToken, SetPropertyRequest requset, std::vector templateIds, sptr& callback); + /* get the executor authentication properties for Coauth */ void GetPropAuthInfoCoauth(uint64_t callerUID, std::string pkgName, int32_t resultCode, UserAuthToken authToken, GetPropertyRequest requset, sptr& callback); + /* get userID */ int32_t GetUserID(int32_t &userID); int32_t GenerateSolution(AuthSolution param, std::vector &sessionIds); int32_t RequestAuthResult(uint64_t contextId, std::vector scheduleToken, UserAuthToken &authToken, std::vector &sessionIds); int32_t CancelContext(uint64_t contextId, std::vector &sessionIds); int32_t Cancel(uint64_t sessionId); + /* get the executor authentication properties */ int32_t GetExecutorProp(uint64_t callerUID, std::string pkgName, uint64_t templateId, GetPropertyRequest requset, ExecutorProperty &result); + /* Set the executor authentication properties */ int32_t SetExecutorProp(uint64_t callerUID, std::string pkgName, SetPropertyRequest requset, sptr& callback); int32_t GetVersion(); diff --git a/services/src/userauth_adapter.cpp b/services/src/userauth_adapter.cpp index 4dff5c26e86a491f9364355bb11c8b3935189aff..af1dc5c17fa6d8593f9fdda4fc358c200b903717 100644 --- a/services/src/userauth_adapter.cpp +++ b/services/src/userauth_adapter.cpp @@ -94,7 +94,7 @@ int32_t UserAuthAdapter::SetProPropAuthInfo(OHOS::UserIAM::AuthResPool::AuthAttr setPropCallback->OnResult(ret, extraInfo); return ret; } - value = requset.key ==SetPropertyType::FREEZE_TEMPLATE ? + value = requset.key == SetPropertyType::FREEZE_TEMPLATE ? static_cast(AuthPropertyMode::PROPERMODE_FREEZE) : static_cast(AuthPropertyMode::PROPERMODE_UNFREEZE); ret = authAttributes.SetUint32Value(AUTH_PROPERTY_MODE, value); @@ -331,7 +331,10 @@ int32_t UserAuthAdapter::SetExecutorProp(uint64_t callerUID, std::string pkgName std::shared_ptr setPropCallback = std::make_shared(callback); OHOS::UserIAM::AuthResPool::AuthAttributes pAuthAttributes; - int32_t ret = pAuthAttributes.SetUint32Value(AUTH_PROPERTY_MODE, PROPERMODE_SET); + uint32_t value = requset.key == SetPropertyType::INIT_ALGORITHM ? + static_cast(AuthPropertyMode::PROPERMODE_INIT_ALGORITHM) + : static_cast(AuthPropertyMode::PROPERMODE_RELEASE_ALGORITHM); + int32_t ret = pAuthAttributes.SetUint32Value(AUTH_PROPERTY_MODE, value); if (ret != SUCCESS) { USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth SetUint32Value SET_AUTH_PROPERTY_MODE ERROR!"); return ret; @@ -355,7 +358,7 @@ int32_t UserAuthAdapter::SetExecutorProp(uint64_t callerUID, std::string pkgName USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth SetUint32Value AUTH_TYPE ERROR!"); return ret; } - ret = pAuthAttributes.SetUint8ArrayValue(AUTH_SIGNATURE, requset.setInfo); + ret = pAuthAttributes.SetUint8ArrayValue(ALGORITHM_INFO, requset.setInfo); if (ret != SUCCESS) { USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth SetUint8ArrayValue init ERROR!"); return ret;