Signed-off-by: liuziwei <liuziwei12@huawei.com>
Change-Id: I460433dc96f94cc987055f14851f612e6c848c7f
This commit is contained in:
liuziwei 2023-10-27 02:58:34 +00:00
parent e4e27377a2
commit 56bc173712
3 changed files with 17 additions and 28 deletions

View File

@ -51,8 +51,8 @@ UserAuthResultCode AuthInstanceV9::GetAvailableStatus(napi_env env, napi_callbac
IAM_LOGE("napi_get_value_int32 fail:%{public}d", ret); IAM_LOGE("napi_get_value_int32 fail:%{public}d", ret);
return UserAuthResultCode::GENERAL_ERROR; return UserAuthResultCode::GENERAL_ERROR;
} }
if (!UserAuthNapiHelper::CheckAuthType(type)) { if (!UserAuthNapiHelper::CheckUserAuthType(type)) {
IAM_LOGE("CheckAuthType fail"); IAM_LOGE("CheckUserAuthType fail");
return UserAuthResultCode::TYPE_NOT_SUPPORT; return UserAuthResultCode::TYPE_NOT_SUPPORT;
} }
uint32_t level; uint32_t level;

View File

@ -65,8 +65,6 @@ private:
std::shared_ptr<ContextCallback> GetAuthContextCallback(const AuthParam &authParam, std::shared_ptr<ContextCallback> GetAuthContextCallback(const AuthParam &authParam,
const WidgetParam &widgetParam, sptr<UserAuthCallbackInterface> &callback); const WidgetParam &widgetParam, sptr<UserAuthCallbackInterface> &callback);
bool CheckAuthTrustLevel(AuthTrustLevel authTrustLevel); bool CheckAuthTrustLevel(AuthTrustLevel authTrustLevel);
ResultCode CheckNorthPermission(AuthType authType);
ResultCode CheckServicePermission(AuthType authType);
bool CheckSingeFaceOrFinger(const std::vector<AuthType> &authType); bool CheckSingeFaceOrFinger(const std::vector<AuthType> &authType);
int32_t CheckAuthWidgetType(const std::vector<AuthType> &authType); int32_t CheckAuthWidgetType(const std::vector<AuthType> &authType);
int32_t CheckAuthWidgetParam( int32_t CheckAuthWidgetParam(

View File

@ -128,10 +128,14 @@ bool UserAuthService::CheckAuthTrustLevel(AuthTrustLevel authTrustLevel)
int32_t UserAuthService::GetAvailableStatus(int32_t apiVersion, AuthType authType, AuthTrustLevel authTrustLevel) int32_t UserAuthService::GetAvailableStatus(int32_t apiVersion, AuthType authType, AuthTrustLevel authTrustLevel)
{ {
IAM_LOGI("start"); IAM_LOGI("start");
ResultCode checkRet = CheckServicePermission(authType); if (!IpcCommon::CheckPermission(*this, ACCESS_USER_AUTH_INTERNAL_PERMISSION) &&
if (checkRet != SUCCESS) { !IpcCommon::CheckPermission(*this, ACCESS_BIOMETRIC_PERMISSION)) {
IAM_LOGE("failed to check permission"); IAM_LOGE("failed to check permission");
return checkRet; return CHECK_PERMISSION_FAILED;
}
if (apiVersion <= API_VERSION_8 && authType == PIN) {
IAM_LOGE("authType not support");
return TYPE_NOT_SUPPORT;
} }
if (!CheckAuthTrustLevel(authTrustLevel)) { if (!CheckAuthTrustLevel(authTrustLevel)) {
IAM_LOGE("authTrustLevel is not in correct range"); IAM_LOGE("authTrustLevel is not in correct range");
@ -257,23 +261,6 @@ void UserAuthService::SetProperty(int32_t userId, AuthType authType, const Attri
callback->OnSetExecutorPropertyResult(result); callback->OnSetExecutorPropertyResult(result);
} }
ResultCode UserAuthService::CheckNorthPermission(AuthType authType)
{
if (!IpcCommon::CheckPermission(*this, ACCESS_BIOMETRIC_PERMISSION)) {
IAM_LOGE("CheckNorthPermission failed, no permission");
return CHECK_PERMISSION_FAILED;
}
return SUCCESS;
}
ResultCode UserAuthService::CheckServicePermission(AuthType authType)
{
if (IpcCommon::CheckPermission(*this, ACCESS_USER_AUTH_INTERNAL_PERMISSION)) {
return SUCCESS;
}
return CheckNorthPermission(authType);
}
std::shared_ptr<ContextCallback> UserAuthService::GetAuthContextCallback(const std::vector<uint8_t> &challenge, std::shared_ptr<ContextCallback> UserAuthService::GetAuthContextCallback(const std::vector<uint8_t> &challenge,
AuthType authType, AuthTrustLevel authTrustLevel, sptr<UserAuthCallbackInterface> &callback) AuthType authType, AuthTrustLevel authTrustLevel, sptr<UserAuthCallbackInterface> &callback)
{ {
@ -305,10 +292,14 @@ uint64_t UserAuthService::Auth(int32_t apiVersion, const std::vector<uint8_t> &c
return BAD_CONTEXT_ID; return BAD_CONTEXT_ID;
} }
Attributes extraInfo; Attributes extraInfo;
ResultCode checkRet = CheckNorthPermission(authType); if (!IpcCommon::CheckPermission(*this, ACCESS_BIOMETRIC_PERMISSION)) {
if (checkRet != SUCCESS) { IAM_LOGE("failed to check permission");
IAM_LOGE("CheckNorthPermission failed"); contextCallback->OnResult(CHECK_PERMISSION_FAILED, extraInfo);
contextCallback->OnResult(checkRet, extraInfo); return BAD_CONTEXT_ID;
}
if (authType == PIN) {
IAM_LOGE("authType not support");
contextCallback->OnResult(TYPE_NOT_SUPPORT, extraInfo);
return BAD_CONTEXT_ID; return BAD_CONTEXT_ID;
} }
int32_t userId; int32_t userId;