• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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_ACCOUNTMGR_INCLUDE_APPACCOUNT_IAPP_ACCOUNT_H
17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_APPACCOUNT_IAPP_ACCOUNT_H
18 
19 #include "app_account_common.h"
20 #include "app_account_info.h"
21 #include "app_account_subscribe_info.h"
22 #include "iremote_broker.h"
23 #include "iremote_object.h"
24 #include "want.h"
25 
26 namespace OHOS {
27 namespace AccountSA {
28 class IAppAccount : public IRemoteBroker {
29 public:
30     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accountfwk.IAppAccount");
31 
32     virtual ErrCode AddAccount(const std::string &name, const std::string &extraInfo) = 0;
33     virtual ErrCode AddAccountImplicitly(const std::string &owner, const std::string &authType,
34         const AAFwk::Want &options, const sptr<IRemoteObject> &callback) = 0;
35     virtual ErrCode CreateAccount(const std::string &name, const CreateAccountOptions &options) = 0;
36     virtual ErrCode CreateAccountImplicitly(const std::string &owner, const CreateAccountImplicitlyOptions &options,
37         const sptr<IRemoteObject> &callback) = 0;
38     virtual ErrCode DeleteAccount(const std::string &name) = 0;
39 
40     virtual ErrCode GetAccountExtraInfo(const std::string &name, std::string &extraInfo) = 0;
41     virtual ErrCode SetAccountExtraInfo(const std::string &name, const std::string &extraInfo) = 0;
42 
43     virtual ErrCode EnableAppAccess(const std::string &name, const std::string &authorizedApp) = 0;
44     virtual ErrCode DisableAppAccess(const std::string &name, const std::string &authorizedApp) = 0;
45     virtual ErrCode SetAppAccess(const std::string &name, const std::string &authorizedApp, bool isAccessible) = 0;
46     virtual ErrCode CheckAppAccess(const std::string &name, const std::string &authorizedApp, bool &isAccessible) = 0;
47 
48     virtual ErrCode CheckAppAccountSyncEnable(const std::string &name, bool &syncEnable) = 0;
49     virtual ErrCode SetAppAccountSyncEnable(const std::string &name, const bool &syncEnable) = 0;
50 
51     virtual ErrCode GetAssociatedData(const std::string &name, const std::string &key, std::string &value) = 0;
52     virtual ErrCode SetAssociatedData(const std::string &name, const std::string &key, const std::string &value) = 0;
53 
54     virtual ErrCode GetAccountCredential(
55         const std::string &name, const std::string &credentialType, std::string &credential) = 0;
56     virtual ErrCode SetAccountCredential(
57         const std::string &name, const std::string &credentialType, const std::string &credential) = 0;
58     virtual ErrCode DeleteAccountCredential(const std::string &name, const std::string &credentialType) = 0;
59 
60     virtual ErrCode Authenticate(const std::string &name, const std::string &owner, const std::string &authType,
61         const AAFwk::Want &options, const sptr<IRemoteObject> &callback) = 0;
62     virtual ErrCode GetOAuthToken(
63         const std::string &name, const std::string &owner, const std::string &authType, std::string &token) = 0;
64     virtual ErrCode GetAuthToken(
65         const std::string &name, const std::string &owner, const std::string &authType, std::string &token) = 0;
66     virtual ErrCode SetOAuthToken(
67         const std::string &name, const std::string &authType, const std::string &token) = 0;
68     virtual ErrCode DeleteOAuthToken(
69         const std::string &name, const std::string &owner, const std::string &authType, const std::string &token) = 0;
70     virtual ErrCode DeleteAuthToken(
71         const std::string &name, const std::string &owner, const std::string &authType, const std::string &token) = 0;
72     virtual ErrCode SetOAuthTokenVisibility(const std::string &name, const std::string &authType,
73         const std::string &bundleName, bool isVisible) = 0;
74     virtual ErrCode SetAuthTokenVisibility(const std::string &name, const std::string &authType,
75         const std::string &bundleName, bool isVisible) = 0;
76     virtual ErrCode CheckOAuthTokenVisibility(const std::string &name, const std::string &authType,
77         const std::string &bundleName, bool &isVisible) = 0;
78     virtual ErrCode CheckAuthTokenVisibility(const std::string &name, const std::string &authType,
79         const std::string &bundleName, bool &isVisible) = 0;
80     virtual ErrCode GetAuthenticatorInfo(const std::string &owner, AuthenticatorInfo &info) = 0;
81     virtual ErrCode GetAllOAuthTokens(const std::string &name, const std::string &owner,
82         std::vector<OAuthTokenInfo> &tokenInfos) = 0;
83     virtual ErrCode GetOAuthList(const std::string &name, const std::string &authType,
84         std::set<std::string> &oauthList) = 0;
85     virtual ErrCode GetAuthList(const std::string &name, const std::string &authType,
86         std::set<std::string> &oauthList) = 0;
87     virtual ErrCode GetAuthenticatorCallback(const std::string &sessionId, sptr<IRemoteObject> &callback) = 0;
88 
89     virtual ErrCode GetAllAccounts(const std::string &owner, std::vector<AppAccountInfo> &appAccounts) = 0;
90     virtual ErrCode GetAllAccessibleAccounts(std::vector<AppAccountInfo> &appAccounts) = 0;
91     virtual ErrCode QueryAllAccessibleAccounts(const std::string &owner, std::vector<AppAccountInfo> &appAccounts) = 0;
92     virtual ErrCode SelectAccountsByOptions(
93         const SelectAccountsOptions &options, const sptr<IRemoteObject> &callback) = 0;
94     virtual ErrCode VerifyCredential(const std::string &name, const std::string &owner,
95         const VerifyCredentialOptions &options, const sptr<IRemoteObject> &callback) = 0;
96     virtual ErrCode CheckAccountLabels(const std::string &name, const std::string &owner,
97         const std::vector<std::string> &labels, const sptr<IRemoteObject> &callback) = 0;
98     virtual ErrCode SetAuthenticatorProperties(
99         const std::string &owner, const SetPropertiesOptions &options, const sptr<IRemoteObject> &callback) = 0;
100 
101     virtual ErrCode SubscribeAppAccount(
102         const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) = 0;
103     virtual ErrCode UnsubscribeAppAccount(const sptr<IRemoteObject> &eventListener) = 0;
104 
105     enum class Message {
106         ADD_ACCOUNT = 0,
107         ADD_ACCOUNT_IMPLICITLY,
108         DELETE_ACCOUNT,
109         GET_ACCOUNT_EXTRA_INFO,
110         SET_ACCOUNT_EXTRA_INFO,
111         ENABLE_APP_ACCESS,
112         DISABLE_APP_ACCESS,
113         SET_APP_ACCESS,
114         CHECK_APP_ACCOUNT_SYNC_ENABLE,
115         SET_APP_ACCOUNT_SYNC_ENABLE,
116         GET_ASSOCIATED_DATA,
117         SET_ASSOCIATED_DATA,
118         GET_ACCOUNT_CREDENTIAL,
119         SET_ACCOUNT_CREDENTIAL,
120         AUTHENTICATE,
121         GET_OAUTH_TOKEN,
122         GET_AUTH_TOKEN,
123         SET_OAUTH_TOKEN,
124         DELETE_OAUTH_TOKEN,
125         DELETE_AUTH_TOKEN,
126         SET_OAUTH_TOKEN_VISIBILITY,
127         SET_AUTH_TOKEN_VISIBILITY,
128         CHECK_OAUTH_TOKEN_VISIBILITY,
129         CHECK_AUTH_TOKEN_VISIBILITY,
130         GET_AUTHENTICATOR_INFO,
131         GET_ALL_OAUTH_TOKENS,
132         GET_OAUTH_LIST,
133         GET_AUTH_LIST,
134         GET_AUTHENTICATOR_CALLBACK,
135         CLEAR_OAUTH_TOKEN,
136         GET_ALL_ACCOUNTS,
137         GET_ALL_ACCESSIBLE_ACCOUNTS,
138         QUERY_ALL_ACCESSIBLE_ACCOUNTS,
139         SUBSCRIBE_ACCOUNT,
140         UNSUBSCRIBE_ACCOUNT,
141         CHECK_APP_ACCESS,
142         DELETE_ACCOUNT_CREDENTIAL,
143         SELECT_ACCOUNTS_BY_OPTIONS,
144         VERIFY_CREDENTIAL,
145         CHECK_ACCOUNT_LABELS,
146         SET_AUTHENTICATOR_PROPERTIES,
147         CREATE_ACCOUNT,
148         CREATE_ACCOUNT_IMPLICITLY
149     };
150 };
151 }  // namespace AccountSA
152 }  // namespace OHOS
153 
154 #endif  // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_APPACCOUNT_IAPP_ACCOUNT_H
155