• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "reminder_access_token_helper.h"
17 
18 #include "ans_log_wrapper.h"
19 #include "ipc_skeleton.h"
20 #include "tokenid_kit.h"
21 #include "reminder_utils.h"
22 
23 using namespace OHOS::Security::AccessToken;
24 
25 namespace OHOS {
26 namespace Notification {
IsSystemApp()27 bool ReminderAccessTokenHelper::IsSystemApp()
28 {
29     AccessTokenID tokenId = IPCSkeleton::GetCallingTokenID();
30     ATokenTypeEnum type = AccessTokenKit::GetTokenTypeFlag(tokenId);
31     if (type == ATokenTypeEnum::TOKEN_HAP) {
32         uint64_t fullTokenId = IPCSkeleton::GetCallingFullTokenID();
33         if (Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(fullTokenId)) {
34             return true;
35         }
36     }
37     return false;
38 }
39 
VerifyNativeToken(const AccessTokenID & callerToken)40 bool ReminderAccessTokenHelper::VerifyNativeToken(const AccessTokenID &callerToken)
41 {
42     ATokenTypeEnum tokenType = AccessTokenKit::GetTokenTypeFlag(callerToken);
43     return (tokenType == ATokenTypeEnum::TOKEN_NATIVE);
44 }
45 }  // namespace Notification
46 }  // namespace OHOS
47