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