1 /* 2 * Copyright (c) 2022-2024 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_PROXY_H 17 #define USER_AUTH_PROXY_H 18 19 #include "iremote_proxy.h" 20 #include "message_parcel.h" 21 #include "nocopyable.h" 22 #include "user_auth_interface.h" 23 24 namespace OHOS { 25 namespace UserIam { 26 namespace UserAuth { 27 class UserAuthProxy : public IRemoteProxy<UserAuthInterface>, public NoCopyable { 28 public: 29 explicit UserAuthProxy(const sptr<IRemoteObject> &object); 30 ~UserAuthProxy() override = default; 31 int32_t GetAvailableStatus(int32_t apiVersion, int32_t userId, AuthType authType, 32 AuthTrustLevel authTrustLevel) override; 33 int32_t GetAvailableStatus(int32_t apiVersion, AuthType authType, AuthTrustLevel authTrustLevel) override; 34 void GetProperty(int32_t userId, AuthType authType, 35 const std::vector<Attributes::AttributeKey> &keys, 36 sptr<GetExecutorPropertyCallbackInterface> &callback) override; 37 void SetProperty(int32_t userId, AuthType authType, const Attributes &attributes, 38 sptr<SetExecutorPropertyCallbackInterface> &callback) override; 39 uint64_t AuthUser(AuthParamInner ¶m, std::optional<RemoteAuthParam> &remoteAuthParam, 40 sptr<UserAuthCallbackInterface> &callback) override; 41 uint64_t Auth(int32_t apiVersion, const std::vector<uint8_t> &challenge, AuthType authType, 42 AuthTrustLevel authTrustLevel, sptr<UserAuthCallbackInterface> &callback) override; 43 uint64_t AuthWidget(int32_t apiVersion, const AuthParamInner &authParam, 44 const WidgetParam &widgetParam, sptr<UserAuthCallbackInterface> &callback) override; 45 uint64_t Identify(const std::vector<uint8_t> &challenge, AuthType authType, 46 sptr<UserAuthCallbackInterface> &callback) override; 47 int32_t CancelAuthOrIdentify(uint64_t contextId) override; 48 int32_t GetVersion(int32_t &version) override; 49 int32_t Notice(NoticeType noticeType, const std::string &eventData) override; 50 int32_t RegisterWidgetCallback(int32_t version, sptr<WidgetCallbackInterface> &callback) override; 51 int32_t GetEnrolledState(int32_t apiVersion, AuthType authType, EnrolledState &enrolledState) override; 52 int32_t RegistUserAuthSuccessEventListener(const std::vector<AuthType> &authType, 53 const sptr<AuthEventListenerInterface> &listener) override; 54 int32_t UnRegistUserAuthSuccessEventListener( 55 const sptr<AuthEventListenerInterface> &listener) override; 56 int32_t SetGlobalConfigParam(const GlobalConfigParam ¶m) override; 57 int32_t PrepareRemoteAuth(const std::string &networkId, sptr<UserAuthCallbackInterface> &callback) override; 58 59 private: 60 static inline BrokerDelegator<UserAuthProxy> delegator_; 61 bool WriteAuthParam(MessageParcel &data, const AuthParamInner &authParam); 62 bool WriteRemoteAuthParam(MessageParcel &data, const std::optional<RemoteAuthParam> &remoteAuthParam); 63 bool WriteOptionalString(MessageParcel &data, const std::optional<std::string> &str); 64 bool WriteOptionalUint32(MessageParcel &data, const std::optional<uint32_t> &val); 65 bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply); 66 bool WriteWidgetAuthParam(MessageParcel &data, const AuthParamInner &authParam); 67 bool WriteWidgetParam(MessageParcel &data, const WidgetParam &widgetParam); 68 int32_t GetAvailableStatusInner(int32_t apiVersion, AuthType authType, AuthTrustLevel authTrustLevel, 69 MessageParcel &data); 70 }; 71 } // namespace UserAuth 72 } // namespace UserIam 73 } // namespace OHOS 74 #endif // USER_AUTH_PROXY_H