• 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_SERVICE_H
17 #define USER_IDM_SERVICE_H
18 
19 #include "user_idm_stub.h"
20 
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 #include "system_ability.h"
26 #include "system_ability_definition.h"
27 
28 #include "context.h"
29 
30 namespace OHOS {
31 namespace UserIam {
32 namespace UserAuth {
33 class UserIdmService : public SystemAbility, public UserIdmStub, public NoCopyable {
34 public:
35     DECLARE_SYSTEM_ABILITY(UserIdmService);
36     explicit UserIdmService(int32_t systemAbilityId, bool runOnCreate = false);
37     ~UserIdmService() override = default;
38     void OnStart() override;
39     void OnStop() override;
40     int Dump(int fd, const std::vector<std::u16string> &args) override;
41     int32_t OpenSession(int32_t userId, std::vector<uint8_t> &challenge) override;
42     void CloseSession(int32_t userId) override;
43     int32_t GetCredentialInfo(int32_t userId, AuthType authType,
44         const sptr<IdmGetCredInfoCallbackInterface> &callback) override;
45     int32_t GetSecInfo(int32_t userId, const sptr<IdmGetSecureUserInfoCallbackInterface> &callback) override;
46     void AddCredential(int32_t userId, const CredentialPara &credPara,
47         const sptr<IdmCallbackInterface> &callback, bool isUpdate) override;
48     void UpdateCredential(int32_t userId, const CredentialPara &credPara,
49         const sptr<IdmCallbackInterface> &callback) override;
50     int32_t Cancel(int32_t userId) override;
51     int32_t EnforceDelUser(int32_t userId, const sptr<IdmCallbackInterface> &callback) override;
52     void DelUser(int32_t userId, const std::vector<uint8_t> authToken,
53         const sptr<IdmCallbackInterface> &callback) override;
54     void DelCredential(int32_t userId, uint64_t credentialId, const std::vector<uint8_t> &authToken,
55         const sptr<IdmCallbackInterface> &callback) override;
56 
57 private:
58     int32_t CancelCurrentEnroll();
59     void CancelCurrentEnrollIfExist();
60     std::mutex mutex_;
61 };
62 } // namespace UserAuth
63 } // namespace UserIam
64 } // namespace OHOS
65 #endif // USER_IDM_SERVICE_H