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 USER_AUTH_INTERFACE_H
17 #define USER_AUTH_INTERFACE_H
18 
19 #include <cstdint>
20 #include <optional>
21 
22 #include "iremote_broker.h"
23 #include "refbase.h"
24 
25 #include "attributes.h"
26 #include "user_auth_callback_interface.h"
27 #include "user_auth_client_callback.h"
28 #include "user_auth_interface_ipc_interface_code.h"
29 #include "widget_callback_interface.h"
30 
31 namespace OHOS {
32 namespace UserIam {
33 namespace UserAuth {
34 class UserAuthInterface : public IRemoteBroker {
35 public:
36     virtual int32_t GetAvailableStatus(int32_t apiVersion, int32_t userId, AuthType authType,
37         AuthTrustLevel authTrustLevel) = 0;
38 
39     virtual int32_t GetAvailableStatus(int32_t apiVersion, AuthType authType, AuthTrustLevel authTrustLevel) = 0;
40 
41     virtual void GetProperty(int32_t userId, AuthType authType,
42         const std::vector<Attributes::AttributeKey> &keys, sptr<GetExecutorPropertyCallbackInterface> &callback) = 0;
43 
44     virtual void GetPropertyById(uint64_t credentialId, const std::vector<Attributes::AttributeKey> &keys,
45         sptr<GetExecutorPropertyCallbackInterface> &callback) = 0;
46 
47     virtual void SetProperty(int32_t userId, AuthType authType, const Attributes &attributes,
48         sptr<SetExecutorPropertyCallbackInterface> &callback) = 0;
49 
50     virtual uint64_t AuthUser(AuthParamInner &param, std::optional<RemoteAuthParam> &remoteAuthParam,
51         sptr<UserAuthCallbackInterface> &callback) = 0;
52 
53     virtual uint64_t Auth(int32_t apiVersion, const std::vector<uint8_t> &challenge, AuthType authType,
54         AuthTrustLevel authTrustLevel, sptr<UserAuthCallbackInterface> &callback) = 0;
55 
56     virtual uint64_t AuthWidget(int32_t apiVersion, const AuthParamInner &authParam,
57         const WidgetParam &widgetParam, sptr<UserAuthCallbackInterface> &callback) = 0;
58 
59     virtual uint64_t Identify(const std::vector<uint8_t> &challenge, AuthType authType,
60         sptr<UserAuthCallbackInterface> &callback) = 0;
61 
62     virtual int32_t CancelAuthOrIdentify(uint64_t contextId) = 0;
63 
64     virtual int32_t GetVersion(int32_t &version) = 0;
65 
66     virtual int32_t Notice(NoticeType noticeType, const std::string &eventData) = 0;
67 
68     virtual int32_t RegisterWidgetCallback(int32_t version, sptr<WidgetCallbackInterface> &callback) = 0;
69 
70     virtual int32_t GetEnrolledState(int32_t apiVersion, AuthType authType, EnrolledState &enrolledState) = 0;
71 
72     virtual int32_t RegistUserAuthSuccessEventListener(const std::vector<AuthType> &authType,
73         const sptr<AuthEventListenerInterface> &listener) = 0;
74 
75     virtual int32_t UnRegistUserAuthSuccessEventListener(
76         const sptr<AuthEventListenerInterface> &listener) = 0;
77 
78     virtual int32_t SetGlobalConfigParam(const GlobalConfigParam &param) = 0;
79 
80     virtual int32_t PrepareRemoteAuth(const std::string &networkId, sptr<UserAuthCallbackInterface> &callback) = 0;
81 
82     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.UserIam.UserAuth.IUserAuth");
83 };
84 } // namespace UserAuth
85 } // namespace UserIam
86 } // namespace OHOS
87 #endif // USER_AUTH_INTERFACE_H