remote auth project

Change-Id: Ie4ff86b09d448a605ae58a6673d5d59ffa5732b8
Signed-off-by: Tianshi Liu <tianshi.liu@huawei.com>
This commit is contained in:
Tianshi Liu 2024-05-11 16:24:21 +08:00
parent 6abef62e2d
commit ae25ffd0f4
6 changed files with 21 additions and 18 deletions

View File

@ -172,9 +172,10 @@ void RemoteAuthContext::StartAuthDelayed()
bool ret = StartAuth();
if (!ret) {
IAM_LOGE("StartAuth failed");
IAM_LOGE("StartAuth failed, latest error %{public}d", GetLatestError());
Attributes attr;
callback_->OnResult(GENERAL_ERROR, attr);
callback_->OnResult(GetLatestError(), attr);
return;
}
IAM_LOGI("success");
}

View File

@ -250,9 +250,9 @@ bool RemoteAuthInvokerContext::SendRequest()
IF_FALSE_LOGE_AND_RETURN(getResultCodeRet);
if (resultCode != ResultCode::SUCCESS) {
IAM_LOGE("start remote auth failed");
IAM_LOGE("start remote auth failed %{public}d", resultCode);
Attributes attr;
callback_->OnResult(ResultCode::GENERAL_ERROR, attr);
callback_->OnResult(resultCode, attr);
return;
}

View File

@ -130,12 +130,10 @@ void RemoteAuthServiceImpl::OnMessage(const std::string &connectionName, const s
break;
}
IF_FALSE_LOGE_AND_RETURN(resultCode == ResultCode::SUCCESS);
bool setResultCodeRet = reply->SetInt32Value(Attributes::ATTR_RESULT_CODE, ResultCode::SUCCESS);
bool setResultCodeRet = reply->SetInt32Value(Attributes::ATTR_RESULT_CODE, resultCode);
IF_FALSE_LOGE_AND_RETURN(setResultCodeRet);
IAM_LOGI("success");
IAM_LOGI("success, msg result %{public}d", resultCode);
}
int32_t RemoteAuthServiceImpl::ProcStartRemoteAuthRequest(std::string connectionName,

View File

@ -91,7 +91,7 @@ private:
ResultCode &failReason);
uint64_t StartRemoteAuthContext(Authentication::AuthenticationPara para,
RemoteAuthContextParam remoteAuthContextParam,
const std::shared_ptr<ContextCallback> &contextCallback);
const std::shared_ptr<ContextCallback> &contextCallback, int &lastError);
uint64_t StartRemoteAuthInvokerContext(AuthParamInner authParam,
RemoteAuthInvokerContextParam &param, const std::shared_ptr<ContextCallback> &contextCallback);
bool Insert2ContextPool(const std::shared_ptr<Context> &context);

View File

@ -123,8 +123,9 @@ uint64_t CoAuthService::ExecutorRegister(const ExecutorRegisterInfo &info, sptr<
uint64_t executorIndex = resourceNode->GetExecutorIndex();
executorCallback->OnMessengerReady(executorIndex, messenger, fwkPublicKey, templateIdList);
int32_t executorType = resourceNode->GetAuthType();
IAM_LOGI("register successful, executorType is %{public}d, executorIndex is ****%{public}hx",
executorType, static_cast<uint16_t>(executorIndex));
IAM_LOGI("register successful, executorType is %{public}d, executorRole is %{public}d, "
"executorIndex is ****%{public}hx",
executorType, resourceNode->GetExecutorRole(), static_cast<uint16_t>(executorIndex));
if (auto obj = executorCallback->AsObject(); obj) {
obj->AddDeathRecipient(new (std::nothrow) IpcCommon::PeerDeathRecipient([executorIndex, executorType]() {
auto result = ResourceNodePool::Instance().Delete(executorIndex);

View File

@ -422,7 +422,8 @@ uint64_t UserAuthService::StartAuthContext(int32_t apiVersion, Authentication::A
}
uint64_t UserAuthService::StartRemoteAuthContext(Authentication::AuthenticationPara para,
RemoteAuthContextParam remoteAuthContextParam, const std::shared_ptr<ContextCallback> &contextCallback)
RemoteAuthContextParam remoteAuthContextParam, const std::shared_ptr<ContextCallback> &contextCallback,
int &lastError)
{
IAM_LOGI("start");
Attributes extraInfo;
@ -436,11 +437,11 @@ uint64_t UserAuthService::StartRemoteAuthContext(Authentication::AuthenticationP
contextCallback->SetCleaner(ContextHelper::Cleaner(context));
if (!context->Start()) {
int32_t errorCode = context->GetLatestError();
IAM_LOGE("failed to start auth errorCode:%{public}d", errorCode);
contextCallback->OnResult(errorCode, extraInfo);
lastError = context->GetLatestError();
IAM_LOGE("failed to start auth errorCode:%{public}d", lastError);
return BAD_CONTEXT_ID;
}
lastError = SUCCESS;
IAM_LOGI("success");
return context->GetContextId();
}
@ -630,8 +631,9 @@ uint64_t UserAuthService::AuthRemoteUser(AuthParamInner &authParam, Authenticati
remoteAuthContextParam.connectionName = "";
remoteAuthContextParam.collectorNetworkId = remoteAuthParam.collectorNetworkId.value();
remoteAuthContextParam.executorInfoMsg = {};
int32_t dummyLastError = 0;
IAM_LOGI("start remote auth context");
return StartRemoteAuthContext(para, remoteAuthContextParam, contextCallback);
return StartRemoteAuthContext(para, remoteAuthContextParam, contextCallback, dummyLastError);
}
uint64_t UserAuthService::Identify(const std::vector<uint8_t> &challenge, AuthType authType,
@ -1228,8 +1230,9 @@ int32_t UserAuthService::ProcStartRemoteAuthRequest(std::string connectionName,
auto contextCallback = ContextCallback::NewInstance(callback, NO_NEED_TRACE);
IF_FALSE_LOGE_AND_RETURN_VAL(contextCallback != nullptr, GENERAL_ERROR);
auto contextId = StartRemoteAuthContext(para, remoteAuthContextParam, contextCallback);
IF_FALSE_LOGE_AND_RETURN_VAL(contextId != BAD_CONTEXT_ID, GENERAL_ERROR);
int32_t lastError;
auto contextId = StartRemoteAuthContext(para, remoteAuthContextParam, contextCallback, lastError);
IF_FALSE_LOGE_AND_RETURN_VAL(contextId != BAD_CONTEXT_ID, lastError);
bool setContextIdRet = reply->SetUint64Value(Attributes::ATTR_CONTEXT_ID, contextId);
IF_FALSE_LOGE_AND_RETURN_VAL(setContextIdRet, GENERAL_ERROR);