1 /* 2 * Copyright (c) 2023-2024 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_CONTROL_H 17 #define ACCESS_CONTROL_H 18 #include "softbus_app_info.h" 19 20 #ifdef __cplusplus 21 #if __cplusplus 22 extern "C" { 23 #endif 24 #endif 25 26 // if the upstream module does not set the first caller tokenID, the value is 0 27 #define TOKENID_NOT_SET 0 28 29 enum FirstTokenType { 30 FOREGROUND_APP_TYPE = 1, 31 BACKGROUND_APP_TYPE = 2, 32 TOKEN_HAP_TYPE = 3, 33 SYSTEM_SA_TYPE = 4, 34 TOKEN_SHELL_TYPE = 5, 35 }; 36 37 int32_t TransCheckClientAccessControl(const char *peerNetworkId); 38 int32_t CheckSecLevelPublic(const char *mySessionName, const char *peerSessionName); 39 int32_t TransCheckServerAccessControl(const AppInfo *appInfo); 40 uint64_t TransACLGetFirstTokenID(void); 41 uint64_t TransACLGetCallingTokenID(void); 42 void TransGetTokenInfo(uint64_t callingId, char *tokenName, int32_t nameLen, int32_t *tokenType); 43 44 #ifdef __cplusplus 45 #if __cplusplus 46 } 47 #endif /* __cplusplus */ 48 #endif /* __cplusplus */ 49 50 #endif /* ACCESS_CONTROL_H */ 51