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 USER_AUTH_CLIENT_IMPL_H 17 #define USER_AUTH_CLIENT_IMPL_H 18 19 #include "nocopyable.h" 20 21 #include "user_auth_client.h" 22 #include "user_auth_interface.h" 23 24 namespace OHOS { 25 namespace UserIam { 26 namespace UserAuth { 27 class UserAuthClientImpl final : public UserAuthClient, NoCopyable { 28 public: 29 static UserAuthClientImpl& Instance(); 30 int32_t GetAvailableStatus(AuthType authType, AuthTrustLevel authTrustLevel); 31 int32_t GetAvailableStatus(int32_t apiVersion, AuthType authType, AuthTrustLevel authTrustLevel); 32 void GetProperty(int32_t userId, const GetPropertyRequest &request, 33 const std::shared_ptr<GetPropCallback> &callback) override; 34 void SetProperty(int32_t userId, const SetPropertyRequest &request, 35 const std::shared_ptr<SetPropCallback> &callback) override; 36 uint64_t BeginAuthentication(int32_t userId, const std::vector<uint8_t> &challenge, AuthType authType, 37 AuthTrustLevel atl, const std::shared_ptr<AuthenticationCallback> &callback) override; 38 uint64_t BeginNorthAuthentication(int32_t apiVersion, const std::vector<uint8_t> &challenge, AuthType authType, 39 AuthTrustLevel atl, const std::shared_ptr<AuthenticationCallback> &callback); 40 int32_t CancelAuthentication(uint64_t contextId) override; 41 uint64_t BeginIdentification(const std::vector<uint8_t> &challenge, AuthType authType, 42 const std::shared_ptr<IdentificationCallback> &callback) override; 43 int32_t CancelIdentification(uint64_t contextId) override; 44 int32_t GetVersion(int32_t &version); 45 46 private: 47 friend class UserAuthClient; 48 UserAuthClientImpl() = default; 49 ~UserAuthClientImpl() override = default; 50 51 constexpr static int32_t MINIMUM_VERSION {0}; 52 constexpr static uint64_t INVALID_SESSION_ID {0}; 53 sptr<UserAuthInterface> GetProxy(); 54 }; 55 } // namespace UserAuth 56 } // namespace UserIam 57 } // namespace OHOS 58 #endif // USER_AUTH_CLIENT_IMPL_H