mirror of
https://github.com/openharmony/device_manager.git
synced 2026-07-01 21:44:51 -04:00
[需求]凭据管理远端功能开发
Signed-off-by: @shi-xiaoxiao-iris <shixiaoxiao2@huawei.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<std::string> &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_;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user