1 /* 2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_MINE_HICHAIN_CONNECTOR_H 17 #define OHOS_MINE_HICHAIN_CONNECTOR_H 18 19 #include <cstdint> 20 #include <string> 21 22 #include "device_auth.h" 23 #include "nlohmann/json.hpp" 24 #include "dm_single_instance.h" 25 #include "softbus_connector.h" 26 27 namespace OHOS { 28 namespace DistributedHardware { 29 class MineHiChainConnector { 30 public: 31 static void onFinish(int64_t requestId, int operationCode, const char *returnData); 32 static void onError(int64_t requestId, int operationCode, int errorCode, const char *errorReturn); 33 34 public: 35 MineHiChainConnector(); 36 ~MineHiChainConnector(); 37 38 /** 39 * @tc.name: MineHiChainConnector::Init 40 * @tc.desc: Init HiChain of the HiChain Connector 41 * @tc.type: FUNC 42 */ 43 int32_t Init(void); 44 45 /** 46 * @tc.name: MineHiChainConnector::UnInit 47 * @tc.desc: UnInit HiChain of the HiChain Connector 48 * @tc.type: FUNC 49 */ 50 int32_t UnInit(void); 51 52 /** 53 * @tc.name: MineHiChainConnector::DeleteCredentialAndGroup 54 * @tc.desc: Delete Credential And Group HiChain of the HiChain Connector 55 * @tc.type: FUNC 56 */ 57 58 int32_t DeleteCredentialAndGroup(void); 59 60 /** 61 * @tc.name: MineHiChainConnector::CreateGroup 62 * @tc.desc: Create Group of the HiChain Connector 63 * @tc.type: FUNC 64 */ 65 int32_t CreateGroup(const std::string &reqJsonStr); 66 67 /** 68 * @tc.name: MineHiChainConnector::RequestCredential 69 * @tc.desc: Request Credential HiChain Callback of the HiChain Connector 70 * @tc.type: FUNC 71 */ 72 int RequestCredential(std::string &returnJsonStr); 73 74 /** 75 * @tc.name: MineHiChainConnector::CheckCredential 76 * @tc.desc: Check Credential HiChain Callback of the HiChain Connector 77 * @tc.type: FUNC 78 */ 79 int CheckCredential(std::string reqJsonStr, std::string &returnJsonStr); 80 81 /** 82 * @tc.name: MineHiChainConnector::ImportCredential 83 * @tc.desc: Import Credential HiChain Callback of the HiChain Connector 84 * @tc.type: FUNC 85 */ 86 int ImportCredential(std::string reqJsonStr, std::string &returnJsonStr); 87 88 /** 89 * @tc.name: MineHiChainConnector::DeleteCredential 90 * @tc.desc: Delete Credential HiChain Callback of the HiChain Connector 91 * @tc.type: FUNC 92 */ 93 int DeleteCredential(std::string reqJsonStr, std::string &returnJsonStr); 94 95 private: 96 static bool IsCredentialExist(void); 97 }; 98 } // namespace DistributedHardware 99 } // namespace OHOS 100 #endif // OHOS_HICHAIN_CONNECTOR_H 101