1 /* 2 * Copyright (c) 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 BASE_NOTIFICATION_CES_STANDARD_SERVICES_CES_INCLUDE_ACCESS_TOKEN_HELPER_H 17 #define BASE_NOTIFICATION_CES_STANDARD_SERVICES_CES_INCLUDE_ACCESS_TOKEN_HELPER_H 18 19 #include "accesstoken_kit.h" 20 21 namespace OHOS { 22 namespace EventFwk { 23 using namespace OHOS::Security; 24 class AccessTokenHelper { 25 public: 26 /** 27 * Verifies native token. 28 * 29 * @param callerToken Indicates the token of caller. 30 * @return Returns true if successful; false otherwise. 31 */ 32 static bool VerifyNativeToken(const AccessToken::AccessTokenID &callerToken); 33 static bool VerifyAccessToken(const AccessToken::AccessTokenID &callerToken, 34 const std::string &permission); 35 static void RecordSensitivePermissionUsage(const AccessToken::AccessTokenID &callerToken, 36 const std::string &event); 37 static bool IsDlpHap(const AccessToken::AccessTokenID &callerToken); 38 static AccessToken::AccessTokenID GetHapTokenID(int userID, const std::string& bundleName, int instIndex); 39 static bool VerifyShellToken(const AccessToken::AccessTokenID &callerToken); 40 static bool IsSystemApp(); 41 }; 42 } // namespace EventFwk 43 } // namespace OHOS 44 #endif // BASE_NOTIFICATION_CES_STANDARD_SERVICES_CES_INCLUDE_ACCESS_TOKEN_HELPER_H