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_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, AuthType authType, AuthTrustLevel authTrustLevel) override; 32 void GetProperty(int32_t userId, AuthType authType, 33 const std::vector<Attributes::AttributeKey> &keys, 34 sptr<GetExecutorPropertyCallbackInterface> &callback) override; 35 void SetProperty(int32_t userId, AuthType authType, const Attributes &attributes, 36 sptr<SetExecutorPropertyCallbackInterface> &callback) override; 37 uint64_t AuthUser(int32_t userId, const std::vector<uint8_t> &challenge, AuthType authType, 38 AuthTrustLevel authTrustLevel, sptr<UserAuthCallbackInterface> &callback) override; 39 uint64_t Auth(int32_t apiVersion, const std::vector<uint8_t> &challenge, AuthType authType, 40 AuthTrustLevel authTrustLevel, sptr<UserAuthCallbackInterface> &callback) override; 41 uint64_t Identify(const std::vector<uint8_t> &challenge, AuthType authType, 42 sptr<UserAuthCallbackInterface> &callback) override; 43 int32_t CancelAuthOrIdentify(uint64_t contextId) override; 44 int32_t GetVersion(int32_t &version) override; 45 46 private: 47 static inline BrokerDelegator<UserAuthProxy> delegator_; 48 bool WriteAuthParam(MessageParcel &data, const std::vector<uint8_t> &challenge, 49 AuthType authType, AuthTrustLevel authTrustLevel, sptr<UserAuthCallbackInterface> &callback); 50 bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply); 51 }; 52 } // namespace UserAuth 53 } // namespace UserIam 54 } // namespace OHOS 55 #endif // USER_AUTH_PROXY_H