• 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 USERIDM_SERVICE_H
17 #define USERIDM_SERVICE_H
18 
19 #include <map>
20 #include <iremote_stub.h>
21 #include <system_ability.h>
22 #include <system_ability_definition.h>
23 #include <string>
24 #include "useridm_stub.h"
25 #include "useridm_hilog_wrapper.h"
26 #include "useridm_controller.h"
27 #include "iuser_idm.h"
28 
29 namespace OHOS {
30 namespace UserIAM {
31 namespace UserIDM {
32 class UserIDMService : public SystemAbility, public UserIDMStub {
33 public:
34     DECLARE_SYSTEM_ABILITY(UserIDMService);
35     explicit UserIDMService(int32_t systemAbilityId, bool runOnCreate = false);
36     ~UserIDMService() override;
37     void OnStart() override;
38     void OnStop() override;
39     uint64_t OpenSession() override;
40     void CloseSession() override;
41     int32_t GetAuthInfo(AuthType authType, const sptr<IGetInfoCallback>& callback) override;
42     int32_t GetAuthInfo(int32_t userId, AuthType authType, const sptr<IGetInfoCallback>& callback) override;
43     int32_t GetSecInfo(int32_t userId, const sptr<IGetSecInfoCallback>& callback) override;
44     void AddCredential(AddCredInfo& credInfo, const sptr<IIDMCallback>& callback) override;
45     void UpdateCredential(AddCredInfo& credInfo, const sptr<IIDMCallback>& callback) override;
46     int32_t Cancel(uint64_t challenge) override;
47     int32_t EnforceDelUser(int32_t userId, const sptr<IIDMCallback>& callback) override;
48     void DelUser(std::vector<uint8_t> authToken, const sptr<IIDMCallback>& callback) override;
49     void DelCred(uint64_t credentialId, std::vector<uint8_t> authToken, const sptr<IIDMCallback>& callback) override;
50 
51 private:
52     int32_t GetCallingUserId(int32_t &userId);
53     bool CheckPermission(const std::string &permission);
54 
55     UserIDMController idmController_;
56 };
57 }  // namespace UserIDM
58 }  // namespace UserIAM
59 }  // namespace OHOS
60 #endif // USERIDM_SERVICE_H
61