• 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 #include "domain_account_plugin_service.h"
17 
18 #include "account_log_wrapper.h"
19 #include "domain_auth_callback_client.h"
20 
21 namespace OHOS {
22 namespace AccountSA {
DomainAccountPluginService(const std::shared_ptr<DomainAccountPlugin> & plugin)23 DomainAccountPluginService::DomainAccountPluginService(const std::shared_ptr<DomainAccountPlugin> &plugin)
24     : innerPlugin_(plugin)
25 {}
26 
~DomainAccountPluginService()27 DomainAccountPluginService::~DomainAccountPluginService()
28 {}
29 
Auth(const DomainAccountInfo & info,const std::vector<uint8_t> & password,const sptr<IDomainAuthCallback> & callback)30 ErrCode DomainAccountPluginService::Auth(const DomainAccountInfo &info, const std::vector<uint8_t> &password,
31     const sptr<IDomainAuthCallback> &callback)
32 {
33     if (innerPlugin_ == nullptr) {
34         ACCOUNT_LOGE("innerPlugin_ is nullptr");
35         return ERR_ACCOUNT_COMMON_NULL_PTR_ERROR;
36     }
37     auto callbackClient = std::make_shared<DomainAuthCallbackClient>(callback);
38     if (callbackClient == nullptr) {
39         ACCOUNT_LOGE("failed to create DomainAuthCallbackClient");
40         return ERR_ACCOUNT_COMMON_INSUFFICIENT_MEMORY_ERROR;
41     }
42     innerPlugin_->Auth(info, password, callbackClient);
43     return ERR_OK;
44 }
45 
GetAuthProperty(const DomainAccountInfo & info,DomainAuthProperty & property)46 ErrCode DomainAccountPluginService::GetAuthProperty(const DomainAccountInfo &info, DomainAuthProperty &property)
47 {
48     if (innerPlugin_ == nullptr) {
49         ACCOUNT_LOGE("innerPlugin_ is nullptr");
50         return ERR_ACCOUNT_COMMON_NULL_PTR_ERROR;
51     }
52     return innerPlugin_->GetAuthProperty(info, property);
53 }
54 }  // namespace AccountSA
55 }  // namespace OHOS