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_APP_ACCOUNT_PROXY_H 17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_APPACCOUNT_APP_ACCOUNT_PROXY_H 18 19 #include "iapp_account.h" 20 #include "iremote_proxy.h" 21 22 namespace OHOS { 23 namespace AccountSA { 24 class AppAccountProxy : public IRemoteProxy<IAppAccount> { 25 public: 26 explicit AppAccountProxy(const sptr<IRemoteObject> &object); 27 ~AppAccountProxy() override; 28 29 ErrCode AddAccount(const std::string &name, const std::string &extraInfo) override; 30 ErrCode AddAccountImplicitly(const std::string &owner, const std::string &authType, 31 const AAFwk::Want &options, const sptr<IAppAccountAuthenticatorCallback> &callback) override; 32 ErrCode CreateAccount(const std::string &name, const CreateAccountOptions &options) override; 33 ErrCode CreateAccountImplicitly(const std::string &owner, const CreateAccountImplicitlyOptions &options, 34 const sptr<IAppAccountAuthenticatorCallback> &callback) override; 35 ErrCode DeleteAccount(const std::string &name) override; 36 37 ErrCode GetAccountExtraInfo(const std::string &name, std::string &extraInfo) override; 38 ErrCode SetAccountExtraInfo(const std::string &name, const std::string &extraInfo) override; 39 40 ErrCode EnableAppAccess(const std::string &name, const std::string &authorizedApp) override; 41 ErrCode DisableAppAccess(const std::string &name, const std::string &authorizedApp) override; 42 ErrCode SetAppAccess(const std::string &name, const std::string &authorizedApp, bool isAccessible) override; 43 ErrCode CheckAppAccess(const std::string &name, const std::string &authorizedApp, bool &isAccessible) override; 44 45 ErrCode CheckAppAccountSyncEnable(const std::string &name, bool &syncEnable) override; 46 ErrCode SetAppAccountSyncEnable(const std::string &name, const bool &syncEnable) override; 47 48 ErrCode GetAssociatedData(const std::string &name, const std::string &key, std::string &value) override; 49 ErrCode SetAssociatedData( 50 const std::string &name, const std::string &key, const std::string &value) override; 51 52 ErrCode GetAccountCredential( 53 const std::string &name, const std::string &credentialType, std::string &credential) override; 54 ErrCode SetAccountCredential( 55 const std::string &name, const std::string &credentialType, const std::string &credential) override; 56 ErrCode DeleteAccountCredential(const std::string &name, const std::string &credentialType) override; 57 58 ErrCode Authenticate(const std::string &name, const std::string &owner, const std::string &authType, 59 const AAFwk::Want &options, const sptr<IAppAccountAuthenticatorCallback> &callback) override; 60 ErrCode GetOAuthToken( 61 const std::string &name, const std::string &owner, const std::string &authType, std::string &token) override; 62 ErrCode GetAuthToken( 63 const std::string &name, const std::string &owner, const std::string &authType, std::string &token) override; 64 ErrCode SetOAuthToken( 65 const std::string &name, const std::string &authType, const std::string &token) override; 66 ErrCode DeleteOAuthToken(const std::string &name, const std::string &owner, const std::string &authType, 67 const std::string &token) override; 68 ErrCode DeleteAuthToken(const std::string &name, const std::string &owner, const std::string &authType, 69 const std::string &token) override; 70 ErrCode SetOAuthTokenVisibility( 71 const std::string &name, const std::string &authType, const std::string &bundleName, bool isVisible) override; 72 ErrCode SetAuthTokenVisibility( 73 const std::string &name, const std::string &authType, const std::string &bundleName, bool isVisible) override; 74 ErrCode CheckOAuthTokenVisibility( 75 const std::string &name, const std::string &authType, const std::string &bundleName, bool &isVisible) override; 76 ErrCode CheckAuthTokenVisibility( 77 const std::string &name, const std::string &authType, const std::string &bundleName, bool &isVisible) override; 78 ErrCode GetAuthenticatorInfo(const std::string &owner, AuthenticatorInfo &info) override; 79 ErrCode GetAllOAuthTokens( 80 const std::string &name, const std::string &owner, std::vector<OAuthTokenInfo> &tokenInfos) override; 81 ErrCode GetOAuthList( 82 const std::string &name, const std::string &authType, std::set<std::string> &oauthList) override; 83 ErrCode GetAuthList( 84 const std::string &name, const std::string &authType, std::set<std::string> &oauthList) override; 85 ErrCode GetAuthenticatorCallback(const std::string &sessionId, sptr<IRemoteObject> &callback) override; 86 87 ErrCode GetAllAccounts(const std::string &owner, std::vector<AppAccountInfo> &appAccounts) override; 88 ErrCode GetAllAccessibleAccounts(std::vector<AppAccountInfo> &appAccounts) override; 89 ErrCode QueryAllAccessibleAccounts(const std::string &owner, std::vector<AppAccountInfo> &appAccounts) override; 90 91 ErrCode SelectAccountsByOptions( 92 const SelectAccountsOptions &options, const sptr<IAppAccountAuthenticatorCallback> &callback) override; 93 ErrCode VerifyCredential(const std::string &name, const std::string &owner, 94 const VerifyCredentialOptions &options, const sptr<IAppAccountAuthenticatorCallback> &callback) override; 95 ErrCode CheckAccountLabels(const std::string &name, const std::string &owner, 96 const std::vector<std::string> &labels, const sptr<IAppAccountAuthenticatorCallback> &callback) override; 97 ErrCode SetAuthenticatorProperties(const std::string &owner, const SetPropertiesOptions &options, 98 const sptr<IAppAccountAuthenticatorCallback> &callback) override; 99 ErrCode ExecuteRequest(const AccountCapabilityRequest &request, 100 const sptr<IAppAccountAuthorizationExtensionCallback> &callback) override; 101 ErrCode SubscribeAppAccount( 102 const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) override; 103 ErrCode UnsubscribeAppAccount(const sptr<IRemoteObject> &eventListener) override; 104 105 private: 106 ErrCode SendRequest(AppAccountInterfaceCode code, MessageParcel &data, MessageParcel &reply); 107 ErrCode WriteGetAuthListParam( 108 const std::string &name, const std::string &authType, MessageParcel &data); 109 ErrCode WriteGetAuthTokenParam( 110 const std::string &name, const std::string &owner, const std::string &authType, MessageParcel &data); 111 ErrCode WriteDeleteAuthTokenParam(const std::string &name, 112 const std::string &owner, const std::string &authType, const std::string &token, MessageParcel &data); 113 ErrCode WriteTokenVisibilityParam( 114 const std::string &name, const std::string &authType, const std::string &bundleName, MessageParcel &data); 115 ErrCode SendRequestWithTwoStr(MessageParcel &reply, AppAccountInterfaceCode code, 116 const std::string &str1, const std::string &str2); 117 118 template<typename T> 119 bool WriteParcelableVector(const std::vector<T> &parcelableVector, MessageParcel &data); 120 template<typename T> 121 bool ReadParcelableVector(std::vector<T> &parcelableVector, MessageParcel &data); 122 123 private: 124 static inline BrokerDelegator<AppAccountProxy> delegator_; 125 }; 126 } // namespace AccountSA 127 } // namespace OHOS 128 129 #endif // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_APPACCOUNT_APP_ACCOUNT_PROXY_H 130