• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 IAM_CONTEXT_FACTORY_H
17 #define IAM_CONTEXT_FACTORY_H
18 
19 #include <cstdint>
20 #include <map>
21 #include <memory>
22 #include <string>
23 
24 #include "singleton.h"
25 #include "authentication_impl.h"
26 #include "enrollment_impl.h"
27 #include "context.h"
28 #include "context_callback.h"
29 #include "identification_impl.h"
30 
31 namespace OHOS {
32 namespace UserIam {
33 namespace UserAuth {
34 class ContextFactory : public DelayedSingleton<ContextFactory> {
35 public:
36     struct AuthWidgetContextPara {
37         struct AuthProfile {
38             int32_t pinSubType {0};
39             std::string sensorInfo {""};
40             int32_t remainTimes {0};
41             int32_t freezingTime {0};
42         };
43 
44         int32_t userId {0};
45         int32_t sdkVersion {0};
46         uint32_t tokenId {0};
47         std::string callingBundleName {""};
48         std::string callerName {""};
49         std::vector<uint8_t> challenge {};
50         std::vector<AuthType> authTypeList {};
51         AuthTrustLevel atl {ATL1};
52         WidgetParam widgetParam {};
53         std::map<AuthType, AuthProfile> authProfileMap {};
54     };
55     static std::shared_ptr<Context> CreateSimpleAuthContext(const Authentication::AuthenticationPara &para,
56         const std::shared_ptr<ContextCallback> &callback);
57     static std::shared_ptr<Context> CreateIdentifyContext(const Identification::IdentificationPara &para,
58         const std::shared_ptr<ContextCallback> &callback);
59     static std::shared_ptr<Context> CreateEnrollContext(const Enrollment::EnrollmentPara &para,
60         const std::shared_ptr<ContextCallback> &callback);
61     static std::shared_ptr<Context> CreateWidgetAuthContext(std::shared_ptr<ContextCallback> callback);
62     static std::shared_ptr<Context> CreateWidgetContext(const AuthWidgetContextPara &para,
63         std::shared_ptr<ContextCallback> callback);
64 };
65 } // namespace UserAuth
66 } // namespace UserIam
67 } // namespace OHOS
68 #endif // IAM_CONTEXT_FACTORY_H