1 /* 2 * Copyright (c) 2022 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 SAMGR_INTERFACE_INNERKITS_COMMOM_INCLUDE_PARSE_UTIL_H 17 #define SAMGR_INTERFACE_INNERKITS_COMMOM_INCLUDE_PARSE_UTIL_H 18 19 #include <list> 20 #include <map> 21 #include <set> 22 #include <string> 23 #include "sa_profiles.h" 24 #include "libxml/parser.h" 25 #include "libxml/xpath.h" 26 27 namespace OHOS { 28 class ParseUtil { 29 public: 30 ~ParseUtil(); 31 bool ParseSaProfiles(const std::string& profilePath); 32 33 const std::list<SaProfile>& GetAllSaProfiles() const; 34 bool GetProfile(int32_t saId, SaProfile& saProfile); 35 void ClearResource(); 36 void OpenSo(); 37 void CloseSo(int32_t systemAbilityId); 38 bool LoadSaLib(int32_t systemAbilityId); 39 bool ParseTrustConfig(const std::string& profilePath, std::map<std::u16string, std::set<int32_t>>& values); 40 void RemoveSaProfile(int32_t saId); 41 bool CheckPathExist(const std::string& profilePath); 42 std::u16string GetProcessName() const; 43 private: 44 void CloseSo(); 45 void OpenSo(SaProfile& saProfile); 46 void CloseHandle(SaProfile& saProfile); 47 bool ParseSystemAbility(const xmlNode& rootNode, const std::u16string& processName); 48 bool ParseProcess(const xmlNodePtr& rootNode, std::u16string& processName); 49 void ParseSAProp(const std::string& nodeName, const std::string& nodeContent, SaProfile& saProfile); 50 bool CheckRootTag(const xmlNodePtr& rootNodePtr); 51 bool ParseTrustConfigInner(const xmlNodePtr& rootNodePtr, std::map<std::u16string, std::set<int32_t>>& values); 52 bool ParseSaId(const xmlNodePtr& rootNode, int32_t& saId); 53 std::string GetRealPath(const std::string& profilePath) const; 54 std::list<SaProfile> saProfiles_; 55 std::u16string procName_; 56 }; 57 } // namespace OHOS 58 59 #endif // SAMGR_INTERFACE_INNERKITS_COMMOM_INCLUDE_PARSE_UTIL_H 60