1 /* 2 * Copyright (c) 2022-2024 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_ACCOUNT_IAM_NATIVE_INCLUDE_ACCOUNT_IAM_MGR_PROXY_H 17 #define OS_ACCOUNT_INTERFACES_INNERKITS_ACCOUNT_IAM_NATIVE_INCLUDE_ACCOUNT_IAM_MGR_PROXY_H 18 19 #include "account_error_no.h" 20 #include "account_iam_info.h" 21 #include "iaccount_iam.h" 22 #include "iremote_proxy.h" 23 24 namespace OHOS { 25 namespace AccountSA { 26 class AccountIAMMgrProxy : public IRemoteProxy<IAccountIAM> { 27 public: 28 explicit AccountIAMMgrProxy(const sptr<IRemoteObject> &object); 29 ~AccountIAMMgrProxy() override; 30 31 int32_t OpenSession(int32_t userId, std::vector<uint8_t> &challenge) override; 32 int32_t CloseSession(int32_t userId) override; 33 void AddCredential( 34 int32_t userId, const CredentialParameters &credInfo, const sptr<IIDMCallback> &callback) override; 35 void UpdateCredential(int32_t userId, const CredentialParameters &credInfo, 36 const sptr<IIDMCallback> &callback) override; 37 int32_t Cancel(int32_t userId) override; 38 void DelCred(int32_t userId, uint64_t credentialId, const std::vector<uint8_t> &authToken, 39 const sptr<IIDMCallback> &callback) override; 40 void DelUser(int32_t userId, const std::vector<uint8_t> &authToken, const sptr<IIDMCallback> &callback) override; 41 int32_t GetCredentialInfo( 42 int32_t userId, AuthType authType, const sptr<IGetCredInfoCallback> &callback) override; 43 int32_t PrepareRemoteAuth( 44 const std::string &remoteNetworkId, const sptr<IPreRemoteAuthCallback> &callback) override; 45 int32_t AuthUser(AuthParam &authParam, const sptr<IIDMCallback> &callback, uint64_t &contextId) override; 46 int32_t CancelAuth(uint64_t contextId) override; 47 int32_t GetAvailableStatus(const AuthType authType, const AuthTrustLevel authTrustLevel, int32_t &status) override; 48 void GetProperty( 49 int32_t userId, const GetPropertyRequest &request, const sptr<IGetSetPropCallback> &callback) override; 50 void SetProperty( 51 int32_t userId, const SetPropertyRequest &request, const sptr<IGetSetPropCallback> &callback) override; 52 void GetEnrolledId(int32_t accountId, AuthType authType, const sptr<IGetEnrolledIdCallback> &callback) override; 53 IAMState GetAccountState(int32_t userId) override; 54 55 private: 56 ErrCode SendRequest(AccountIAMInterfaceCode code, MessageParcel &data, MessageParcel &reply); 57 void AddOrUpdateCredential(int32_t userId, const CredentialParameters &credInfo, 58 const sptr<IIDMCallback> &callback, bool isAdd); 59 bool WriteCommonData(MessageParcel &data, int32_t userId); 60 bool WriteAuthParam(MessageParcel &data, const AuthParam &authParam); 61 bool WriteRemoteAuthParam(MessageParcel &data, const std::optional<RemoteAuthParam> &remoteAuthParam); 62 63 private: 64 static inline BrokerDelegator<AccountIAMMgrProxy> delegator_; 65 }; 66 } // namespace AccountSA 67 } // namespace OHOS 68 #endif // OS_ACCOUNT_INTERFACES_INNERKITS_ACCOUNT_IAM_NATIVE_INCLUDE_ACCOUNT_IAM_MGR_PROXY_H