diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 39988888..1ef1c554 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -152,6 +152,7 @@ const int32_t LOCAL_CREDENTIAL_DEAL_TYPE = 1; const int32_t REMOTE_CREDENTIAL_DEAL_TYPE = 2; const int32_t NONSYMMETRY_CREDENTIAL_TYPE = 2; const int32_t SYMMETRY_CREDENTIAL_TYPE = 1; +const int32_t UNKNOWN_CREDENTIAL_TYPE = 0; // Softbus const int32_t SOFTBUS_CHECK_INTERVAL = 100000; // 100ms const uint32_t SOFTBUS_SUBSCRIBE_ID_PREFIX_LEN = 16; diff --git a/services/implementation/include/dependency/hichain/hichain_connector.h b/services/implementation/include/dependency/hichain/hichain_connector.h index c737fbf4..f3dcd1e3 100644 --- a/services/implementation/include/dependency/hichain/hichain_connector.h +++ b/services/implementation/include/dependency/hichain/hichain_connector.h @@ -180,14 +180,14 @@ public: * @tc.desc: Get RegisterInfo Info of the HiChain Connector * @tc.type: FUNC */ - int32_t addMultiMembers(const int32_t groupType, const std::string userId, const nlohmann::json &jsonDeviceList); + int32_t addMultiMembers(const int32_t groupType, const std::string &userId, const nlohmann::json &jsonDeviceList); /** * @tc.name: HiChainConnector::deleteMultiMembers * @tc.desc: Get RegisterInfo Info of the HiChain Connector * @tc.type: FUNC */ - int32_t deleteMultiMembers(const int32_t groupType, const std::string userId, const nlohmann::json &jsonDeviceList); + int32_t deleteMultiMembers(const int32_t groupType, const std::string &userId, const nlohmann::json &jsonDeviceList); private: int64_t GenRequestId(); int32_t SyncGroups(std::string deviceId, std::vector &remoteGroupIdList); @@ -200,7 +200,7 @@ private: bool IsGroupInfoInvalid(GroupInfo &group); int32_t GetStrFieldByType(const std::string &reqJsonStr, const std::string &outField, int32_t type); int32_t GetNumsFieldByType(const std::string &reqJsonStr, int32_t &outField, int32_t type); - int32_t GetGroupId(const std::string userId, const int32_t groupType, std::string &groupId); + int32_t GetGroupId(const std::string &userId, const int32_t groupType, std::string &groupId); private: const DeviceGroupManager *deviceGroupManager_ = nullptr; DeviceAuthCallback deviceAuthCallback_; diff --git a/services/implementation/src/credential/dm_credential_manager.cpp b/services/implementation/src/credential/dm_credential_manager.cpp index d9a75abf..5c3b00d7 100644 --- a/services/implementation/src/credential/dm_credential_manager.cpp +++ b/services/implementation/src/credential/dm_credential_manager.cpp @@ -33,7 +33,7 @@ struct CredentialDataInfo { std::string authCode; std::string peerDeviceId; std::string userId; - CredentialDataInfo() : credentialType(0) + CredentialDataInfo() : credentialType(UNKNOWN_CREDENTIAL_TYPE) { } }; @@ -289,7 +289,7 @@ int32_t DmCredentialManager::GetCredentialData(const std::string &credentialInfo void from_json(const nlohmann::json &jsonObject, CredentialDataInfo &credentialDataInfo) { if (!jsonObject.contains(FIELD_CREDENTIAL_TYPE)) { - LOGE("credentialType json key Not exist"); + LOGE("credentialType json key not exist"); return; } jsonObject[FIELD_CREDENTIAL_TYPE].get_to(credentialDataInfo.credentialType); @@ -311,6 +311,9 @@ void from_json(const nlohmann::json &jsonObject, CredentialDataInfo &credentialD if (jsonObject.contains(FIELD_AUTH_CODE)) { jsonObject[FIELD_AUTH_CODE].get_to(credentialDataInfo.authCode); } + } eles { + LOGE("credentialType john key is unknown"); + return; } if (jsonObject.contains(FIELD_PEER_DEVICE_ID)) { jsonObject[FIELD_PEER_DEVICE_ID].get_to(credentialDataInfo.peerDeviceId); @@ -400,7 +403,6 @@ int32_t DmCredentialManager::ImportRemoteCredential(const std::string &credentia LOGE("failed to add members to group."); return ERR_DM_FAILED; } - LOGI("ImportRemoteCredential complete!"); return DM_OK; } diff --git a/services/implementation/src/dependency/hichain/hichain_connector.cpp b/services/implementation/src/dependency/hichain/hichain_connector.cpp index ff76d5fa..c84baca0 100644 --- a/services/implementation/src/dependency/hichain/hichain_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_connector.cpp @@ -754,7 +754,7 @@ int32_t HiChainConnector::getRegisterInfo(const std::string &queryParams, std::s return DM_OK; } -int32_t HiChainConnector::GetGroupId(const std::string userId, const int32_t groupType, std::string &groupId) +int32_t HiChainConnector::GetGroupId(const std::string &userId, const int32_t groupType, std::string &groupId) { nlohmann::json jsonObjGroup; jsonObjGroup[FIELD_GROUP_TYPE] = groupType; @@ -775,25 +775,22 @@ int32_t HiChainConnector::GetGroupId(const std::string userId, const int32_t gro return DM_OK; } -int32_t HiChainConnector::addMultiMembers(const int32_t groupType, const std::string userId, +int32_t HiChainConnector::addMultiMembers(const int32_t groupType, const std::string &userId, const nlohmann::json &jsonDeviceList) { if (deviceGroupManager_ == nullptr) { LOGE("HiChainConnector::deviceGroupManager_ is nullptr."); return ERR_DM_INPUT_PARAMETER_EMPTY; } - LOGI("addMultiMembers in!"); if (userId.empty() || !jsonDeviceList.contains(FIELD_DEVICE_LIST)) { LOGE("userId or deviceList is empty"); return ERR_DM_INPUT_PARAMETER_EMPTY; } std::string groupId; - LOGI("GetGroupId before!"); if (GetGroupId(userId, groupType, groupId) != DM_OK) { LOGE("failed to get groupid"); return ERR_DM_FAILED; } - LOGI("GetGroupId end!"); std::string appId = DM_PKG_NAME; nlohmann::json jsonObj; jsonObj[FIELD_GROUP_ID] = groupId; @@ -814,7 +811,7 @@ int32_t HiChainConnector::addMultiMembers(const int32_t groupType, const std::st return DM_OK; } -int32_t HiChainConnector::deleteMultiMembers(const int32_t groupType, const std::string userId, +int32_t HiChainConnector::deleteMultiMembers(const int32_t groupType, const std::string &userId, const nlohmann::json &jsonDeviceList) { if (deviceGroupManager_ == nullptr) {