1 /*
2  * Copyright (c) 2022-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 ACCESSTOKEN_CALLBACKS_H
17 #define ACCESSTOKEN_CALLBACKS_H
18 
19 
20 #include "accesstoken_callback_stubs.h"
21 #include "perm_state_change_callback_customize.h"
22 #ifdef TOKEN_SYNC_ENABLE
23 #include "token_sync_kit_interface.h"
24 #endif // TOKEN_SYNC_ENABLE
25 
26 namespace OHOS {
27 namespace Security {
28 namespace AccessToken {
29 class PermissionStateChangeCallback : public PermissionStateChangeCallbackStub {
30 public:
31     explicit PermissionStateChangeCallback(const std::shared_ptr<PermStateChangeCallbackCustomize>& customizedCallback);
32     ~PermissionStateChangeCallback() override;
33 
34     void PermStateChangeCallback(PermStateChangeInfo& result) override;
35 
36     void Stop();
37 
38 private:
39     std::shared_ptr<PermStateChangeCallbackCustomize> customizedCallback_;
40 };
41 
42 #ifdef TOKEN_SYNC_ENABLE
43 class TokenSyncCallback : public TokenSyncCallbackStub {
44 public:
45     explicit TokenSyncCallback(const std::shared_ptr<TokenSyncKitInterface>& tokenSyncCallback);
46     ~TokenSyncCallback() override;
47 
48     int32_t GetRemoteHapTokenInfo(const std::string& deviceID, AccessTokenID tokenID) override;
49     int32_t DeleteRemoteHapTokenInfo(AccessTokenID tokenID) override;
50     int32_t UpdateRemoteHapTokenInfo(const HapTokenInfoForSync& tokenInfo) override;
51 
52 private:
53     std::shared_ptr<TokenSyncKitInterface> tokenSyncCallback_;
54 };
55 #endif // TOKEN_SYNC_ENABLE
56 } // namespace AccessToken
57 } // namespace Security
58 } // namespace OHOS
59 #endif // ACCESSTOKEN_CALLBACKS_H
60