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_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_PLUGIN_H
17 #define OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_PLUGIN_H
18 
19 #include "domain_account_common.h"
20 #include "domain_account_callback.h"
21 #include "want.h"
22 
23 namespace OHOS {
24 namespace AccountSA {
25 class DomainAccountPlugin {
26 public:
27     /**
28      * Authenticates the specified domain account with the specified password,
29      * the authentication result should be returned from the callback.
30      *
31      * @param info Indicates the domain account information, including accountName and domain.
32      * @param password Indicates the password for authentication.
33      * @param callback Indicates the result callback.
34     */
35     virtual void Auth(const DomainAccountInfo &info, const std::vector<uint8_t> &password,
36         const std::shared_ptr<DomainAccountCallback> &callback) = 0;
37 
38     /**
39      * Authenticates the specified domain account with a popup.
40      *
41      * @param info Indicates the domain account information, including accountName and domain.
42      * @param callback Indicates the result callback.
43     */
44     virtual void AuthWithPopup(
45         const DomainAccountInfo &info, const std::shared_ptr<DomainAccountCallback> &callback) = 0;
46 
47     /**
48      * Authenticates the specified domain account with an authorization token.
49      *
50      * @param info Indicates the domain account information, including accountName and domain.
51      * @param token Indicates the authorization token generated when PIN or biometric authentication is successful.
52      * @param callback Indicates the result callback.
53     */
54     virtual void AuthWithToken(const DomainAccountInfo &info, const std::vector<uint8_t> &token,
55         const std::shared_ptr<DomainAccountCallback> &callback) = 0;
56 
57     /**
58      * Gets the authentication property of the specified domain account,
59      * which can be used to prevent brute-force attack.
60      *
61      * @param info Indicates the domain account information, including accountName and domain.
62      * @param[out] property Indicates the authentication property, including remaining times and freezing time.
63      * @return 0 indicates success, others indicate failure.
64     */
65     virtual void GetAuthStatusInfo(const DomainAccountInfo &info,
66         const std::shared_ptr<DomainAccountCallback> &callback) = 0;
67 
68     virtual void GetDomainAccountInfo(const GetDomainAccountInfoOptions &options,
69         const std::shared_ptr<DomainAccountCallback> &callback) = 0;
70 
71     virtual void OnAccountBound(const DomainAccountInfo &info, const int32_t localId,
72         const std::shared_ptr<DomainAccountCallback> &callback) = 0;
73 
74     virtual void OnAccountUnBound(const DomainAccountInfo &info,
75         const std::shared_ptr<DomainAccountCallback> &callback) = 0;
76 
77     virtual void IsAccountTokenValid(const DomainAccountInfo &info, const std::vector<uint8_t> &token,
78         const std::shared_ptr<DomainAccountCallback> &callback) = 0;
79 
80     virtual void GetAccessToken(const DomainAccountInfo &domainInfo, const std::vector<uint8_t> &accountToken,
81         const GetAccessTokenOptions &option, const std::shared_ptr<DomainAccountCallback> &callback) = 0;
82 };
83 }  // namespace AccountSA
84 }  // namespace OHOS
85 #endif  // OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_PLUGIN_H