• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_APPACCOUNT_INNER_APP_ACCOUNT_MANAGER_H
17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_APPACCOUNT_INNER_APP_ACCOUNT_MANAGER_H
18 
19 #include "app_account_authenticator_manager.h"
20 #include "app_account_authenticator_session_manager.h"
21 #include "app_account_control_manager.h"
22 #include "app_account_subscribe_manager.h"
23 
24 namespace OHOS {
25 namespace AccountSA {
26 class InnerAppAccountManager {
27 public:
28     InnerAppAccountManager();
29     virtual ~InnerAppAccountManager();
30 
31     ErrCode AddAccount(const std::string &name, const std::string &extraInfo,
32         const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
33     ErrCode AddAccountImplicitly(const AuthenticatorSessionRequest &request);
34     ErrCode CreateAccount(const std::string &name, const CreateAccountOptions &options,
35         const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
36     ErrCode CreateAccountImplicitly(const AuthenticatorSessionRequest &request);
37     ErrCode DeleteAccount(
38         const std::string &name, const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
39 
40     ErrCode GetAccountExtraInfo(const std::string &name, std::string &extraInfo,
41         const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
42     ErrCode SetAccountExtraInfo(const std::string &name, const std::string &extraInfo,
43         const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
44 
45     ErrCode EnableAppAccess(const std::string &name, const std::string &authorizedApp,
46         AppAccountCallingInfo &appAccountCallingInfo, const uint32_t apiVersion = Constants::API_VERSION7);
47     ErrCode DisableAppAccess(const std::string &name, const std::string &authorizedApp,
48         AppAccountCallingInfo &appAccountCallingInfo, const uint32_t apiVersion = Constants::API_VERSION7);
49     ErrCode CheckAppAccess(const std::string &name, const std::string &authorizedApp, bool &isAccessible,
50         const AppAccountCallingInfo &appAccountCallingInfo);
51 
52     ErrCode CheckAppAccountSyncEnable(const std::string &name, bool &syncEnable,
53         const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
54     ErrCode SetAppAccountSyncEnable(const std::string &name, const bool &syncEnable,
55         const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
56 
57     ErrCode GetAssociatedData(const std::string &name, const std::string &key,
58         std::string &value, const uid_t &uid);
59     ErrCode SetAssociatedData(const std::string &name, const std::string &key, const std::string &value,
60         const AppAccountCallingInfo &appAccountCallingInfo);
61 
62     ErrCode GetAccountCredential(const std::string &name, const std::string &credentialType, std::string &credential,
63         const AppAccountCallingInfo &appAccountCallingInfo);
64     ErrCode SetAccountCredential(const std::string &name, const std::string &credentialType,
65         const std::string &credential, const AppAccountCallingInfo &appAccountCallingInfo);
66     ErrCode DeleteAccountCredential(const std::string &name, const std::string &credentialType,
67         const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
68 
69     ErrCode Authenticate(const AuthenticatorSessionRequest &request);
70     ErrCode GetOAuthToken(const AuthenticatorSessionRequest &request,
71         std::string &token, const uint32_t apiVersion = Constants::API_VERSION8);
72     ErrCode SetOAuthToken(const AuthenticatorSessionRequest &request);
73     ErrCode DeleteOAuthToken(
74         const AuthenticatorSessionRequest &request, const uint32_t apiVersion = Constants::API_VERSION8);
75     ErrCode SetOAuthTokenVisibility(const AuthenticatorSessionRequest &,
76         const uint32_t apiVersion = Constants::API_VERSION8);
77     ErrCode CheckOAuthTokenVisibility(const AuthenticatorSessionRequest &request,
78         bool &isVisible, const uint32_t apiVersion = Constants::API_VERSION8);
79     ErrCode GetAllOAuthTokens(const AuthenticatorSessionRequest &request, std::vector<OAuthTokenInfo> &tokenInfos);
80     ErrCode GetOAuthList(const AuthenticatorSessionRequest &request,
81         std::set<std::string> &oauthList, const uint32_t apiVersion = Constants::API_VERSION8);
82     ErrCode GetAuthenticatorCallback(const AuthenticatorSessionRequest &request, sptr<IRemoteObject> &callback);
83     ErrCode GetAuthenticatorInfo(const AuthenticatorSessionRequest &request, AuthenticatorInfo &authenticator);
84 
85     ErrCode GetAllAccounts(const std::string &owner, std::vector<AppAccountInfo> &appAccounts, const uid_t &uid,
86         const std::string &bundleName, const uint32_t &appIndex);
87     ErrCode GetAllAccessibleAccounts(std::vector<AppAccountInfo> &appAccounts,
88         const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
89 
90     ErrCode SelectAccountsByOptions(
91         const SelectAccountsOptions &options, const sptr<IAppAccountAuthenticatorCallback> &callback,
92         const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
93     ErrCode VerifyCredential(const AuthenticatorSessionRequest &request);
94     ErrCode CheckAccountLabels(const AuthenticatorSessionRequest &request);
95     ErrCode SetAuthenticatorProperties(const AuthenticatorSessionRequest &request);
96 
97     ErrCode SubscribeAppAccount(const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener,
98         const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
99     ErrCode UnsubscribeAppAccount(const sptr<IRemoteObject> &eventListener);
100 
101     ErrCode OnPackageRemoved(const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
102     ErrCode OnUserRemoved(int32_t userId);
103 
104 private:
105     std::shared_ptr<AppAccountControlManager> controlManagerPtr_ = nullptr;
106     std::shared_ptr<AppAccountSubscribeManager> subscribeManagerPtr_ = nullptr;
107     std::shared_ptr<AppAccountAuthenticatorSessionManager> sessionManagerPtr_ = nullptr;
108     std::shared_ptr<AppAccountAuthenticatorManager> authenticatorManagerPtr_ = nullptr;
109 
110     DISALLOW_COPY_AND_MOVE(InnerAppAccountManager);
111 };
112 }  // namespace AccountSA
113 }  // namespace OHOS
114 
115 #endif  // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_APPACCOUNT_INNER_APP_ACCOUNT_MANAGER_H
116