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