• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025-2025 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 ANTIFRAUD_CLOUD_SERVICE_H
17 #define ANTIFRAUD_CLOUD_SERVICE_H
18 
19 #include <map>
20 #include <mutex>
21 #include <string>
22 
23 #include "anti_fraud_service_client_type.h"
24 #include "antifraud_hsdr_helper.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 class AntiFraudCloudService : public std::enable_shared_from_this<AntiFraudCloudService> {
29 public:
30     explicit AntiFraudCloudService(const std::string &phoneNum);
31     bool UploadPostRequest(const OHOS::AntiFraudService::AntiFraudResult &antiFraudResult);
32 private:
33     bool isSettled_ = false;
34     std::string phoneNum_;
35     std::mutex mutex_;
36     std::condition_variable cv_;
37     std::pair<std::string, std::string> EncryptSync(const std::string &metaData, sptr<IRemoteObject> remoteObject);
38     std::pair<std::string, std::string> ProcessEncryptResult(const std::string &encryptResult);
39     std::string GenerateRequestJson(const std::map<std::string, std::string> &headersMap, const std::string &body);
40     std::string GetAuthSync(const std::string &metaData, const std::string &ak, sptr<IRemoteObject> remoteObject);
41     std::string GenerateUcsRequestBody(UcsMethod code, const std::string &requestData);
42     std::string EncodeBase64(const std::string &src);
43     std::string GeneratePayload(const OHOS::AntiFraudService::AntiFraudResult &antiFraudResult);
44     std::string GetRomVersion();
45     std::string GetSubstringBeforeSymbol(const std::string &str, const std::string &symbol);
46     std::string GetDeviceSerial();
47     std::string CalculateDigest(const std::string &payload);
48     std::string GetOsVersion();
49     std::string GenerateRandomString(size_t length);
50     std::string ProcessSignResult(const std::string &signResult);
51     uint64_t GenerateRandomLong();
52     bool ConnectCloudAsync(const std::string &metaData, const std::string &auth,
53         const OHOS::AntiFraudService::AntiFraudResult &antiFraudResult, sptr<IRemoteObject> remoteObject);
54     std::map<std::string, std::string> GenerateHeadersMap(const std::string &auth, const std::string &fileContent,
55         const std::string &boundary);
56 };
57 } // namespace Telephony
58 } // namespace OHOS
59 #endif