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