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 GetPropertyById(uint64_t credentialId, const std::vector<Attributes::AttributeKey> &keys, 38 sptr<GetExecutorPropertyCallbackInterface> &callback) override; 39 void SetProperty(int32_t userId, AuthType authType, const Attributes &attributes, 40 sptr<SetExecutorPropertyCallbackInterface> &callback) override; 41 uint64_t AuthUser(AuthParamInner ¶m, std::optional<RemoteAuthParam> &remoteAuthParam, 42 sptr<UserAuthCallbackInterface> &callback) override; 43 uint64_t Auth(int32_t apiVersion, const std::vector<uint8_t> &challenge, AuthType authType, 44 AuthTrustLevel authTrustLevel, sptr<UserAuthCallbackInterface> &callback) override; 45 uint64_t AuthWidget(int32_t apiVersion, const AuthParamInner &authParam, 46 const WidgetParam &widgetParam, sptr<UserAuthCallbackInterface> &callback) override; 47 uint64_t Identify(const std::vector<uint8_t> &challenge, AuthType authType, 48 sptr<UserAuthCallbackInterface> &callback) override; 49 int32_t CancelAuthOrIdentify(uint64_t contextId) override; 50 int32_t GetVersion(int32_t &version) override; 51 int32_t Notice(NoticeType noticeType, const std::string &eventData) override; 52 int32_t RegisterWidgetCallback(int32_t version, sptr<WidgetCallbackInterface> &callback) override; 53 int32_t GetEnrolledState(int32_t apiVersion, AuthType authType, EnrolledState &enrolledState) override; 54 int32_t RegistUserAuthSuccessEventListener(const std::vector<AuthType> &authType, 55 const sptr<AuthEventListenerInterface> &listener) override; 56 int32_t UnRegistUserAuthSuccessEventListener( 57 const sptr<AuthEventListenerInterface> &listener) override; 58 int32_t SetGlobalConfigParam(const GlobalConfigParam ¶m) override; 59 int32_t PrepareRemoteAuth(const std::string &networkId, sptr<UserAuthCallbackInterface> &callback) override; 60 61 private: 62 static inline BrokerDelegator<UserAuthProxy> delegator_; 63 bool WriteAuthParam(MessageParcel &data, const AuthParamInner &authParam); 64 bool WriteRemoteAuthParam(MessageParcel &data, const std::optional<RemoteAuthParam> &remoteAuthParam); 65 bool WriteOptionalString(MessageParcel &data, const std::optional<std::string> &str); 66 bool WriteOptionalUint32(MessageParcel &data, const std::optional<uint32_t> &val); 67 bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply); 68 bool WriteWidgetAuthParam(MessageParcel &data, const AuthParamInner &authParam); 69 bool WriteWidgetParam(MessageParcel &data, const WidgetParam &widgetParam); 70 int32_t GetAvailableStatusInner(int32_t apiVersion, AuthType authType, AuthTrustLevel authTrustLevel, 71 MessageParcel &data); 72 }; 73 } // namespace UserAuth 74 } // namespace UserIam 75 } // namespace OHOS 76 #endif // USER_AUTH_PROXY_H