fix UserAuth issue

Signed-off-by: https://gitee.com/WALL_EYE <wangguoqiang12@huawei.com>
Change-Id: I3f46d5250653e1b3654e8d51df8fe2abd3a112e6
This commit is contained in:
https://gitee.com/WALL_EYE 2022-03-12 20:47:37 +08:00
parent de76c7f3f6
commit c2b2e1bac6
27 changed files with 35 additions and 35 deletions

0
LICENSE Executable file → Normal file
View File

0
OAT.xml Executable file → Normal file
View File

0
interfaces/innerkits/napi/BUILD.gn Executable file → Normal file
View File

0
interfaces/innerkits/napi/include/auth_build.h Executable file → Normal file
View File

0
interfaces/innerkits/napi/include/auth_common.h Executable file → Normal file
View File

0
interfaces/innerkits/napi/include/auth_object.h Executable file → Normal file
View File

0
interfaces/innerkits/napi/include/authapi_callback.h Executable file → Normal file
View File

0
interfaces/innerkits/napi/include/result_convert.h Executable file → Normal file
View File

0
interfaces/innerkits/napi/include/user_auth_impl.h Executable file → Normal file
View File

0
interfaces/innerkits/napi/src/auth_build.cpp Executable file → Normal file
View File

0
interfaces/innerkits/native/BUILD.gn Executable file → Normal file
View File

0
interfaces/innerkits/native/include/iuser_auth.h Executable file → Normal file
View File

View File

0
interfaces/innerkits/native/include/user_auth.h Executable file → Normal file
View File

View File

View File

View File

