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 "token_sync_kit.h"
17
18 #include <string>
19 #include <vector>
20
21 #include "accesstoken_log.h"
22 #include "constant_common.h"
23 #include "token_sync_manager_client.h"
24
25 namespace OHOS {
26 namespace Security {
27 namespace AccessToken {
28 using namespace std;
29
30 namespace {
31 static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_ACCESSTOKEN, "TokenSyncKit"};
32 } // namespace
33
GetRemoteHapTokenInfo(const std::string & deviceID,AccessTokenID tokenID)34 int TokenSyncKit::GetRemoteHapTokenInfo(const std::string& deviceID, AccessTokenID tokenID)
35 {
36 ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called, deviceID=%{public}s tokenID=%{public}d",
37 __func__, ConstantCommon::EncryptDevId(deviceID).c_str(), tokenID);
38 return TokenSyncManagerClient::GetInstance().GetRemoteHapTokenInfo(deviceID, tokenID);
39 }
40
DeleteRemoteHapTokenInfo(AccessTokenID tokenID)41 int TokenSyncKit::DeleteRemoteHapTokenInfo(AccessTokenID tokenID)
42 {
43 ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called, tokenID=%{public}d", __func__, tokenID);
44 return TokenSyncManagerClient::GetInstance().DeleteRemoteHapTokenInfo(tokenID);
45 }
46
UpdateRemoteHapTokenInfo(const HapTokenInfoForSync & tokenInfo)47 int TokenSyncKit::UpdateRemoteHapTokenInfo(const HapTokenInfoForSync& tokenInfo)
48 {
49 ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called tokenID=%{public}d", __func__, tokenInfo.baseInfo.tokenID);
50 return TokenSyncManagerClient::GetInstance().UpdateRemoteHapTokenInfo(tokenInfo);
51 }
52 } // namespace AccessToken
53 } // namespace Security
54 } // namespace OHOS
55