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 #ifndef OS_ACCOUNT_SERVICES_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_PLUGIN_PROXY_H
17 #define OS_ACCOUNT_SERVICES_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_PLUGIN_PROXY_H
18 
19 #include <string>
20 #include "account_error_no.h"
21 #include "idomain_account_plugin.h"
22 #include "iremote_proxy.h"
23 #include "want.h"
24 
25 namespace OHOS {
26 namespace AccountSA {
27 class DomainAccountPluginProxy : public IRemoteProxy<IDomainAccountPlugin> {
28 public:
29     explicit DomainAccountPluginProxy(const sptr<IRemoteObject> &object);
30     ~DomainAccountPluginProxy() override;
31     ErrCode Auth(const DomainAccountInfo &info, const std::vector<uint8_t> &password,
32         const sptr<IDomainAccountCallback> &callback) override;
33     ErrCode AuthWithPopup(const DomainAccountInfo &info, const sptr<IDomainAccountCallback> &callback) override;
34     ErrCode AuthWithToken(const DomainAccountInfo &info, const std::vector<uint8_t> &token,
35         const sptr<IDomainAccountCallback> &callback) override;
36     ErrCode GetAuthStatusInfo(const DomainAccountInfo &info, const sptr<IDomainAccountCallback> &callback) override;
37     ErrCode GetDomainAccountInfo(
38         const GetDomainAccountInfoOptions &options, const sptr<IDomainAccountCallback> &callback) override;
39     ErrCode OnAccountBound(const DomainAccountInfo &info, const int32_t localId,
40         const sptr<IDomainAccountCallback> &callback) override;
41     ErrCode OnAccountUnBound(const DomainAccountInfo &info,
42         const sptr<IDomainAccountCallback> &callback) override;
43     ErrCode IsAccountTokenValid(const DomainAccountInfo &info, const std::vector<uint8_t> &token,
44         const sptr<IDomainAccountCallback> &callback) override;
45     ErrCode GetAccessToken(const DomainAccountInfo &domainInfo, const std::vector<uint8_t> &accountToken,
46         const GetAccessTokenOptions &option, const sptr<IDomainAccountCallback> &callback) override;
47 
48 private:
49     ErrCode SendRequest(DomainAccountPluginInterfaceCode code, MessageParcel &data, MessageParcel &reply);
50     ErrCode AuthCommonInterface(const DomainAccountInfo &info, const std::vector<uint8_t> &password,
51         const sptr<IDomainAccountCallback> &callback, AuthMode authMode);
52 
53 private:
54     static inline BrokerDelegator<DomainAccountPluginProxy> delegator_;
55 };
56 }  // namespace AccountSA
57 }  // namespace OHOS
58 #endif  // OS_ACCOUNT_SERVICES_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_PLUGIN_PROXY_H