• 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 APP_ACCOUNT_INTERFACES_INNERKITS_APPACCOUNT_NATIVE_INCLUDE_APP_ACCOUNT_MANAGER_H
17 #define APP_ACCOUNT_INTERFACES_INNERKITS_APPACCOUNT_NATIVE_INCLUDE_APP_ACCOUNT_MANAGER_H
18 
19 #include "app_account_subscriber.h"
20 #include "app_account_common.h"
21 #include "app_account_info.h"
22 #include "iapp_account_authenticator_callback.h"
23 #include "iremote_object.h"
24 
25 namespace OHOS {
26 namespace AccountSA {
27 class AppAccountManager {
28 public:
29     static ErrCode AddAccount(const std::string &name, const std::string &extraInfo = "");
30     static ErrCode AddAccountImplicitly(const std::string &owner, const std::string &authType,
31         const AAFwk::Want &options, const sptr<IAppAccountAuthenticatorCallback> &callback);
32     static ErrCode CreateAccount(const std::string &name, const CreateAccountOptions &options);
33     static ErrCode CreateAccountImplicitly(const std::string &owner, const CreateAccountImplicitlyOptions &options,
34         const sptr<IAppAccountAuthenticatorCallback> &callback);
35     static ErrCode DeleteAccount(const std::string &name);
36 
37     static ErrCode GetAccountExtraInfo(const std::string &name, std::string &extraInfo);
38     static ErrCode SetAccountExtraInfo(const std::string &name, const std::string &extraInfo);
39 
40     static ErrCode EnableAppAccess(const std::string &name, const std::string &authorizedApp);
41     static ErrCode DisableAppAccess(const std::string &name, const std::string &authorizedApp);
42     static ErrCode SetAppAccess(const std::string &name, const std::string &authorizedApp, bool isAccessible);
43 
44     static ErrCode CheckAppAccountSyncEnable(const std::string &name, bool &syncEnable);
45     static ErrCode SetAppAccountSyncEnable(const std::string &name, const bool &syncEnable);
46 
47     static ErrCode GetAssociatedData(const std::string &name, const std::string &key, std::string &value);
48     static ErrCode SetAssociatedData(const std::string &name, const std::string &key, const std::string &value);
49 
50     static ErrCode GetAccountCredential(
51         const std::string &name, const std::string &credentialType, std::string &credential);
52     static ErrCode SetAccountCredential(
53         const std::string &name, const std::string &credentialType, const std::string &credential);
54 
55     static ErrCode Authenticate(const std::string &name, const std::string &owner, const std::string &authType,
56         const AAFwk::Want &options, const sptr<IAppAccountAuthenticatorCallback> &callback);
57     static ErrCode GetOAuthToken(const std::string &name, const std::string &owner, const std::string &authType,
58         std::string &token);
59     static ErrCode GetAuthToken(const std::string &name, const std::string &owner, const std::string &authType,
60         std::string &token);
61     static ErrCode SetOAuthToken(
62         const std::string &name, const std::string &authType, const std::string &token);
63     static ErrCode DeleteOAuthToken(
64         const std::string &name, const std::string &owner, const std::string &authType, const std::string &token);
65     static ErrCode DeleteAuthToken(
66         const std::string &name, const std::string &owner, const std::string &authType, const std::string &token);
67     static ErrCode SetOAuthTokenVisibility(const std::string &name, const std::string &authType,
68         const std::string &bundleName, bool isVisible);
69     static ErrCode SetAuthTokenVisibility(const std::string &name, const std::string &authType,
70         const std::string &bundleName, bool isVisible);
71     static ErrCode CheckOAuthTokenVisibility(const std::string &name, const std::string &authType,
72         const std::string &bundleName, bool &isVisible);
73     static ErrCode CheckAuthTokenVisibility(const std::string &name, const std::string &authType,
74         const std::string &bundleName, bool &isVisible);
75     static ErrCode GetAuthenticatorInfo(const std::string &owner, AuthenticatorInfo &info);
76     static ErrCode GetAllOAuthTokens(const std::string &name, const std::string &owner,
77         std::vector<OAuthTokenInfo> &tokenInfos);
78     static ErrCode GetOAuthList(const std::string &name, const std::string &authType,
79         std::set<std::string> &oauthList);
80     static ErrCode GetAuthList(const std::string &name, const std::string &authType,
81         std::set<std::string> &oauthList);
82     static ErrCode GetAuthenticatorCallback(const std::string &sessionId, sptr<IRemoteObject> &callback);
83 
84     static ErrCode GetAllAccounts(const std::string &owner, std::vector<AppAccountInfo> &appAccounts);
85     static ErrCode GetAllAccessibleAccounts(std::vector<AppAccountInfo> &appAccounts);
86     static ErrCode QueryAllAccessibleAccounts(const std::string &owner, std::vector<AppAccountInfo> &appAccounts);
87     static ErrCode CheckAppAccess(const std::string &name, const std::string &authorizedApp, bool &isAccessible);
88     static ErrCode DeleteAccountCredential(const std::string &name, const std::string &credentialType);
89     static ErrCode SelectAccountsByOptions(
90         const SelectAccountsOptions &options, const sptr<IAppAccountAuthenticatorCallback> &callback);
91     static ErrCode VerifyCredential(const std::string &name, const std::string &owner,
92         const VerifyCredentialOptions &options, const sptr<IAppAccountAuthenticatorCallback> &callback);
93     static ErrCode CheckAccountLabels(const std::string &name, const std::string &owner,
94         const std::vector<std::string> &labels, const sptr<IAppAccountAuthenticatorCallback> &callback);
95     static ErrCode SetAuthenticatorProperties(const std::string &owner,
96         const SetPropertiesOptions &options, const sptr<IAppAccountAuthenticatorCallback> &callback);
97 
98     static ErrCode SubscribeAppAccount(const std::shared_ptr<AppAccountSubscriber> &subscriber);
99     static ErrCode UnsubscribeAppAccount(const std::shared_ptr<AppAccountSubscriber> &subscriber);
100 };
101 }  // namespace AccountSA
102 }  // namespace OHOS
103 
104 #endif  // APP_ACCOUNT_INTERFACES_INNERKITS_APPACCOUNT_NATIVE_INCLUDE_APP_ACCOUNT_MANAGER_H
105