diff --git a/services/implementation/src/authentication/auth_message_processor.cpp b/services/implementation/src/authentication/auth_message_processor.cpp index 44294f3b08223e4921dea2b1be7a14e10366326f..c6dd61e5ca4cc558730183b66b4f48f8f2961caa 100644 --- a/services/implementation/src/authentication/auth_message_processor.cpp +++ b/services/implementation/src/authentication/auth_message_processor.cpp @@ -634,8 +634,6 @@ void AuthMessageProcessor::ParseNegotiateMessage(const JsonObject &json) } if (IsString(json, TAG_ACCOUNT_GROUPID)) { authResponseContext_->accountGroupIdHash = json[TAG_ACCOUNT_GROUPID].Get(); - } else { - authResponseContext_->accountGroupIdHash = OLD_VERSION_ACCOUNT; } if (IsString(json, TAG_HOST)) { authResponseContext_->hostPkgName = json[TAG_HOST].Get(); @@ -673,8 +671,6 @@ void AuthMessageProcessor::ParseRespNegotiateMessage(const JsonObject &json) } if (IsString(json, TAG_ACCOUNT_GROUPID)) { authResponseContext_->accountGroupIdHash = json[TAG_ACCOUNT_GROUPID].Get(); - } else { - authResponseContext_->accountGroupIdHash = OLD_VERSION_ACCOUNT; } if (IsString(json, TAG_NET_ID)) { authResponseContext_->networkId = json[TAG_NET_ID].Get(); diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 5660934f73b8f4ce6f8bbcb052dbf6b3736fca5c..04af5ce3e96edbaa88283ff274842ab512d60a84 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -984,14 +984,17 @@ void DmAuthManager::AbilityNegotiate() authResponseContext_->remoteAccountId = authResponseContext_->localAccountId; authResponseContext_->remoteUserId = authResponseContext_->localUserId; GetBinderInfo(); - bool ret = hiChainConnector_->IsDevicesInP2PGroup(authResponseContext_->localDeviceId, localDeviceId); - if (ret) { + if (hiChainConnector_->IsDevicesInP2PGroup(authResponseContext_->localDeviceId, localDeviceId) != DM_OK) { LOGE("DmAuthManager::EstablishAuthChannel device is in group"); if (!DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(authResponseContext_->hostPkgName, authResponseContext_->localDeviceId)) { CompatiblePutAcl(); } authResponseContext_->reply = ERR_DM_AUTH_PEER_REJECT; + if (!CompareVersion(remoteVersion_, std::string(DM_VERSION_5_0_3)) && + authResponseContext_->authType == AUTH_TYPE_IMPORT_AUTH_CODE && !importAuthCode_.empty()) { + authResponseContext_->importAuthCode = Crypto::Sha256(importAuthCode_); + } } else { authResponseContext_->reply = ERR_DM_AUTH_REJECT; } @@ -1970,10 +1973,6 @@ bool DmAuthManager::IsIdenticalAccount() LOGE("authResponseContext_ is nullptr."); return false; } - if (authResponseContext_->accountGroupIdHash == OLD_VERSION_ACCOUNT) { - LOGI("The old version."); - return true; - } JsonObject jsonPeerGroupIdObj(authResponseContext_->accountGroupIdHash); if (jsonPeerGroupIdObj.IsDiscarded()) { LOGE("accountGroupIdHash string not a json type."); @@ -2636,7 +2635,10 @@ void DmAuthManager::ProcRespNegotiateExt(const int32_t &sessionId) DeviceProfileConnector::GetInstance().GetBindTypeByPkgName(authResponseContext_->hostPkgName, authResponseContext_->localDeviceId, authResponseContext_->deviceId); authResponseContext_->authed = !authResponseContext_->bindType.empty(); - + if (authResponseContext_->authed && authResponseContext_->authType == AUTH_TYPE_IMPORT_AUTH_CODE && + !importAuthCode_.empty() && !CompareVersion(remoteVersion_, std::string(DM_VERSION_5_0_3))) { + authResponseContext_->importAuthCode = Crypto::Sha256(importAuthCode_); + } authResponseContext_->isIdenticalAccount = false; if (authResponseContext_->localAccountId == authResponseContext_->remoteAccountId && authResponseContext_->localAccountId != "ohosAnonymousUid" && authResponseContext_->authed) { @@ -2682,6 +2684,12 @@ void DmAuthManager::ProcRespNegotiate(const int32_t &sessionId) softbusConnector_->GetSoftbusSession()->SendData(sessionId, message); return; } + if (IsIdenticalAccount()) { + jsonObject[TAG_IDENTICAL_ACCOUNT] = true; + if (authResponseContext_->authType == AUTH_TYPE_IMPORT_AUTH_CODE && !importAuthCode_.empty()) { + jsonObject[TAG_IMPORT_AUTH_CODE] = Crypto::Sha256(importAuthCode_); + } + } jsonObject[TAG_ACCOUNT_GROUPID] = GetAccountGroupIdHash(); authResponseContext_ = authResponseState_->GetAuthContext(); if (jsonObject[TAG_CRYPTO_SUPPORT].Get() == true && authResponseContext_->cryptoSupport) { @@ -2870,12 +2878,9 @@ void DmAuthManager::HandleSessionHeartbeat(std::string name) int32_t DmAuthManager::CheckTrustState() { - bool isSameGroup = false; - if (authResponseContext_->reply == ERR_DM_AUTH_PEER_REJECT && + bool isSameGroup = (authResponseContext_->reply == ERR_DM_AUTH_PEER_REJECT && hiChainConnector_->IsDevicesInP2PGroup(authResponseContext_->localDeviceId, - authRequestContext_->localDeviceId)) { - isSameGroup = true; - } + authRequestContext_->localDeviceId)); if (isSameGroup && authResponseContext_->isOnline && authResponseContext_->authType == AUTH_TYPE_IMPORT_AUTH_CODE) { authResponseContext_->isFinish = true; SetReasonAndFinish(DM_OK, AuthState::AUTH_REQUEST_FINISH); @@ -3098,12 +3103,9 @@ int32_t DmAuthManager::GetBinderInfo() } ret = AppManager::GetInstance().GetHapTokenIdByName(authResponseContext_->localUserId, authResponseContext_->peerBundleName, 0, authResponseContext_->tokenId); -#ifndef DEVICE_MANAGER_COMMON_FLAG - if (ret == DM_OK && static_cast(authResponseContext_->bindLevel) != APP) { - LOGI("get tokenId by bundleName failed %{public}s", GetAnonyString(authResponseContext_->bundleName).c_str()); - return ERR_DM_FAILED; + if (ret != DM_OK) { + LOGE("get tokenId by bundleName failed %{public}s", GetAnonyString(authResponseContext_->bundleName).c_str()); } -#endif return ret; }