1 /*
2 * Copyright (c) 2022-2023 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 #include "domain_account_manager_service.h"
17
18 #include "account_log_wrapper.h"
19 #include "inner_domain_account_manager.h"
20
21 namespace OHOS {
22 namespace AccountSA {
23 namespace {
24 constexpr int32_t START_USER_ID = 100;
25 }
26
DomainAccountManagerService()27 DomainAccountManagerService::DomainAccountManagerService()
28 {}
29
~DomainAccountManagerService()30 DomainAccountManagerService::~DomainAccountManagerService()
31 {}
32
RegisterPlugin(const sptr<IDomainAccountPlugin> & plugin)33 ErrCode DomainAccountManagerService::RegisterPlugin(const sptr<IDomainAccountPlugin> &plugin)
34 {
35 return InnerDomainAccountManager::GetInstance().RegisterPlugin(plugin);
36 }
37
UnregisterPlugin()38 ErrCode DomainAccountManagerService::UnregisterPlugin()
39 {
40 InnerDomainAccountManager::GetInstance().UnregisterPlugin();
41 return ERR_OK;
42 }
43
HasDomainAccount(const DomainAccountInfo & info,const sptr<IDomainAccountCallback> & callback)44 ErrCode DomainAccountManagerService::HasDomainAccount(
45 const DomainAccountInfo &info, const sptr<IDomainAccountCallback> &callback)
46 {
47 return InnerDomainAccountManager::GetInstance().HasDomainAccount(info, callback);
48 }
49
GetAccessToken(const DomainAccountInfo & info,const AAFwk::WantParams & parameters,const sptr<IDomainAccountCallback> & callback)50 ErrCode DomainAccountManagerService::GetAccessToken(
51 const DomainAccountInfo &info, const AAFwk::WantParams ¶meters, const sptr<IDomainAccountCallback> &callback)
52 {
53 return InnerDomainAccountManager::GetInstance().GetAccessToken(info, parameters, callback);
54 }
55
UpdateAccountToken(const DomainAccountInfo & info,const std::vector<uint8_t> & token)56 ErrCode DomainAccountManagerService::UpdateAccountToken(
57 const DomainAccountInfo &info, const std::vector<uint8_t> &token)
58 {
59 return InnerDomainAccountManager::GetInstance().UpdateAccountToken(info, token);
60 }
61
Auth(const DomainAccountInfo & info,const std::vector<uint8_t> & password,const sptr<IDomainAuthCallback> & callback)62 ErrCode DomainAccountManagerService::Auth(const DomainAccountInfo &info, const std::vector<uint8_t> &password,
63 const sptr<IDomainAuthCallback> &callback)
64 {
65 return InnerDomainAccountManager::GetInstance().Auth(info, password, callback);
66 }
67
AuthUser(int32_t userId,const std::vector<uint8_t> & password,const sptr<IDomainAuthCallback> & callback)68 ErrCode DomainAccountManagerService::AuthUser(int32_t userId, const std::vector<uint8_t> &password,
69 const sptr<IDomainAuthCallback> &callback)
70 {
71 if (userId < START_USER_ID) {
72 ACCOUNT_LOGE("invalid userId");
73 return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
74 }
75 return InnerDomainAccountManager::GetInstance().AuthUser(userId, password, callback);
76 }
77
AuthWithPopup(int32_t userId,const sptr<IDomainAuthCallback> & callback)78 ErrCode DomainAccountManagerService::AuthWithPopup(int32_t userId, const sptr<IDomainAuthCallback> &callback)
79 {
80 if (userId < 0) {
81 ACCOUNT_LOGE("invalid userId");
82 return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
83 }
84 return InnerDomainAccountManager::GetInstance().AuthWithPopup(userId, callback);
85 }
86
GetAccountStatus(const DomainAccountInfo & info,DomainAccountStatus & status)87 ErrCode DomainAccountManagerService::GetAccountStatus(const DomainAccountInfo &info, DomainAccountStatus &status)
88 {
89 return InnerDomainAccountManager::GetInstance().GetAccountStatus(info, status);
90 }
91
GetDomainAccountInfo(const DomainAccountInfo & info,const sptr<IDomainAccountCallback> & callback)92 ErrCode DomainAccountManagerService::GetDomainAccountInfo(
93 const DomainAccountInfo &info, const sptr<IDomainAccountCallback> &callback)
94 {
95 return InnerDomainAccountManager::GetInstance().GetDomainAccountInfo(info, callback);
96 }
97
RegisterAccountStatusListener(const sptr<IDomainAccountCallback> & listener)98 ErrCode DomainAccountManagerService::RegisterAccountStatusListener(const sptr<IDomainAccountCallback> &listener)
99 {
100 return InnerDomainAccountManager::GetInstance().RegisterAccountStatusListener(listener);
101 }
102
RegisterAccountStatusListener(const DomainAccountInfo & info,const sptr<IDomainAccountCallback> & listener)103 ErrCode DomainAccountManagerService::RegisterAccountStatusListener(
104 const DomainAccountInfo &info, const sptr<IDomainAccountCallback> &listener)
105 {
106 return InnerDomainAccountManager::GetInstance().RegisterAccountStatusListener(info, listener);
107 }
108
UnregisterAccountStatusListener(const DomainAccountInfo & info,const sptr<IDomainAccountCallback> & listener)109 ErrCode DomainAccountManagerService::UnregisterAccountStatusListener(
110 const DomainAccountInfo &info, const sptr<IDomainAccountCallback> &listener)
111 {
112 return InnerDomainAccountManager::GetInstance().UnregisterAccountStatusListener(info, listener);
113 }
114
UnregisterAccountStatusListener(const sptr<IDomainAccountCallback> & listener)115 ErrCode DomainAccountManagerService::UnregisterAccountStatusListener(const sptr<IDomainAccountCallback> &listener)
116 {
117 return InnerDomainAccountManager::GetInstance().UnregisterAccountStatusListener(listener);
118 }
119 } // namespace AccountSA
120 } // namespace OHOS
121