• 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 FACE_AUTH_EXECUTOR_HDI_H
17 #define FACE_AUTH_EXECUTOR_HDI_H
18 
19 #include <cstdint>
20 #include <map>
21 #include <vector>
22 
23 #include "nocopyable.h"
24 
25 #include "ibuffer_producer.h"
26 
27 #include "framework_types.h"
28 #include "iauth_executor_hdi.h"
29 #include "iexecute_callback.h"
30 #include "v1_0/iexecutor.h"
31 
32 namespace OHOS {
33 namespace UserIam {
34 namespace FaceAuth {
35 namespace FaceHdi = OHOS::HDI::FaceAuth::V1_0;
36 namespace UserAuth = OHOS::UserIam::UserAuth;
37 class FaceAuthExecutorHdi : public UserAuth::IAuthExecutorHdi, public NoCopyable {
38 public:
39     explicit FaceAuthExecutorHdi(sptr<FaceHdi::IExecutor> executorProxy);
40     ~FaceAuthExecutorHdi() override = default;
41 
42     UserIam::UserAuth::ResultCode GetExecutorInfo(UserIam::UserAuth::ExecutorInfo &info) override;
43     UserIam::UserAuth::ResultCode GetTemplateInfo(uint64_t templateId, UserAuth::TemplateInfo &info) override;
44     UserIam::UserAuth::ResultCode OnRegisterFinish(const std::vector<uint64_t> &templateIdList,
45         const std::vector<uint8_t> &frameworkPublicKey, const std::vector<uint8_t> &extraInfo) override;
46     UserIam::UserAuth::ResultCode Enroll(uint64_t scheduleId, uint32_t tokenId, const std::vector<uint8_t> &extraInfo,
47         const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override;
48     UserIam::UserAuth::ResultCode Authenticate(uint64_t scheduleId, uint32_t tokenId,
49         const std::vector<uint64_t> &templateIdList, const std::vector<uint8_t> &extraInfo,
50         const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override;
51     UserIam::UserAuth::ResultCode Identify(uint64_t scheduleId, uint32_t tokenId, const std::vector<uint8_t> &extraInfo,
52         const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override;
53     UserIam::UserAuth::ResultCode Delete(const std::vector<uint64_t> &templateIdList) override;
54     UserIam::UserAuth::ResultCode Cancel(uint64_t scheduleId) override;
55     UserIam::UserAuth::ResultCode SendCommand(UserIam::UserAuth::PropertyMode commandId,
56         const std::vector<uint8_t> &extraInfo, const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override;
57     int32_t SetBufferProducer(sptr<IBufferProducer> &producer);
58 
59 private:
60     UserIam::UserAuth::ResultCode MoveHdiExecutorInfo(FaceHdi::ExecutorInfo &in, UserIam::UserAuth::ExecutorInfo &out);
61     void MoveHdiTemplateInfo(FaceHdi::TemplateInfo &in, UserAuth::TemplateInfo &out);
62     UserIam::UserAuth::ResultCode ConvertCommandId(const UserIam::UserAuth::PropertyMode in, FaceHdi::CommandId &out);
63     UserIam::UserAuth::ResultCode ConvertAuthType(const FaceHdi::AuthType in, UserIam::UserAuth::AuthType &out);
64     UserIam::UserAuth::ResultCode ConvertExecutorRole(
65         const FaceHdi::ExecutorRole in, UserIam::UserAuth::ExecutorRole &out);
66     UserIam::UserAuth::ResultCode ConvertExecutorSecureLevel(
67         const FaceHdi::ExecutorSecureLevel in, UserIam::UserAuth::ExecutorSecureLevel &out);
68     UserIam::UserAuth::ResultCode ConvertResultCode(const int32_t in);
69 
70     sptr<FaceHdi::IExecutor> executorProxy_;
71 };
72 } // namespace FaceAuth
73 } // namespace UserIam
74 } // namespace OHOS
75 
76 #endif // FACE_AUTH_EXECUTOR_HDI_H