1 /* 2 * Copyright (c) 2022-2024 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 PIN_AUTH_ALL_IN_ONE_HDI_H 17 #define PIN_AUTH_ALL_IN_ONE_HDI_H 18 19 #include <cstdint> 20 #include <vector> 21 22 #include "iam_executor_framework_types.h" 23 #include "iam_executor_iauth_executor_hdi.h" 24 #include "iam_executor_iexecute_callback.h" 25 #include "nocopyable.h" 26 #include "pin_auth_hdi.h" 27 28 namespace OHOS { 29 namespace UserIam { 30 namespace PinAuth { 31 class PinAuthAllInOneHdi : public std::enable_shared_from_this<PinAuthAllInOneHdi>, 32 public UserAuth::IAuthExecutorHdi, public NoCopyable { 33 public: 34 explicit PinAuthAllInOneHdi(const sptr<IAllInOneExecutor> &allInOneProxy); 35 ~PinAuthAllInOneHdi() override = default; 36 37 UserAuth::ResultCode GetExecutorInfo(UserAuth::ExecutorInfo &info) override; 38 UserAuth::ResultCode OnRegisterFinish(const std::vector<uint64_t> &templateIdList, 39 const std::vector<uint8_t> &frameworkPublicKey, const std::vector<uint8_t> &extraInfo) override; 40 UserAuth::ResultCode SendMessage(uint64_t scheduleId, int32_t srcRole, const std::vector<uint8_t> &msg) override; 41 UserAuth::ResultCode Enroll(uint64_t scheduleId, const UserAuth::EnrollParam ¶m, 42 const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override; 43 UserAuth::ResultCode Authenticate(uint64_t scheduleId, const UserAuth::AuthenticateParam ¶m, 44 const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override; 45 UserAuth::ResultCode OnSetData(uint64_t scheduleId, uint64_t authSubType, const std::vector<uint8_t> &data, 46 int32_t errorCode); 47 UserAuth::ResultCode Delete(const std::vector<uint64_t> &templateIdList) override; 48 UserAuth::ResultCode Cancel(uint64_t scheduleId) override; 49 UserAuth::ResultCode GetProperty(const std::vector<uint64_t> &templateIdList, 50 const std::vector<UserAuth::Attributes::AttributeKey> &keys, UserAuth::Property &property) override; 51 52 private: 53 void MoveHdiProperty(Property &in, UserAuth::Property &out); 54 UserAuth::ResultCode ConvertAttributeKeyToPropertyType(const UserAuth::Attributes::AttributeKey in, int32_t &out); 55 UserAuth::ResultCode ConvertAttributeKeyVectorToPropertyType( 56 const std::vector<UserAuth::Attributes::AttributeKey> inVector, 57 std::vector<int32_t> &outVector); 58 59 sptr<IAllInOneExecutor> allInOneProxy_ {nullptr}; 60 }; 61 } // namespace PinAuth 62 } // namespace UserIam 63 } // namespace OHOS 64 65 #endif // PIN_AUTH_ALL_IN_ONE_HDI_H