• 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 USER_AUTH_CALLBACK_SERVICE_H
17 #define USER_AUTH_CALLBACK_SERVICE_H
18 
19 #include "iam_callback_stub.h"
20 
21 #include "iam_hitrace_helper.h"
22 #include "get_executor_property_callback_stub.h"
23 #include "set_executor_property_callback_stub.h"
24 #include "user_auth_client_callback.h"
25 #include "user_auth_modal_client_callback.h"
26 
27 namespace OHOS {
28 namespace UserIam {
29 namespace UserAuth {
30 class UserAuthCallbackService : public IamCallbackStub {
31 public:
32     explicit UserAuthCallbackService(const std::shared_ptr<AuthenticationCallback> &impl);
33     explicit UserAuthCallbackService(const std::shared_ptr<AuthenticationCallback> &impl,
34         const std::shared_ptr<UserAuthModalClientCallback> &modalCallback);
35     explicit UserAuthCallbackService(const std::shared_ptr<IdentificationCallback> &impl);
36     explicit UserAuthCallbackService(const std::shared_ptr<PrepareRemoteAuthCallback> &impl);
37     ~UserAuthCallbackService() override;
38     int32_t OnResult(int32_t resultCode, const std::vector<uint8_t> &extraInfo) override;
39     int32_t OnAcquireInfo(int32_t module, int32_t acquireInfo, const std::vector<uint8_t> &extraInfo) override;
40     int32_t CallbackEnter([[maybe_unused]] uint32_t code) override;
41     int32_t CallbackExit([[maybe_unused]] uint32_t code, [[maybe_unused]] int32_t result) override;
42 
43 private:
44     std::shared_ptr<AuthenticationCallback> authCallback_ {nullptr};
45     std::shared_ptr<UserAuthModalClientCallback> modalCallback_ {nullptr};
46     std::shared_ptr<IdentificationCallback> identifyCallback_ {nullptr};
47     std::shared_ptr<PrepareRemoteAuthCallback> prepareRemoteAuthCallback_ {nullptr};
48     std::shared_ptr<UserIam::UserAuth::IamHitraceHelper> iamHitraceHelper_ {nullptr};
49 };
50 
51 class GetExecutorPropertyCallbackService : public GetExecutorPropertyCallbackStub {
52 public:
53     explicit GetExecutorPropertyCallbackService(const std::shared_ptr<GetPropCallback> &impl);
54     ~GetExecutorPropertyCallbackService() override;
55     int32_t OnGetExecutorPropertyResult(int32_t resultCode, const std::vector<uint8_t> &attributes) override;
56     int32_t CallbackEnter([[maybe_unused]] uint32_t code) override;
57     int32_t CallbackExit([[maybe_unused]] uint32_t code, [[maybe_unused]] int32_t result) override;
58 
59 private:
60     std::shared_ptr<GetPropCallback> getPropCallback_ {nullptr};
61 };
62 
63 class SetExecutorPropertyCallbackService : public SetExecutorPropertyCallbackStub {
64 public:
65     explicit SetExecutorPropertyCallbackService(const std::shared_ptr<SetPropCallback> &impl);
66     ~SetExecutorPropertyCallbackService() override;
67     int32_t OnSetExecutorPropertyResult(int32_t resultCode) override;
68     int32_t CallbackEnter([[maybe_unused]] uint32_t code) override;
69     int32_t CallbackExit([[maybe_unused]] uint32_t code, [[maybe_unused]] int32_t result) override;
70 
71 private:
72     std::shared_ptr<SetPropCallback> setPropCallback_ {nullptr};
73 };
74 } // namespace UserAuth
75 } // namespace UserIam
76 } // namespace OHOS
77 #endif // USER_AUTH_CALLBACK_SERVICE_H