• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 /**
17  * @addtogroup AccessToken
18  * @{
19  *
20  * @brief Provides permission management interfaces.
21  *
22  * Provides tokenID-based application permission verification mechanism.
23  * When an application accesses sensitive data or APIs, this module can check
24  * whether the application has the corresponding permission. Allows applications
25  * to query their access token information or APL levcels based on token IDs.
26  *
27  * @since 7.0
28  * @version 7.0
29  */
30 
31 /**
32  * @file hap_token_info.h
33  *
34  * @brief Declares hap token infos.
35  *
36  * @since 7.0
37  * @version 7.0
38  */
39 
40 #ifndef ACCESSTOKEN_HAP_TOKEN_INFO_H
41 #define ACCESSTOKEN_HAP_TOKEN_INFO_H
42 
43 #include "access_token.h"
44 #include "permission_def.h"
45 #include "permission_state_full.h"
46 #include <string>
47 #include <vector>
48 
49 namespace OHOS {
50 namespace Security {
51 namespace AccessToken {
52 /**
53  * @brief Declares hap info params class
54  */
55 class HapInfoParams final {
56 public:
57     int userID;
58     std::string bundleName;
59     /** instance index */
60     int instIndex;
61     /**
62      * dlp type, for details about the valid values,
63      * see the definition of HapDlpType in the access_token.h file.
64      */
65     int dlpType;
66     std::string appIDDesc;
67     /** which version of the SDK is used to develop the hap */
68     int32_t apiVersion;
69     /** indicates whether the hap is a system app */
70     bool isSystemApp;
71     /* app type */
72     std::string appDistributionType;
73     bool isRestore = false;
74     AccessTokenID tokenID = INVALID_TOKENID;
75 };
76 
77 /**
78  * @brief Declares hap info params class
79  */
80 class UpdateHapInfoParams final {
81 public:
82     std::string appIDDesc;
83     /** which version of the SDK is used to develop the hap */
84     int32_t apiVersion;
85     /** indicates whether the hap is a system app */
86     bool isSystemApp;
87     /* app type */
88     std::string appDistributionType;
89 };
90 
91 /**
92  * @brief Declares hap token info class
93  */
94 class HapTokenInfo final {
95 public:
96     /**
97      * apl level, for details about the valid values,
98      * see the definition of ATokenAplEnum in the access_token.h file.
99      */
100     ATokenAplEnum apl;
101     char ver;
102     int userID;
103     std::string bundleName;
104     /** which version of the SDK is used to develop this hap */
105     int32_t apiVersion;
106     /** instance index */
107     int instIndex;
108     /**
109      * dlp type, for details about the valid values,
110      * see the definition of HapDlpType in the access_token.h file.
111      */
112     int dlpType;
113     std::string appID;
114     std::string deviceID;
115     AccessTokenID tokenID;
116     /** token attribute */
117     AccessTokenAttr tokenAttr;
118 };
119 
120 /**
121  * @brief Declares hap token info for distributed synchronize class
122  */
123 class HapTokenInfoForSync final {
124 public:
125     /** hap token info */
126     HapTokenInfo baseInfo;
127     /** permission state list */
128     std::vector<PermissionStateFull> permStateList;
129 };
130 
131 /**
132  * @brief Declares hap base token info class
133  */
134 class HapBaseInfo final {
135 public:
136     int32_t userID;
137     std::string bundleName = "";
138     /** instance index */
139     int32_t instIndex = 0;
140 };
141 
142 /**
143  * @brief Pre-authorization token info class
144  */
145 class PreAuthorizationInfo final {
146 public:
147     std::string permissionName;
148     /** Whether the pre-authorization is non-cancelable */
149     bool userCancelable = false;
150 };
151 /**
152  * @brief Declares hap policy params class
153  */
154 class HapPolicyParams final {
155 public:
156     /**
157      * apl level, for details about the valid values,
158      * see the definition of ATokenAplEnum in the access_token.h file.
159      */
160     ATokenAplEnum apl;
161     std::string domain;
162     std::vector<PermissionDef> permList;
163     std::vector<PermissionStateFull> permStateList;
164     std::vector<std::string> aclRequestedList;
165     std::vector<PreAuthorizationInfo> preAuthorizationInfo;
166 };
167 
168 } // namespace AccessToken
169 } // namespace Security
170 } // namespace OHOS
171 #endif // ACCESSTOKEN_HAP_TOKEN_INFO_H
172