1 /* 2 * Copyright (C) 2023 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 APP_DOMAIN_VERIFY_MGR_SERVICE_H 17 #define APP_DOMAIN_VERIFY_MGR_SERVICE_H 18 19 #include "app_domain_verify_mgr_service_stub.h" 20 #include "inner_verify_status.h" 21 #include "skill_uri.h" 22 #include "system_ability.h" 23 #include "i_app_domain_verify_mgr_service.h" 24 #include "i_app_domain_verify_agent_service.h" 25 #include "app_domain_verify_data_mgr.h" 26 #include "white_list_config_mgr.h" 27 #include "permission_manager.h" 28 29 namespace OHOS { 30 namespace AppDomainVerify { 31 class AppDomainVerifyMgrService : public SystemAbility, public AppDomainVerifyMgrServiceStub { 32 DECLARE_SYSTEM_ABILITY(AppDomainVerifyMgrService); 33 34 public: 35 API_EXPORT AppDomainVerifyMgrService(); 36 API_EXPORT virtual ~AppDomainVerifyMgrService(); 37 API_EXPORT void VerifyDomain(const std::string& appIdentifier, const std::string& bundleName, 38 const std::string& fingerprint, const std::vector<SkillUri>& skillUris) override; 39 API_EXPORT bool ClearDomainVerifyStatus(const std::string& appIdentifier, const std::string& bundleName) override; 40 API_EXPORT bool FilterAbilities(const OHOS::AAFwk::Want& want, 41 const std::vector<OHOS::AppExecFwk::AbilityInfo>& originAbilityInfos, 42 std::vector<OHOS::AppExecFwk::AbilityInfo>& filtedAbilityInfos) override; 43 API_EXPORT bool QueryDomainVerifyStatus( 44 const std::string& bundleName, DomainVerifyStatus& domainVerificationState) override; 45 API_EXPORT bool QueryAllDomainVerifyStatus(BundleVerifyStatusInfo& bundleVerifyStatusInfo) override; 46 API_EXPORT bool SaveDomainVerifyStatus( 47 const std::string& bundleName, const VerifyResultInfo& verifyResultInfo) override; 48 API_EXPORT bool IsAtomicServiceUrl(const std::string& url) override; 49 API_EXPORT void ConvertToExplicitWant(OHOS::AAFwk::Want& implicitWant, sptr<IConvertCallback>& callback) override; 50 API_EXPORT void UpdateWhiteListUrls(const std::vector<std::string>& urls) override; 51 API_EXPORT int QueryAssociatedDomains(const std::string& bundleName, std::vector<std::string>& domains) override; 52 API_EXPORT int QueryAssociatedBundleNames( 53 const std::string& domain, std::vector<std::string>& bundleNames) override; 54 55 protected: 56 void OnDump() override; 57 int Dump(int fd, const std::vector<std::u16string>& args) override; 58 void OnStart() override; 59 void OnStop() override; 60 61 private: 62 void DumpAllVerifyInfos(std::string& dumpString); 63 bool IsWantImplicit(const OHOS::AAFwk::Want& want); 64 static int CheckPermission(); 65 static void CollectDomains(const std::vector<SkillUri>& skillUris, VerifyResultInfo& verifyResultInfo); 66 67 private: 68 std::shared_ptr<AppDomainVerifyDataMgr> dataManager_ = nullptr; 69 bool InitConfigMgr(); 70 std::shared_ptr<WhiteListConfigMgr> whiteListConfigMgr_; 71 std::mutex initConfigMutex_; 72 }; 73 } // namespace AppDomainVerify 74 } // namespace OHOS 75 #endif // APP_DOMAIN_VERIFY_MGR_SERVICE_H