• 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_IDM_INTERFACE_H
17 #define USER_IDM_INTERFACE_H
18 
19 #include <cstdint>
20 
21 #include "refbase.h"
22 #include "user_idm_callback_interface.h"
23 
24 namespace OHOS {
25 namespace UserIam {
26 namespace UserAuth {
27 class UserIdmInterface : public IRemoteBroker {
28 public:
29     enum : uint32_t {
30         USER_IDM_OPEN_SESSION = 0,
31         USER_IDM_CLOSE_SESSION,
32         USER_IDM_GET_CRED_INFO,
33         USER_IDM_GET_SEC_INFO,
34         USER_IDM_ADD_CREDENTIAL,
35         USER_IDM_UPDATE_CREDENTIAL,
36         USER_IDM_CANCEL,
37         USER_IDM_ENFORCE_DEL_USER,
38         USER_IDM_DEL_USER,
39         USER_IDM_DEL_CRED,
40     };
41 
42     struct CredentialPara {
43         AuthType authType {ALL};
44         PinSubType pinType {PIN_SIX};
45         std::vector<uint8_t> token;
46     };
47 
48     /*
49      * start an IDM operation to obtain challenge value, a challenge value of 0 indicates that open session failed.
50      *
51      * param userId user id.
52      * return challenge value.
53      */
54     virtual int32_t OpenSession(int32_t userId, std::vector<uint8_t> &challenge) = 0;
55 
56     /*
57      * end an IDM operation.
58      *
59      * param userId user id.
60      */
61     virtual void CloseSession(int32_t userId) = 0;
62 
63     /*
64      * get authentication information.
65      *
66      * param userId current user id.
67      * param authType credential type.
68      * param callback returns all registered credential information of this type for the specific user.
69      */
70     virtual int32_t GetCredentialInfo(int32_t userId, AuthType authType,
71         const sptr<IdmGetCredInfoCallbackInterface> &callback) = 0;
72 
73     /*
74      * get user security ID.
75      *
76      * param userId current user id.
77      * param callback returns all registered security information for the specific user.
78      */
79     virtual int32_t GetSecInfo(int32_t userId, const sptr<IdmGetSecureUserInfoCallbackInterface> &callback) = 0;
80 
81     /**
82      * add user credential information, pass in credential addition method and credential information
83      * (credential type, subtype, if adding user's non password credentials, pass in password authentication token),
84      * and get the result / acquire info callback.
85      *
86      * param userId user id.
87      * param credInfo Incoming credential addition method and credential information
88      * (credential type, subtype, password authentication token).
89      * param callback get results / acquire info callback.
90      */
91     virtual void AddCredential(int32_t userId, const CredentialPara &credPara,
92         const sptr<IdmCallbackInterface> &callback, bool isUpdate) = 0;
93     /*
94      * update user credential information.
95      *
96      * param userId user id.
97      * param credInfo Incoming credential addition method and credential information
98      * (credential type, subtype, password authentication token).
99      * param callback update results / acquire info callback.
100      */
101     virtual void UpdateCredential(int32_t userId, const CredentialPara &credPara,
102         const sptr<IdmCallbackInterface> &callback) = 0;
103 
104     /*
105      * Cancel entry and pass in user id.
106      *
107      * param userId user id.
108      */
109     virtual int32_t Cancel(int32_t userId) = 0;
110 
111     /*
112      * enforce delete the user credential information, pass in the callback,
113      * and obtain the deletion result through the callback.
114      *
115      * param authToken user password authentication token.
116      * param callback get deletion result through callback.
117      */
118     virtual int32_t EnforceDelUser(int32_t userId, const sptr<IdmCallbackInterface> &callback) = 0;
119 
120     /*
121      * delete all users credential information, pass in the user password authentication token and callback,
122      * and obtain the deletion result through the callback.
123      *
124      * param userId user id.
125      * param authToken user password authentication token.
126      * param callback get deletion result through callback.
127      */
128     virtual void DelUser(int32_t userId, const std::vector<uint8_t> authToken,
129         const sptr<IdmCallbackInterface> &callback) = 0;
130 
131     /*
132      * delete the user credential information, pass in the credential id, password authentication token and callback,
133      * and obtain the deletion result through the callback.
134      * Only deleting non password credentials is supported.
135      *
136      * param userId user id.
137      * param credentialId credential index.
138      * param authToken password authentication token.
139      * param callback get deletion result through callback.
140      */
141     virtual void DelCredential(int32_t userId, uint64_t credentialId,
142         const std::vector<uint8_t> &authToken, const sptr<IdmCallbackInterface> &callback) = 0;
143     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.useridm.IUserIDM");
144 };
145 } // namespace UserAuth
146 } // namespace UserIam
147 } // namespace OHOS
148 #endif // USER_IDM_INTERFACE_H