1 /* 2 * Copyright (c) 2022-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_ACCOUNT_IAM_CALLBACK_H 17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_ACCOUNT_IAM_CALLBACK_H 18 19 #include <map> 20 #include <vector> 21 #include "account_iam_info.h" 22 #include "domain_account_callback.h" 23 #include "iaccount_iam_callback.h" 24 25 namespace OHOS { 26 namespace AccountSA { 27 class AuthCallback : public AuthenticationCallback { 28 public: 29 explicit AuthCallback(uint32_t userId, AuthType authType, const sptr<IIDMCallback> &callback); 30 virtual ~AuthCallback() = default; 31 32 void OnAcquireInfo(int32_t module, uint32_t acquireInfo, const Attributes &extraInfo) override; 33 void OnResult(int32_t result, const Attributes &extraInfo) override; 34 35 private: 36 std::uint32_t userId_; 37 AuthType authType_; 38 sptr<IIDMCallback> innerCallback_ = nullptr; 39 }; 40 41 class IDMAuthCallback : public AuthenticationCallback { 42 public: 43 explicit IDMAuthCallback(uint32_t userId, const CredentialParameters &credInfo, 44 int32_t oldResult, const Attributes &reqResult, const sptr<IIDMCallback> &idmCallback); 45 virtual ~IDMAuthCallback() = default; 46 47 void OnResult(int32_t result, const Attributes &extraInfo) override; 48 void OnAcquireInfo(int32_t module, uint32_t acquireInfo, const Attributes &extraInfo) override; 49 50 private: 51 uint32_t userId_; 52 CredentialParameters credInfo_; 53 int32_t oldResult_; 54 Attributes reqResult_; 55 sptr<IIDMCallback> idmCallback_ = nullptr; 56 uint64_t credentialId_ = 0; 57 uint64_t secureUid_ = 0; 58 }; 59 60 class AddCredCallback : public UserIdmClientCallback { 61 public: 62 explicit AddCredCallback(uint32_t userId, const CredentialParameters &credInfo, 63 const sptr<IIDMCallback> &callback); 64 virtual ~AddCredCallback() = default; 65 66 void OnResult(int32_t result, const Attributes &extraInfo) override; 67 void OnAcquireInfo(int32_t module, uint32_t acquireInfo, const Attributes &extraInfo) override; 68 69 private: 70 std::uint32_t userId_; 71 CredentialParameters credInfo_; 72 const sptr<IIDMCallback> innerCallback_ = nullptr; 73 }; 74 75 class UpdateCredCallback : public UserIdmClientCallback { 76 public: 77 explicit UpdateCredCallback(uint32_t userId, const CredentialParameters &credInfo, 78 const sptr<IIDMCallback> &callback); 79 virtual ~UpdateCredCallback() = default; 80 81 void OnResult(int32_t result, const Attributes &extraInfo) override; 82 void OnAcquireInfo(int32_t module, uint32_t acquireInfo, const Attributes &extraInfo) override; 83 84 private: 85 std::uint32_t userId_; 86 std::vector<uint8_t> oldCredential_; 87 CredentialParameters credInfo_; 88 const sptr<IIDMCallback> innerCallback_ = nullptr; 89 }; 90 91 class DelCredCallback : public UserIdmClientCallback { 92 public: 93 explicit DelCredCallback(int32_t userId, uint64_t credentialId, const std::vector<uint8_t> &authToken, 94 const sptr<IIDMCallback> &callback); 95 virtual ~DelCredCallback() = default; 96 97 void OnResult(int32_t result, const Attributes &extraInfo) override; 98 void OnAcquireInfo(int32_t module, uint32_t acquireInfo, const Attributes &extraInfo) override; 99 100 private: 101 int32_t userId_; 102 uint64_t credentialId_; 103 std::vector<uint8_t> authToken_; 104 const sptr<IIDMCallback> innerCallback_ = nullptr; 105 }; 106 107 class GetCredInfoCallbackWrapper : public GetCredentialInfoCallback { 108 public: 109 explicit GetCredInfoCallbackWrapper( 110 int32_t userId, int32_t authType, const sptr<IGetCredInfoCallback> &callback); 111 virtual ~GetCredInfoCallbackWrapper() = default; 112 113 void OnCredentialInfo(const std::vector<CredentialInfo> &infoList) override; 114 115 private: 116 int32_t userId_; 117 int32_t authType_; 118 sptr<IGetCredInfoCallback> innerCallback_ = nullptr; 119 }; 120 121 class GetPropCallbackWrapper : public GetPropCallback { 122 public: 123 explicit GetPropCallbackWrapper(const sptr<IGetSetPropCallback> &callback); 124 virtual ~GetPropCallbackWrapper() = default; 125 126 void OnResult(int32_t result, const Attributes &extraInfo) override; 127 128 private: 129 sptr<IGetSetPropCallback> innerCallback_; 130 }; 131 132 class SetPropCallbackWrapper : public SetPropCallback { 133 public: 134 explicit SetPropCallbackWrapper(const sptr<IGetSetPropCallback> &callback); 135 virtual ~SetPropCallbackWrapper() = default; 136 137 void OnResult(int32_t result, const Attributes &extraInfo) override; 138 139 private: 140 sptr<IGetSetPropCallback> innerCallback_; 141 }; 142 143 class GetDomainAuthStatusInfoCallback final : public DomainAccountCallback { 144 public: 145 explicit GetDomainAuthStatusInfoCallback( 146 const GetPropertyRequest &request, const sptr<IGetSetPropCallback> &callback); 147 148 void OnResult(int32_t result, Parcel &parcel) override; 149 150 private: 151 GetPropertyRequest request_; 152 sptr<IGetSetPropCallback> innerCallback_; 153 }; 154 } // namespace AccountSA 155 } // namespace OHOS 156 #endif // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_ACCOUNT_IAM_CALLBACK_H 157