1 /*
2  * Copyright (c) 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 INTERFACES_INNER_API_DLP_UTILS_H
17 #define INTERFACES_INNER_API_DLP_UTILS_H
18 
19 #include "bundle_mgr_interface.h"
20 #include "bundle_mgr_proxy.h"
21 #include "system_ability_definition.h"
22 #include "iservice_registry.h"
23 #include "os_account_manager.h"
24 #include "file_operator.h"
25 
26 namespace OHOS {
27 namespace Security {
28 namespace DlpPermission {
29 
30 static const std::string DLP_WHITELIST = "/system/etc/dlp_whitelist.json";
31 static const std::string DLP_DEFAULT_WHITELIST = "default";
32 
33 static const std::unordered_map<std::string, std::string> FILE_TYPE_MAP = {
34     {"txt", "support_txt_dlp"},
35     {"pdf", "support_pdf_dlp"},
36     {"doc", "support_office_dlp"},
37     {"docx", "support_office_dlp"},
38     {"ppt", "support_office_dlp"},
39     {"pptx", "support_office_dlp"},
40     {"xls", "support_office_dlp"},
41     {"xlsx", "support_office_dlp"},
42 };
43 
44 class DlpUtils {
45 public:
46     static sptr<AppExecFwk::IBundleMgr> GetBundleMgrProxy(void);
47     static bool GetWhitelistWithType(const std::string &cfgFile, const std::string &type,
48         std::vector<std::string> &whitelist);
49     static std::string GetFileTypeBySuffix(const std::string& suffix);
50     static std::string GetDlpFileRealSuffix(const std::string& dlpFileName);
51     static int32_t GetFileNameWithFd(const int32_t &fd, std::string &srcFileName);
52     static std::string ToLowerString(const std::string& str);
53 };
54 }  // namespace DlpPermission
55 }  // namespace Security
56 }  // namespace OHOS
57 #endif /*  INTERFACES_INNER_API_DLP_UTILS_H */
58