1 /* 2 * Copyright (c) 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_INTERFACES_INNERKITS_ACCOUNT_IAM_NATIVE_INCLUDE_ACCOUNT_IAM_CALLBACK_SERVICE_H 17 #define OS_ACCOUNT_INTERFACES_INNERKITS_ACCOUNT_IAM_NATIVE_INCLUDE_ACCOUNT_IAM_CALLBACK_SERVICE_H 18 19 #include "account_iam_callback_stub.h" 20 #include "account_iam_client_callback.h" 21 #include "account_iam_info.h" 22 #include "domain_account_common.h" 23 #include "domain_auth_callback.h" 24 25 namespace OHOS { 26 namespace AccountSA { 27 class IDMCallbackService : public IDMCallbackStub { 28 public: 29 explicit IDMCallbackService(int32_t userId, const std::shared_ptr<IDMCallback> &callback); 30 void OnAcquireInfo(int32_t module, uint32_t acquireInfo, const Attributes &extraInfo) override; 31 void OnResult(int32_t result, const Attributes &extraInfo) override; 32 33 private: 34 int32_t userId_; 35 std::shared_ptr<IDMCallback> callback_; 36 DISALLOW_COPY_AND_MOVE(IDMCallbackService); 37 }; 38 39 class GetCredInfoCallbackService : public GetCredInfoCallbackStub { 40 public: 41 explicit GetCredInfoCallbackService(const std::shared_ptr<GetCredInfoCallback> &callback); 42 void OnCredentialInfo(const std::vector<CredentialInfo> &infoList) override; 43 44 private: 45 std::shared_ptr<GetCredInfoCallback> callback_; 46 DISALLOW_COPY_AND_MOVE(GetCredInfoCallbackService); 47 }; 48 49 class GetSetPropCallbackService : public GetSetPropCallbackStub { 50 public: 51 explicit GetSetPropCallbackService(const std::shared_ptr<GetSetPropCallback> &callback); 52 void OnResult(int32_t result, const Attributes &extraInfo) override; 53 54 private: 55 std::shared_ptr<GetSetPropCallback> callback_; 56 DISALLOW_COPY_AND_MOVE(GetSetPropCallbackService); 57 }; 58 59 class DomainAuthCallbackAdapter final : public DomainAuthCallback { 60 public: 61 DomainAuthCallbackAdapter(const std::shared_ptr<IDMCallback> &callback); 62 void OnResult(int32_t resultCode, const DomainAuthResult &result); 63 64 private: 65 std::shared_ptr<IDMCallback> callback_; 66 }; 67 68 class DomainCredentialRecipient : public IInputerData { 69 public: 70 DomainCredentialRecipient(int32_t userId, const std::shared_ptr<IDMCallback> &callback); 71 virtual ~DomainCredentialRecipient(); 72 void OnSetData(int32_t authSubType, std::vector<uint8_t> data) override; 73 74 private: 75 int32_t userId_; 76 std::shared_ptr<IDMCallback> idmCallback_; 77 }; 78 79 class IAMInputerData : public IInputerData { 80 public: 81 IAMInputerData(int32_t userId, const std::shared_ptr<IInputerData> &inputerData); 82 virtual~IAMInputerData(); 83 void OnSetData(int32_t authSubType, std::vector<uint8_t> data) override; 84 void ResetInnerInputerData(const std::shared_ptr<IInputerData> &inputerData); 85 86 private: 87 int32_t userId_; 88 std::shared_ptr<IInputerData> innerInputerData_; 89 std::map<std::string, std::vector<uint8_t>> credMap_; 90 }; 91 92 class IAMInputer : public IInputer { 93 public: 94 IAMInputer(int32_t userId, const std::shared_ptr<IInputer> &inputer); 95 virtual ~IAMInputer(); 96 97 void OnGetData(int32_t authSubType, std::shared_ptr<IInputerData> inputerData) override; 98 void ResetInnerInputer(const std::shared_ptr<IInputer> &inputer); 99 private: 100 int32_t userId_; 101 std::vector<uint8_t> oldCredential_; 102 std::shared_ptr<IInputer> innerInputer_ = nullptr; 103 std::shared_ptr<IAMInputerData> inputerData_ = nullptr; 104 }; 105 } // namespace AccountSA 106 } // namespace OHOS 107 #endif // OS_ACCOUNT_INTERFACES_INNERKITS_ACCOUNT_IAM_NATIVE_INCLUDE_ACCOUNT_IAM_CALLBACK_SERVICE_H 108