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 ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_IRENDER_SERVICE_INTERFACE_CODE_ACCESS_VERIFIER_H 17 #define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_IRENDER_SERVICE_INTERFACE_CODE_ACCESS_VERIFIER_H 18 19 #include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" 20 #include "platform/ohos/rs_irender_service_ipc_interface_code.h" 21 22 namespace OHOS { 23 namespace Rosen { 24 class RSIRenderServiceInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { 25 public: 26 /* 27 * specify the enum class of the associated interface code (i.e. CodeEnumType) here 28 * note that term **CodeEnumType** should not be changed 29 */ 30 using CodeEnumType = RSIRenderServiceInterfaceCode; 31 static inline const std::string codeEnumTypeName_ {"RSIRenderServiceInterfaceCode"}; 32 33 /* specify constructor and destructor here */ 34 RSIRenderServiceInterfaceCodeAccessVerifier(); 35 ~RSIRenderServiceInterfaceCodeAccessVerifier() noexcept override = default; 36 #ifdef ENABLE_IPC_SECURITY 37 bool IsAccessTimesVerificationPassed(CodeUnderlyingType code, uint32_t times) const override; 38 #endif 39 40 protected: 41 /* specify exclusive verification rules here */ 42 bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; 43 44 private: 45 DISALLOW_COPY_AND_MOVE(RSIRenderServiceInterfaceCodeAccessVerifier); 46 #ifdef ENABLE_IPC_SECURITY 47 void AddRSIRenderServiceInterfaceCodePermission(); 48 static inline const std::vector<std::pair<CodeEnumType, PermissionType>> 49 permissionRSIRenderServiceInterfaceMappings_ {}; 50 static inline const std::unordered_map<CodeEnumType, uint32_t> accessRSIRenderServiceInterfaceTimesRestrictions_ {}; 51 #endif 52 }; 53 54 } // namespace Rosen 55 } // namespace OHOS 56 #endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_IRENDER_SERVICE_INTERFACE_CODE_ACCESS_VERIFIER_H 57