@ -132,7 +132,7 @@ struct FreezInfo {
AuthType authType;
};
struct UserInfo {
struct CallerInfo {
uint64_t callerUID;
int32_t userID {0};
std::string pkgName;

0
interfaces/innerkits/native/include/userauth_proxy.h Executable file → Normal file
View File

View File

@ -42,14 +42,14 @@ public:
* after the callback of the coAuth is called to obtain the scheduling token
* and the authentication result is successful.
* */
void CoauthSetPropAuthInfo(UserInfo userInfo, int32_t resultCode,
void CoauthSetPropAuthInfo(CallerInfo callerInfo, int32_t resultCode,
UserAuthToken authToken, SetPropertyRequest requset);
/* Set the executor authentication properties for freez or unfreez */
void SetPropAuthInfo(UserInfo userInfo, int32_t resultCode, UserAuthToken authToken,
void SetPropAuthInfo(CallerInfo callerInfo, int32_t resultCode, UserAuthToken authToken,
SetPropertyRequest requset, std::vector<uint64_t> templateIds);
/* get the executor authentication properties for Coauth */
void GetPropAuthInfoCoauth(UserInfo userInfo, int32_t resultCode,
void GetPropAuthInfoCoauth(CallerInfo callerInfo, int32_t resultCode,
UserAuthToken authToken, GetPropertyRequest requset, sptr<IUserAuthCallback> &callback);
int32_t GenerateSolution(AuthSolution param, std::vector<uint64_t> &sessionIds);
int32_t RequestAuthResult(uint64_t contextId, std::vector<uint8_t> scheduleToken, UserAuthToken &authToken,
@ -70,7 +70,7 @@ private:
~UserAuthAdapter() = default;
int32_t GetEachExecutorProp(GetPropertyRequest &requset, ExecutorProperty &result, uint32_t &value,
std::shared_ptr<OHOS::UserIAM::AuthResPool::AuthAttributes> pAuthAttributes);
int32_t SetProPropAuthInfo(OHOS::UserIAM::AuthResPool::AuthAttributes &authAttributes, UserInfo userInfo,
int32_t SetProPropAuthInfo(OHOS::UserIAM::AuthResPool::AuthAttributes &authAttributes, CallerInfo callerInfo,
SetPropertyRequest requset, std::vector<uint64_t> templateIds,
std::shared_ptr<CoAuth::SetPropCallback> &setPropCallback);
};

0
services/include/userauth_async_proxy.h Executable file → Normal file
View File

0
services/include/userauth_datamgr.h Executable file → Normal file
View File

0
services/include/userauth_stub.h Executable file → Normal file
View File

View File

@ -62,15 +62,15 @@ void UserAuthAdapter::GetPropAuthInfo(int32_t userID, uint64_t callerUID, std::s
USERAUTH_HILOGI(MODULE_SERVICE, "UserAuth GetPropAuthInfo is end!");
}
void UserAuthAdapter::SetPropAuthInfo(UserInfo userInfo, int32_t resultCode,
void UserAuthAdapter::SetPropAuthInfo(CallerInfo callerInfo, int32_t resultCode,
UserAuthToken authToken, SetPropertyRequest requset, std::vector<uint64_t> templateIds)
{
USERAUTH_HILOGI(MODULE_SERVICE, "UserAuth SetPropAuthInfo is start!");
using namespace AuthResPool;
FreezInfo freezInfo;
freezInfo.callerID = userInfo.callerUID;
freezInfo.callerID = callerInfo.callerUID;
freezInfo.authType = requset.authType;
freezInfo.pkgName = userInfo.pkgName;
freezInfo.pkgName = callerInfo.pkgName;
freezInfo.resultCode = resultCode;
std::shared_ptr<CoAuth::SetPropCallback> setPropCallback =
@ -80,7 +80,7 @@ void UserAuthAdapter::SetPropAuthInfo(UserInfo userInfo, int32_t resultCode,
return;
}
AuthAttributes authAttributes;
int32_t ret = SetProPropAuthInfo(authAttributes, userInfo, requset, templateIds, setPropCallback);
int32_t ret = SetProPropAuthInfo(authAttributes, callerInfo, requset, templateIds, setPropCallback);
if (ret != SUCCESS) {
return;
}
@ -89,7 +89,7 @@ void UserAuthAdapter::SetPropAuthInfo(UserInfo userInfo, int32_t resultCode,
}
int32_t UserAuthAdapter::SetProPropAuthInfo(OHOS::UserIAM::AuthResPool::AuthAttributes &authAttributes,
UserInfo userInfo, SetPropertyRequest requset, std::vector<uint64_t> templateIds,
CallerInfo callerInfo, SetPropertyRequest requset, std::vector<uint64_t> templateIds,
std::shared_ptr<CoAuth::SetPropCallback> &setPropCallback)
{
uint32_t value;
@ -110,7 +110,7 @@ int32_t UserAuthAdapter::SetProPropAuthInfo(OHOS::UserIAM::AuthResPool::AuthAttr
setPropCallback->OnResult(ret, extraInfo);
return ret;
}
ret = authAttributes.SetUint64Value(AUTH_CALLER_UID, userInfo.callerUID);
ret = authAttributes.SetUint64Value(AUTH_CALLER_UID, callerInfo.callerUID);
if (ret != SUCCESS) {
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth SetUint32Value AUTH_CALLER_UID ERROR!");
std::vector<uint8_t> extraInfo;
@ -118,9 +118,9 @@ int32_t UserAuthAdapter::SetProPropAuthInfo(OHOS::UserIAM::AuthResPool::AuthAttr
return ret;
}
std::vector<uint8_t> pkgNameValue;
userInfo.pkgName.resize(userInfo.pkgName.size());
callerInfo.pkgName.resize(callerInfo.pkgName.size());
pkgNameValue.clear();
pkgNameValue.assign(userInfo.pkgName.begin(), userInfo.pkgName.end());
pkgNameValue.assign(callerInfo.pkgName.begin(), callerInfo.pkgName.end());
ret = authAttributes.SetUint8ArrayValue(AUTH_CALLER_NAME, pkgNameValue);
if (ret != SUCCESS) {
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth SetUint8ArrayValue->AUTH_CALLER_NAME ERROR!");
@ -137,14 +137,14 @@ int32_t UserAuthAdapter::SetProPropAuthInfo(OHOS::UserIAM::AuthResPool::AuthAttr
}
return ret;
}
void UserAuthAdapter::GetPropAuthInfoCoauth(UserInfo userInfo, int32_t resultCode,
void UserAuthAdapter::GetPropAuthInfoCoauth(CallerInfo callerInfo, int32_t resultCode,
UserAuthToken authToken, GetPropertyRequest requset, sptr<IUserAuthCallback> &callback)
{
USERAUTH_HILOGI(MODULE_SERVICE, "UserAuth GetPropAuthInfoCoauth is start!");
using namespace UserIDM;
std::shared_ptr<GetInfoCallback> getInfoCallback = std::make_shared<UserAuthCallbackImplIDMGetPorpCoauth>(callback,
userInfo.callerUID, userInfo.pkgName, resultCode, authToken, requset);
int32_t ret = UserIDMClient::GetInstance().GetAuthInfo(userInfo.userID,
callerInfo.callerUID, callerInfo.pkgName, resultCode, authToken, requset);
int32_t ret = UserIDMClient::GetInstance().GetAuthInfo(callerInfo.userID,
static_cast<UserIDM::AuthType>(requset.authType), getInfoCallback);
if (ret != SUCCESS) {
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth GetPropAuthInfoCoauth ERROR!");
@ -152,14 +152,14 @@ void UserAuthAdapter::GetPropAuthInfoCoauth(UserInfo userInfo, int32_t resultCod
USERAUTH_HILOGI(MODULE_SERVICE, "UserAuth GetPropAuthInfoCoauth is end!");
}
void UserAuthAdapter::CoauthSetPropAuthInfo(UserInfo userInfo, int32_t resultCode,
void UserAuthAdapter::CoauthSetPropAuthInfo(CallerInfo callerInfo, int32_t resultCode,
UserAuthToken authToken, SetPropertyRequest requset)
{
USERAUTH_HILOGI(MODULE_SERVICE, "UserAuth CoauthSetPropAuthInfo is start!");
using namespace UserIDM;
std::shared_ptr<GetInfoCallback> setPropCallback = std::make_shared<UserAuthCallbackImplIDMCothGetPorpFreez>(
userInfo.callerUID, userInfo.pkgName, resultCode, authToken, requset);
int32_t ret = UserIDMClient::GetInstance().GetAuthInfo(userInfo.userID,
callerInfo.callerUID, callerInfo.pkgName, resultCode, authToken, requset);
int32_t ret = UserIDMClient::GetInstance().GetAuthInfo(callerInfo.userID,
static_cast<UserIDM::AuthType>(requset.authType), setPropCallback);
if (ret != SUCCESS) {
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth CoauthSetPropAuthInfo ERROR!");

0
services/src/userauth_async_proxy.cpp Executable file → Normal file
View File

View File

@ -120,11 +120,11 @@ void UserAuthCallbackImplCoAuth::OnFinishHandleExtend(int32_t userID, SetPropert
USERAUTH_HILOGD(MODULE_SERVICE, "RequestAuthResult SUCCESS");
setPropertyRequest.authType = UserAuth::FACE;
setPropertyRequest.key = SetPropertyType::THAW_TEMPLATE;
UserInfo userInfo;
userInfo.callerUID = callerUid_;
userInfo.userID = userID;
userInfo.pkgName = pkgName_;
UserAuthAdapter::GetInstance().CoauthSetPropAuthInfo(userInfo, ret, authToken, setPropertyRequest);
CallerInfo callerInfo;
callerInfo.callerUID = callerUid_;
callerInfo.userID = userID;
callerInfo.pkgName = pkgName_;
UserAuthAdapter::GetInstance().CoauthSetPropAuthInfo(callerInfo, ret, authToken, setPropertyRequest);
}
}
@ -148,12 +148,12 @@ void UserAuthCallbackImplCoAuth::OnFinishHandle(uint32_t resultCode, std::vector
SetPropertyRequest setPropertyRequest;
GetPropertyRequest getPropertyRequest;
AuthResult authResult;
UserInfo userInfo;
CallerInfo callerInfo;
int32_t ret = GENERAL_ERROR;
std::lock_guard<std::mutex> lock(mutex_);
userInfo.callerUID = callerUid_;
userInfo.userID = userID_;
userInfo.pkgName = pkgName_;
callerInfo.callerUID = callerUid_;
callerInfo.userID = userID_;
callerInfo.pkgName = pkgName_;
USERAUTH_HILOGD(MODULE_SERVICE, "OnFinishHandle scheduleTokensize:%{public}d, resultCode:%{public}u",
scheduleToken.size(), resultCode);
callbackNowCount_++;
@ -178,7 +178,7 @@ void UserAuthCallbackImplCoAuth::OnFinishHandle(uint32_t resultCode, std::vector
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthCallbackImplCoAuth resultCode == LOCKED");
setPropertyRequest.authType = FACE;
setPropertyRequest.key = SetPropertyType::FREEZE_TEMPLATE;
UserAuthAdapter::GetInstance().CoauthSetPropAuthInfo(userInfo, resultCode, authToken,
UserAuthAdapter::GetInstance().CoauthSetPropAuthInfo(callerInfo, resultCode, authToken,
setPropertyRequest);
}
if (ret == SUCCESS) {
@ -187,7 +187,7 @@ void UserAuthCallbackImplCoAuth::OnFinishHandle(uint32_t resultCode, std::vector
getPropertyRequest.authType = authType_;
getPropertyRequest.keys.push_back(UserAuth::REMAIN_TIMES);
getPropertyRequest.keys.push_back(UserAuth::FREEZING_TIME);
UserAuthAdapter::GetInstance().GetPropAuthInfoCoauth(userInfo, resultCode,
UserAuthAdapter::GetInstance().GetPropAuthInfoCoauth(callerInfo, resultCode,
authToken, getPropertyRequest, callback_);
DealFinishData(sessionIds);
}
@ -283,10 +283,10 @@ UserAuthCallbackImplIDMCothGetPorpFreez::UserAuthCallbackImplIDMCothGetPorpFreez
void UserAuthCallbackImplIDMCothGetPorpFreez::OnGetInfo(std::vector<UserIDM::CredentialInfo>& info)
{
UserInfo userInfo;
userInfo.callerUID = callerUid_;
userInfo.userID = 0;
userInfo.pkgName = pkgName_;
CallerInfo callerInfo;
callerInfo.callerUID = callerUid_;
callerInfo.userID = 0;
callerInfo.pkgName = pkgName_;
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthCallbackImplIDMCothGetPorpFreez OnGetInfo enter");
std::vector<uint64_t> templateIds;
@ -303,7 +303,7 @@ void UserAuthCallbackImplIDMCothGetPorpFreez::OnGetInfo(std::vector<UserIDM::Cre
for (auto const &item : info) {
templateIds.push_back(item.templateId);
}
UserAuthAdapter::GetInstance().SetPropAuthInfo(userInfo, resultCode_, authToken_, requset_,
UserAuthAdapter::GetInstance().SetPropAuthInfo(callerInfo, resultCode_, authToken_, requset_,
templateIds);
}

0
userauth.gni Executable file → Normal file
View File