• 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 MOCK_IPC_COMMON_H
17 #define MOCK_IPC_COMMON_H
18 
19 #include <cinttypes>
20 #include <iremote_stub.h>
21 #include <optional>
22 #include <string>
23 #include <set>
24 
25 #include "nocopyable.h"
26 
27 namespace OHOS {
28 namespace UserIam {
29 namespace UserAuth {
30 enum Permission {
31     MANAGE_USER_IDM_PERMISSION,
32     USE_USER_IDM_PERMISSION,
33     ACCESS_USER_AUTH_INTERNAL_PERMISSION,
34     ACCESS_BIOMETRIC_PERMISSION,
35     ACCESS_AUTH_RESPOOL,
36     ENFORCE_USER_IDM,
37 };
38 
39 class IpcCommon final : public NoCopyable {
40 public:
41     static int32_t GetCallingUserId(IPCObjectStub &stub, int32_t &userId);
42     static int32_t GetActiveUserId(std::optional<int32_t> &userId);
43     static bool CheckPermission(IPCObjectStub &stub, Permission permission);
44     static uint32_t GetAccessTokenId(IPCObjectStub &stub);
45     static void AddPermission(Permission perm);
46     static void DeleteAllPermission();
47 
48 private:
49     static std::set<Permission> permSet_;
50 };
51 } // namespace UserAuth
52 } // namespace UserIam
53 } // namespace OHOS
54 #endif // MOCK_IPC_COMMON_H