• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 IAM_CONTEXT_FACTORY_H
17 #define IAM_CONTEXT_FACTORY_H
18 
19 #include <cstdint>
20 #include <memory>
21 
22 #include "singleton.h"
23 
24 #include "context.h"
25 #include "context_callback.h"
26 
27 namespace OHOS {
28 namespace UserIam {
29 namespace UserAuth {
30 class ContextFactory : public DelayedSingleton<ContextFactory> {
31 public:
32     struct AuthContextPara {
33         int32_t userId {0};
34         AuthType authType {ALL};
35         AuthTrustLevel atl {ATL1};
36         uint32_t tokenId {0};
37         std::vector<uint8_t> challenge;
38     };
39 
40     struct IdentifyContextPara {
41         AuthType authType {ALL};
42         uint32_t tokenId {0};
43         std::vector<uint8_t> challenge;
44     };
45 
46     struct EnrollContextPara {
47         int32_t userId {0};
48         AuthType authType {ALL};
49         PinSubType pinType {PIN_SIX};
50         uint32_t tokenId {0};
51         std::vector<uint8_t> token;
52     };
53     static std::shared_ptr<Context> CreateSimpleAuthContext(const AuthContextPara &para,
54         const std::shared_ptr<ContextCallback> &callback);
55     static std::shared_ptr<Context> CreateIdentifyContext(const IdentifyContextPara &para,
56         const std::shared_ptr<ContextCallback> &callback);
57     static std::shared_ptr<Context> CreateEnrollContext(const EnrollContextPara &para,
58         const std::shared_ptr<ContextCallback> &callback);
59     static std::shared_ptr<Context> CreateWidgetAuthContext(std::shared_ptr<ContextCallback> callback);
60 };
61 } // namespace UserAuth
62 } // namespace UserIam
63 } // namespace OHOS
64 #endif // IAM_CONTEXT_FACTORY_H