• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 INTERFACES_INNER_KITS_ACCESSTOKEN_KIT_H
17 #define INTERFACES_INNER_KITS_ACCESSTOKEN_KIT_H
18 
19 #include "access_token.h"
20 #include "native_token_info.h"
21 #include "hap_token_info.h"
22 
23 namespace OHOS {
24 namespace Security {
25 namespace AccessToken {
26 
27 class AccessTokenKit {
28 public:
GetTokenTypeFlag(AccessTokenID tokenID)29     static ATokenTypeEnum GetTokenTypeFlag(AccessTokenID tokenID)
30     {
31         return getTokenTypeFlagRet;
32     }
33 
GetNativeTokenInfo(AccessTokenID tokenID,NativeTokenInfo & nativeTokenInfoRes)34     static int32_t GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfo &nativeTokenInfoRes)
35     {
36         nativeTokenInfoRes = nativeTokenInfo;
37         return getNativeTokenInfoRet;
38     }
39 
GetHapTokenInfo(AccessTokenID tokenID,HapTokenInfo & hapInfoRes)40     static int GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfo &hapInfoRes)
41     {
42         hapInfoRes = hapInfo;
43         return getHapTokenInfoRet;
44     }
45 
InitMockResult()46     static void InitMockResult()
47     {
48         getNativeTokenInfoRet = 0;
49         getHapTokenInfoRet = 0;
50         nativeTokenInfo = NativeTokenInfo();
51         hapInfo = HapTokenInfo();
52     }
53 
54     static NativeTokenInfo nativeTokenInfo;
55     static HapTokenInfo hapInfo;
56     static int32_t getNativeTokenInfoRet;
57     static int32_t getHapTokenInfoRet;
58     static ATokenTypeEnum getTokenTypeFlagRet;
59 };
60 } // namespace AccessToken
61 } // namespace Security
62 } // namespace OHOS
63 #endif