• 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 int DEFAULT_PERMISSION_FLAGS = 0;
26 static const int FIRSTCALLER_TOKENID_DEFAULT = 0;
27 static const int MAX_PERMISSION_SIZE = 1000;
28 static const int MAX_NATIVE_TOKEN_INFO_SIZE = 20480;
29 
30 enum AccessTokenKitRet {
31     RET_FAILED = -1,
32     RET_SUCCESS = 0,
33 };
34 
35 typedef struct {
36     unsigned int tokenUniqueID : 20;
37     unsigned int res : 7;
38     unsigned int type : 2;
39     unsigned int version : 3;
40 } AccessTokenIDInner;
41 
42 typedef enum TypeATokenTypeEnum {
43     TOKEN_INVALID = -1,
44     TOKEN_HAP = 0,
45     TOKEN_NATIVE,
46 } ATokenTypeEnum;
47 
48 typedef enum TypeATokenAplEnum {
49     APL_NORMAL = 1,
50     APL_SYSTEM_BASIC = 2,
51     APL_SYSTEM_CORE = 3,
52 } ATokenAplEnum;
53 
54 typedef union {
55     unsigned long long tokenIDEx;
56     struct {
57         AccessTokenID tokenID;
58         AccessTokenAttr tokenAttr;
59     } tokenIdExStruct;
60 } AccessTokenIDEx;
61 
62 typedef enum TypePermissionState {
63     PERMISSION_DENIED = -1,
64     PERMISSION_GRANTED = 0,
65 } PermissionState;
66 
67 typedef enum TypeGrantMode {
68     USER_GRANT = 0,
69     SYSTEM_GRANT = 1,
70 } GrantMode;
71 
72 typedef enum TypePermissionFlag {
73     PERMISSION_USER_SET = 1 << 0,
74     PERMISSION_USER_FIXED = 1 << 1,
75     PERMISSION_SYSTEM_FIXED = 1 << 2,
76 } PermissionFlag;
77 
78 typedef enum TypePermissionOper {
79     SETTING_OPER = -1,
80     PASS_OPER = 0,
81     DYNAMIC_OPER = 1,
82     INVALID_OPER = 2,
83 } PermissionOper;
84 } // namespace AccessToken
85 } // namespace Security
86 } // namespace OHOS
87 #endif // ACCESS_TOKEN_DEF_H
88