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_INTERFACE_H 17 #define USER_AUTH_INTERFACE_H 18 19 #include <cstdint> 20 #include <optional> 21 22 #include "iremote_broker.h" 23 #include "refbase.h" 24 25 #include "attributes.h" 26 #include "user_auth_callback_interface.h" 27 28 namespace OHOS { 29 namespace UserIam { 30 namespace UserAuth { 31 class UserAuthInterface : public IRemoteBroker { 32 public: 33 /* Message ID */ 34 enum : uint32_t { 35 USER_AUTH_GET_AVAILABLE_STATUS = 0, 36 USER_AUTH_GET_PROPERTY, 37 USER_AUTH_SET_PROPERTY, 38 USER_AUTH_AUTH, 39 USER_AUTH_AUTH_USER, 40 USER_AUTH_CANCEL_AUTH, 41 USER_AUTH_GET_VERSION, 42 USER_AUTH_ON_RESULT, 43 USER_AUTH_GET_EX_PROP, 44 USER_AUTH_SET_EX_PROP, 45 USER_AUTH_ACQUIRE_INFO, 46 USER_AUTH_IDENTIFY, 47 USER_AUTH_CANCEL_IDENTIFY, 48 USER_AUTH_ON_IDENTIFY_RESULT, 49 }; 50 51 virtual int32_t GetAvailableStatus(int32_t apiVersion, AuthType authType, AuthTrustLevel authTrustLevel) = 0; 52 53 virtual void GetProperty(int32_t userId, AuthType authType, 54 const std::vector<Attributes::AttributeKey> &keys, sptr<GetExecutorPropertyCallbackInterface> &callback) = 0; 55 56 virtual void SetProperty(int32_t userId, AuthType authType, const Attributes &attributes, 57 sptr<SetExecutorPropertyCallbackInterface> &callback) = 0; 58 59 virtual uint64_t AuthUser(int32_t userId, const std::vector<uint8_t> &challenge, AuthType authType, 60 AuthTrustLevel authTrustLevel, sptr<UserAuthCallbackInterface> &callback) = 0; 61 62 virtual uint64_t Auth(int32_t apiVersion, const std::vector<uint8_t> &challenge, AuthType authType, 63 AuthTrustLevel authTrustLevel, sptr<UserAuthCallbackInterface> &callback) = 0; 64 65 virtual uint64_t Identify(const std::vector<uint8_t> &challenge, AuthType authType, 66 sptr<UserAuthCallbackInterface> &callback) = 0; 67 68 virtual int32_t CancelAuthOrIdentify(uint64_t contextId) = 0; 69 70 virtual int32_t GetVersion(int32_t &version) = 0; 71 72 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.UserIam.UserAuth.IUserAuth"); 73 }; 74 } // namespace UserAuth 75 } // namespace UserIam 76 } // namespace OHOS 77 #endif // USER_AUTH_INTERFACE_H