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 SERVICES_EDM_INCLUDE_EDM_PERMISSION_MANAGER_H 17 #define SERVICES_EDM_INCLUDE_EDM_PERMISSION_MANAGER_H 18 19 #include <map> 20 #include <string> 21 #include <vector> 22 #include "admin.h" 23 #include "edm_permission.h" 24 #include "singleton.h" 25 26 namespace OHOS { 27 namespace EDM { 28 struct AdminPermission { 29 std::string permissionName; 30 AdminType adminType; 31 }; 32 33 // global all permissions 34 static const AdminPermission ADMIN_PERMISSIONS[] = { 35 { "ohos.permission.EDM_TEST_PERMISSION", AdminType::NORMAL }, 36 { "ohos.permission.EDM_TEST_ENT_PERMISSION", AdminType::ENT }, 37 { "ohos.permission.ENTERPRISE_SET_DATETIME", AdminType::ENT }, 38 }; 39 40 class PermissionManager : public DelayedSingleton<PermissionManager> { 41 DECLARE_DELAYED_SINGLETON(PermissionManager) 42 public: 43 ErrCode AddPermission(const std::string &permission); 44 void GetReqPermission(const std::vector<std::string> &permissions, 45 std::vector<AdminPermission> &reqPermission); 46 void GetReqPermission(const std::vector<std::string> &permissions, 47 std::vector<EdmPermission> &reqPermission); 48 49 private: 50 std::map<std::string, AdminPermission> permissions_; 51 }; 52 } // namespace EDM 53 } // namespace OHOS 54 55 #endif // SERVICES_EDM_INCLUDE_EDM_PERMISSION_MANAGER_H 56