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 }; 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 /** instance 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 128 /** 129 * @brief Declares hap base token info class 130 */ 131 class HapBaseInfo final { 132 public: 133 int32_t userID; 134 std::string bundleName = ""; 135 /** instance index */ 136 int32_t instIndex = 0; 137 }; 138 139 } // namespace AccessToken 140 } // namespace Security 141 } // namespace OHOS 142 #endif // ACCESSTOKEN_HAP_TOKEN_INFO_H 143