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 USERIDM_COAUTH_HANDLER_PROXY_H 17 #define USERIDM_COAUTH_HANDLER_PROXY_H 18 19 #include "useridm_module.h" 20 #include "coauth_callback.h" 21 #include "useridm_setprop_handler.h" 22 #include "auth_info.h" 23 #include "co_auth.h" 24 #include "auth_attributes.h" 25 26 namespace OHOS { 27 namespace UserIAM { 28 namespace UserIDM { 29 class UserIDMCoAuthHandler : public CoAuth::CoAuthCallback { 30 public: 31 explicit UserIDMCoAuthHandler(CoAuthType type, const uint64_t challenge, const uint64_t sessionId, 32 const std::shared_ptr<UserIDMModule>& data, const sptr<IIDMCallback>& callback); 33 virtual ~UserIDMCoAuthHandler() = default; 34 35 void OnFinish(uint32_t resultCode, std::vector<uint8_t>& scheduleToken) override; 36 void OnAcquireInfo(uint32_t acquire) override; 37 void ResetCallback(); 38 39 private: 40 int32_t OnFinishModify(uint32_t resultCode, std::vector<uint8_t>& scheduleToken, uint64_t& credentialId); 41 uint64_t lastChallenge_; 42 uint64_t lastScheduleId_; 43 std::shared_ptr<UserIDMModule> dataCallback_; 44 sptr<IIDMCallback> innerCallback_; 45 CoAuthType type_; // 0: add cred 1: modify cred 46 std::mutex mutex_; 47 }; 48 } // namespace UserIDM 49 } // namespace UserIAM 50 } // namespace OHOS 51 #endif // USERIDM_COAUTH_HANDLER_PROXY_H 52