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 IAM_RESOURCE_NODE_H 17 #define IAM_RESOURCE_NODE_H 18 19 #include <cstdint> 20 #include <memory> 21 #include <vector> 22 23 #include "co_auth_interface.h" 24 #include "executor_callback_interface.h" 25 #include "iam_common_defines.h" 26 27 namespace OHOS { 28 namespace UserIam { 29 namespace UserAuth { 30 class ResourceNode { 31 public: 32 using ExecutorRegisterInfo = CoAuthInterface::ExecutorRegisterInfo; 33 virtual ~ResourceNode() = default; 34 virtual uint64_t GetExecutorIndex() const = 0; 35 virtual std::string GetOwnerDeviceId() const = 0; 36 virtual uint32_t GetOwnerPid() const = 0; 37 virtual AuthType GetAuthType() const = 0; 38 virtual ExecutorRole GetExecutorRole() const = 0; 39 virtual uint64_t GetExecutorSensorHint() const = 0; 40 virtual uint64_t GetExecutorMatcher() const = 0; 41 virtual ExecutorSecureLevel GetExecutorEsl() const = 0; 42 virtual std::vector<uint8_t> GetExecutorPublicKey() const = 0; 43 virtual int32_t BeginExecute(uint64_t scheduleId, const std::vector<uint8_t> &publicKey, 44 const Attributes &command) = 0; 45 virtual int32_t EndExecute(uint64_t scheduleId, const Attributes &command) = 0; 46 virtual int32_t SetProperty(const Attributes &properties) = 0; 47 virtual int32_t GetProperty(const Attributes &condition, Attributes &values) = 0; 48 virtual void Detach() = 0; 49 50 static std::shared_ptr<ResourceNode> MakeNewResource(const ExecutorRegisterInfo &info, 51 const std::shared_ptr<ExecutorCallbackInterface> &callback, std::vector<uint64_t> &templateIdList, 52 std::vector<uint8_t> &fwkPublicKey); 53 }; 54 } // namespace UserAuth 55 } // namespace UserIam 56 } // namespace OHOS 57 #endif // IAM_RESOURCE_NODE_H