• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef ACCESSTOKEN_MANAGER_PROXY_H
17 #define ACCESSTOKEN_MANAGER_PROXY_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "access_token.h"
23 #include "atm_tools_param_info_parcel.h"
24 #include "hap_info_parcel.h"
25 #include "hap_base_info_parcel.h"
26 #include "hap_policy_parcel.h"
27 #include "hap_token_info_parcel.h"
28 #include "hap_token_info_for_sync_parcel.h"
29 #include "i_accesstoken_manager.h"
30 #include "iremote_proxy.h"
31 #include "native_token_info_for_sync_parcel.h"
32 #include "native_token_info_parcel.h"
33 #include "permission_def_parcel.h"
34 #include "permission_grant_info_parcel.h"
35 #include "permission_list_state_parcel.h"
36 #include "permission_state_full_parcel.h"
37 
38 namespace OHOS {
39 namespace Security {
40 namespace AccessToken {
41 class AccessTokenManagerProxy : public IRemoteProxy<IAccessTokenManager> {
42 public:
43     explicit AccessTokenManagerProxy(const sptr<IRemoteObject>& impl);
44     ~AccessTokenManagerProxy() override;
45 
46     int VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName) override;
47     int GetDefPermission(const std::string& permissionName, PermissionDefParcel& permissionDefResult) override;
48     int GetDefPermissions(AccessTokenID tokenID, std::vector<PermissionDefParcel>& permList) override;
49     int GetReqPermissions(
50         AccessTokenID tokenID, std::vector<PermissionStateFullParcel>& reqPermList, bool isSystemGrant) override;
51     int GetPermissionFlag(AccessTokenID tokenID, const std::string& permissionName, uint32_t& flag) override;
52     int GrantPermission(AccessTokenID tokenID, const std::string& permissionName, uint32_t flag) override;
53     int RevokePermission(AccessTokenID tokenID, const std::string& permissionName, uint32_t flag) override;
54     PermissionOper GetSelfPermissionsState(std::vector<PermissionListStateParcel>& permListParcel,
55         PermissionGrantInfoParcel& infoParcel) override;
56     int ClearUserGrantedPermissionState(AccessTokenID tokenID) override;
57     int GetTokenType(AccessTokenID tokenID) override;
58     int CheckNativeDCap(AccessTokenID tokenID, const std::string& dcap) override;
59     AccessTokenIDEx GetHapTokenID(int32_t userID, const std::string& bundleName, int32_t instIndex) override;
60     AccessTokenID AllocLocalTokenID(const std::string& remoteDeviceID, AccessTokenID remoteTokenID) override;
61     AccessTokenIDEx AllocHapToken(const HapInfoParcel& hapInfo, const HapPolicyParcel& policyParcel) override;
62     int DeleteToken(AccessTokenID tokenID) override;
63     int UpdateHapToken(AccessTokenIDEx& tokenIdEx, bool isSystemApp, const std::string& appIDDesc, int32_t apiVersion,
64         const HapPolicyParcel& policyParcel) override;
65     int GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfoParcel& hapTokenInfoRes) override;
66     int GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfoParcel& nativeTokenInfoRes) override;
67 #ifndef ATM_BUILD_VARIANT_USER_ENABLE
68     int32_t ReloadNativeTokenInfo() override;
69 #endif
70     int32_t RegisterPermStateChangeCallback(
71         const PermStateChangeScopeParcel& scope, const sptr<IRemoteObject>& callback) override;
72     int32_t UnRegisterPermStateChangeCallback(const sptr<IRemoteObject>& callback) override;
73     AccessTokenID GetNativeTokenId(const std::string& processName) override;
74 
75 #ifdef TOKEN_SYNC_ENABLE
76     int GetHapTokenInfoFromRemote(AccessTokenID tokenID, HapTokenInfoForSyncParcel& hapSyncParcel) override;
77     int GetAllNativeTokenInfo(std::vector<NativeTokenInfoForSyncParcel>& nativeTokenInfoRes) override;
78     int SetRemoteHapTokenInfo(const std::string& deviceID, HapTokenInfoForSyncParcel& hapSyncParcel) override;
79     int SetRemoteNativeTokenInfo(const std::string& deviceID,
80         std::vector<NativeTokenInfoForSyncParcel>& nativeTokenInfoForSyncParcel) override;
81     int DeleteRemoteToken(const std::string& deviceID, AccessTokenID tokenID) override;
82     AccessTokenID GetRemoteNativeTokenID(const std::string& deviceID, AccessTokenID tokenID) override;
83     int DeleteRemoteDeviceTokens(const std::string& deviceID) override;
84 #endif
85 
86     int32_t SetPermDialogCap(const HapBaseInfoParcel& hapBaseInfo, bool enable) override;
87     void DumpTokenInfo(const AtmToolsParamInfoParcel& infoParcel, std::string& dumpInfo) override;
88 
89 private:
90     bool SendRequest(AccessTokenInterfaceCode code, MessageParcel& data, MessageParcel& reply);
91     static inline BrokerDelegator<AccessTokenManagerProxy> delegator_;
92 };
93 } // namespace AccessToken
94 } // namespace Security
95 } // namespace OHOS
96 #endif // ACCESSTOKEN_MANAGER_PROXY_H
97