• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 ACCESS_TOKEN_DEF_H
17 #define ACCESS_TOKEN_DEF_H
18 
19 namespace OHOS {
20 namespace Security {
21 namespace AccessToken {
22 typedef unsigned int AccessTokenID;
23 typedef unsigned int AccessTokenAttr;
24 static const int DEFAULT_TOKEN_VERSION = 1;
25 static const AccessTokenID INVALID_TOKENID = 0;
26 
27 enum AccessTokenKitRet {
28     RET_FAILED = -1,
29     RET_SUCCESS = 0,
30 };
31 
32 typedef struct {
33     unsigned int tokenUniqueID : 20;
34     unsigned int res : 6;
35     unsigned int dlpFlag : 1;
36     unsigned int type : 2;
37     unsigned int version : 3;
38 } AccessTokenIDInner;
39 
40 typedef enum TypeATokenTypeEnum {
41     TOKEN_INVALID = -1,
42     TOKEN_HAP = 0,
43     TOKEN_NATIVE,
44     TOKEN_SHELL,
45     TOKEN_TYPE_BUTT,
46 } ATokenTypeEnum;
47 
48 typedef enum TypeATokenAplEnum {
49     APL_INVALID = 0,
50     APL_NORMAL = 1,
51     APL_SYSTEM_BASIC = 2,
52     APL_SYSTEM_CORE = 3,
53 } ATokenAplEnum;
54 
55 typedef union {
56     unsigned long long tokenIDEx;
57     struct {
58         AccessTokenID tokenID;
59         AccessTokenAttr tokenAttr;
60     } tokenIdExStruct;
61 } AccessTokenIDEx;
62 
63 typedef enum TypePermissionState {
64     PERMISSION_DENIED = -1,
65     PERMISSION_GRANTED = 0,
66 } PermissionState;
67 
68 typedef enum TypeGrantMode {
69     USER_GRANT = 0,
70     SYSTEM_GRANT = 1,
71 } GrantMode;
72 
73 typedef enum TypePermissionFlag {
74     PERMISSION_DEFAULT_FLAG = 0,
75     PERMISSION_USER_SET = 1 << 0,
76     PERMISSION_USER_FIXED = 1 << 1,
77     PERMISSION_SYSTEM_FIXED = 1 << 2,
78     PERMISSION_GRANTED_BY_POLICY = 1 << 3,
79 } PermissionFlag;
80 
81 typedef enum TypePermissionOper {
82     SETTING_OPER = -1,
83     PASS_OPER = 0,
84     DYNAMIC_OPER = 1,
85     INVALID_OPER = 2,
86 } PermissionOper;
87 
88 typedef enum DlpType {
89     DLP_COMMON = 0,
90     DLP_READ = 1,
91     DLP_FULL_CONTROL = 2,
92 } HapDlpType;
93 
94 typedef enum TypeDlpPerm {
95     DLP_PERM_ALL = 0,
96     DLP_PERM_FULL_CONTROL = 1,
97     DLP_PERM_NONE = 2,
98 } DlpPermMode;
99 } // namespace AccessToken
100 } // namespace Security
101 } // namespace OHOS
102 #endif // ACCESS_TOKEN_DEF_H
103