• 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     /** instcance 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 };
72 
73 /**
74  * @brief Declares hap policy params class
75  */
76 class HapPolicyParams final {
77 public:
78     /**
79      * apl level, for details about the valid values,
80      * see the definition of ATokenAplEnum in the access_token.h file.
81      */
82     ATokenAplEnum apl;
83     std::string domain;
84     std::vector<PermissionDef> permList;
85     std::vector<PermissionStateFull> permStateList;
86 };
87 
88 /**
89  * @brief Declares hap token info class
90  */
91 class HapTokenInfo final {
92 public:
93     /**
94      * apl level, for details about the valid values,
95      * see the definition of ATokenAplEnum in the access_token.h file.
96      */
97     ATokenAplEnum apl;
98     char ver;
99     int userID;
100     std::string bundleName;
101     /** which version of the SDK is used to develop this hap */
102     int32_t apiVersion;
103     /** instcance index */
104     int instIndex;
105     /**
106      * dlp type, for details about the valid values,
107      * see the definition of HapDlpType in the access_token.h file.
108      */
109     int dlpType;
110     std::string appID;
111     std::string deviceID;
112     AccessTokenID tokenID;
113     /** token attribute */
114     AccessTokenAttr tokenAttr;
115 };
116 
117 /**
118  * @brief Declares hap token info for distributed synchronize class
119  */
120 class HapTokenInfoForSync final {
121 public:
122     /** hap token info */
123     HapTokenInfo baseInfo;
124     /** permission state list */
125     std::vector<PermissionStateFull> permStateList;
126 };
127 } // namespace AccessToken
128 } // namespace Security
129 } // namespace OHOS
130 #endif // ACCESSTOKEN_HAP_TOKEN_INFO_H
131