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_CONTROLLER_H 17 #define USERIDM_CONTROLLER_H 18 19 #include "useridm_info.h" 20 #include "useridm_coauth_handler.h" 21 #include "auth_info.h" 22 #include "co_auth.h" 23 #include "auth_attributes.h" 24 25 namespace OHOS { 26 namespace UserIAM { 27 namespace UserIDM { 28 const int64_t delay_time = 30 * 1000; 29 class UserIDMController { 30 public: 31 explicit UserIDMController(); 32 ~UserIDMController(); 33 34 void OpenEditSessionCtrl(int32_t userId, uint64_t& challenge); 35 void CloseEditSessionCtrl(); 36 int32_t GetAuthInfoCtrl(int32_t userId, AuthType authType, std::vector<CredentialInfo>& credInfos); 37 int32_t GetSecureInfoCtrl(int32_t userId, uint64_t& secureUid, std::vector<EnrolledInfo>& enrolledInfos); 38 int32_t DeleteCredentialCtrl(int32_t userId, uint64_t credentialId, 39 std::vector<uint8_t> authToken, CredentialInfo& credInfo); 40 int32_t DeleteUserCtrl(int32_t userId, std::vector<uint8_t> authToken, std::vector<CredentialInfo>& credInfo); 41 int32_t DeleteUserByForceCtrl(int32_t userId, std::vector<CredentialInfo>& credInfo); 42 int32_t AddCredentialCtrl(int32_t userId, uint64_t callerID, AddCredInfo& credInfo, 43 const sptr<IIDMCallback>& innerkitsCallback); 44 int32_t AddCredentialCallCoauth(uint64_t callerID, AddCredInfo& credInfo, 45 const sptr<IIDMCallback>& innerkitsCallback, uint64_t& challenge, uint64_t& scheduleId); 46 int32_t UpdateCredentialCtrl(int32_t userId, uint64_t callerID, std::string callerName, 47 AddCredInfo& credInfo, const sptr<IIDMCallback>& innerCallback); 48 int32_t DelSchedleIdCtrl(uint64_t challenge); 49 int32_t DelFaceCredentialCtrl(AuthType authType, AuthSubType authSubType, 50 uint64_t credentialId, uint64_t templateId, const sptr<IIDMCallback>& innerCallback); 51 int32_t DelExecutorPinInfoCtrl(const sptr<IIDMCallback>& innerCallback, std::vector<CredentialInfo>& info); 52 53 private: 54 class CoAuthCallbackDeathRecipient : public IRemoteObject::DeathRecipient { 55 public: 56 CoAuthCallbackDeathRecipient(std::shared_ptr<UserIDMCoAuthHandler> callback); 57 ~CoAuthCallbackDeathRecipient() = default; 58 void OnRemoteDied(const wptr<IRemoteObject>& remote) override; 59 private: 60 std::shared_ptr<UserIDMCoAuthHandler> callback_; 61 DISALLOW_COPY_AND_MOVE(CoAuthCallbackDeathRecipient); 62 }; 63 64 class SetPropCallbackDeathRecipient : public IRemoteObject::DeathRecipient { 65 public: 66 SetPropCallbackDeathRecipient(std::shared_ptr<UserIDMSetPropHandler> callback); 67 ~SetPropCallbackDeathRecipient() = default; 68 void OnRemoteDied(const wptr<IRemoteObject>& remote) override; 69 private: 70 std::shared_ptr<UserIDMSetPropHandler> callback_; 71 DISALLOW_COPY_AND_MOVE(SetPropCallbackDeathRecipient); 72 }; 73 74 std::shared_ptr<UserIDMModule> data_; 75 }; 76 } // namespace UserIDM 77 } // namespace UserIAM 78 } // namespace OHOS 79 80 #endif // USERIDM_CONTROLLER_H 81