• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 SUDO_IAM_H
17 #define SUDO_IAM_H
18 #include <condition_variable>
19 #include <mutex>
20 #include "i_inputer.h"
21 #include "user_auth_client_callback.h"
22 
23 extern std::condition_variable g_condVarForAuth;
24 extern bool g_authFinish;
25 extern std::mutex g_mutexForAuth;
26 
27 namespace OHOS {
28 namespace UserIam {
29 namespace PinAuth {
30 
31 class SudoIInputer : public IInputer {
32 public:
33     virtual ~SudoIInputer();
34     void OnGetData(int32_t authSubType, std::vector<uint8_t> challenge,
35                                 std::shared_ptr<IInputerData> inputerData) override;
36     void SetPasswd(char *pwd, int len);
37 private:
38     std::vector<uint8_t> passwd_;
39 };
40 } // PinAuth
41 
42 namespace UserAuth {
43 class SudoIDMCallback : public AuthenticationCallback {
44 public:
45     virtual ~SudoIDMCallback();
46     SudoIDMCallback();
47     void OnAcquireInfo(int32_t module, uint32_t acquireInfo,
48                           const OHOS::UserIam::UserAuth::Attributes &extraInfo) override;
49     void OnResult(int32_t result,
50                           const OHOS::UserIam::UserAuth::Attributes &extraInfo) override;
51     bool GetVerifyResult(void);
52     std::vector<uint8_t> GetAuthToken();
53 private:
54     bool verifyResult_;
55     std::vector<uint8_t> authToken_;
56 };
57 } // UserAuth
58 
59 } // UserIam
60 } // OHOS
61 #endif  //SUDO_IAM_H
62