/* * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef USER_AUTH_SERVICE_H #define USER_AUTH_SERVICE_H #include "user_auth_stub.h" #include #include #include #include "context_callback.h" #include "context_factory.h" #include "context_pool.h" #include "resource_node_pool.h" #include "user_idm_database.h" namespace OHOS { namespace UserIam { namespace UserAuth { class UserAuthService : public SystemAbility, public UserAuthStub, public NoCopyable { public: DECLARE_SYSTEM_ABILITY(UserAuthService); explicit UserAuthService(int32_t systemAbilityId, bool runOnCreate = false); ~UserAuthService() override = default; int32_t GetAvailableStatus(int32_t apiVersion, AuthType authType, AuthTrustLevel authTrustLevel) override; void GetProperty(int32_t userId, AuthType authType, const std::vector &keys, sptr &callback) override; void SetProperty(int32_t userId, AuthType authType, const Attributes &attributes, sptr &callback) override; uint64_t AuthUser(int32_t userId, const std::vector &challenge, AuthType authType, AuthTrustLevel authTrustLevel, sptr &callback) override; uint64_t Auth(int32_t apiVersion, const std::vector &challenge, AuthType authType, AuthTrustLevel authTrustLevel, sptr &callback) override; uint64_t AuthWidget(int32_t apiVersion, const AuthParam &authParam, const WidgetParam &widgetParam, sptr &callback) override; uint64_t Identify(const std::vector &challenge, AuthType authType, sptr &callback) override; int32_t CancelAuthOrIdentify(uint64_t contextId) override; int32_t GetVersion(int32_t &version) override; int32_t Notice(NoticeType noticeType, const std::string &eventData) override; int32_t RegisterWidgetCallback(int32_t version, sptr &callback) override; protected: void OnStart() override; void OnStop() override; private: std::shared_ptr GetAuthContextCallback(int32_t apiVersion, const std::vector &challenge, AuthType authType, AuthTrustLevel authTrustLevel, sptr &callback); std::shared_ptr GetAuthContextCallback(int32_t apiVersion, const AuthParam &authParam, const WidgetParam &widgetParam, sptr &callback); bool CheckAuthTrustLevel(AuthTrustLevel authTrustLevel); bool CheckSingeFaceOrFinger(const std::vector &authType); int32_t CheckAuthWidgetType(const std::vector &authType); int32_t CheckAuthWidgetParam( int32_t userId, const AuthParam &authParam, const WidgetParam &widgetParam, std::vector &validType); uint64_t StartWidgetContext(const std::shared_ptr &contextCallback, const AuthParam &authParam, const WidgetParam &widgetParam, std::vector &validType, ContextFactory::AuthWidgetContextPara ¶); uint64_t StartAuthContext(int32_t apiVersion, Authentication::AuthenticationPara para, const std::shared_ptr &contextCallback); bool Insert2ContextPool(const std::shared_ptr &context); bool CheckCallerIsSystemApp(); int32_t CheckAuthPermissionAndParam(int32_t authType, bool isBundleName, const std::string &callerName, AuthTrustLevel authTrustLevel); }; } // namespace UserAuth } // namespace UserIam } // namespace OHOS #endif // USER_AUTH_SERVICE_H