• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-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_FFI_STRUCT_H
17 #define USER_AUTH_FFI_STRUCT_H
18 
19 #include <functional>
20 
21 #include "user_auth_client_callback.h"
22 
23 namespace OHOS {
24 namespace UserIam {
25 namespace UserAuth {
26 struct CjAuthParam {
27     uint8_t *challenge;
28     int64_t challengeLen;
29     uint32_t *authTypes;
30     int64_t authTypesLen;
31     uint32_t authTrustLevel;
32     bool isReuse;
33     uint32_t reuseMode;
34     uint64_t reuseDuration;
35 };
36 
37 struct CjWidgetParam {
38     const char *title;
39     const char *navigationButtonText;
40 };
41 
42 struct CjUserAuthResult {
43     int32_t result;
44     uint8_t *token;
45     int64_t tokenLen;
46     uint32_t authType;
47     uint64_t credentialDigest;
48     uint16_t credentialCount;
49 };
50 
51 class CjUserAuthCallback final : public AuthenticationCallback {
52 public:
53     CjUserAuthCallback() = default;
CjUserAuthCallback(const std::function<void (CjUserAuthResult)> & onResult)54     explicit CjUserAuthCallback(const std::function<void(CjUserAuthResult)> &onResult) : onResult_(onResult) {}
55     virtual ~CjUserAuthCallback() = default;
56     void OnResult(int32_t result, const Attributes &extraInfo) override;
57     void OnAcquireInfo(int32_t module, uint32_t acquireInfo, const Attributes &extraInfo) override;
58 
59 private:
60     std::function<void(CjUserAuthResult)> onResult_;
61 };
62 
63 } // namespace UserAuth
64 } // namespace UserIam
65 } // namespace OHOS
66 
67 #endif // USER_AUTH_FFI_STRUCT_H
68