• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 PIN_AUTH_EXECUTOR_HDI_H
17 #define PIN_AUTH_EXECUTOR_HDI_H
18 
19 #include <cstdint>
20 #include <map>
21 #include <vector>
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 PinAuthExecutorHdi : public std::enable_shared_from_this<PinAuthExecutorHdi>,
32     public UserAuth::IAuthExecutorHdi, public NoCopyable {
33 public:
34     explicit PinAuthExecutorHdi(const sptr<HDI::PinAuth::V1_1::IExecutor> &executorProxy);
35     ~PinAuthExecutorHdi() 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 Enroll(uint64_t scheduleId, const UserAuth::EnrollParam &param,
41         const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override;
42     UserAuth::ResultCode Authenticate(uint64_t scheduleId, const UserAuth::AuthenticateParam &param,
43         const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override;
44     UserAuth::ResultCode OnSetData(uint64_t scheduleId, uint64_t authSubType, const std::vector<uint8_t> &data);
45     UserAuth::ResultCode Identify(uint64_t scheduleId, const UserAuth::IdentifyParam &param,
46         const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override;
47     UserAuth::ResultCode Delete(const std::vector<uint64_t> &templateIdList) override;
48     UserAuth::ResultCode Cancel(uint64_t scheduleId) override;
49     UserAuth::ResultCode SendCommand(UserAuth::PropertyMode commandId, const std::vector<uint8_t> &extraInfo,
50         const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override;
51     UserAuth::ResultCode GetProperty(const std::vector<uint64_t> &templateIdList,
52         const std::vector<UserAuth::Attributes::AttributeKey> &keys, UserAuth::Property &property) override;
53     UserAuth::ResultCode SetCachedTemplates(const std::vector<uint64_t> &templateIdList) override;
54 
55 private:
56     UserAuth::ResultCode MoveHdiExecutorInfo(ExecutorInfo &in, UserAuth::ExecutorInfo &out);
57     UserAuth::ResultCode MoveHdiTemplateInfo(TemplateInfo &in, UserAuth::TemplateInfo &out);
58     void MoveHdiProperty(Property &in, UserAuth::Property &out);
59     UserAuth::ResultCode ConvertCommandId(const UserAuth::PropertyMode in, CommandId &out);
60     UserAuth::ResultCode ConvertAuthType(const AuthType in, UserAuth::AuthType &out);
61     UserAuth::ResultCode ConvertExecutorRole(const ExecutorRole in, UserAuth::ExecutorRole &out);
62     UserAuth::ResultCode ConvertExecutorSecureLevel(const ExecutorSecureLevel in,
63         UserAuth::ExecutorSecureLevel &out);
64     UserAuth::ResultCode ConvertResultCode(const int32_t in);
65     UserAuth::ResultCode ConvertAttributeKeyToPropertyType(const UserAuth::Attributes::AttributeKey in,
66         GetPropertyType &out);
67     UserAuth::ResultCode ConvertAttributeKeyVectorToPropertyType(
68         const std::vector<UserAuth::Attributes::AttributeKey> inVector,
69         std::vector<GetPropertyType> &outVector);
70 
71     sptr<IExecutor> executorProxy_ { nullptr };
72 };
73 } // namespace PinAuth
74 } // namespace UserIam
75 } // namespace OHOS
76 
77 #endif // PIN_AUTH_EXECUTOR_HDI_H