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_STUB_H 17 #define ACCESSTOKEN_MANAGER_STUB_H 18 19 #include "i_accesstoken_manager.h" 20 21 #include <map> 22 23 #include "iremote_stub.h" 24 #include "nocopyable.h" 25 26 namespace OHOS { 27 namespace Security { 28 namespace AccessToken { 29 class AccessTokenManagerStub : public IRemoteStub<IAccessTokenManager> { 30 public: 31 AccessTokenManagerStub(); 32 virtual ~AccessTokenManagerStub(); 33 34 int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& options) override; 35 36 private: 37 void VerifyAccessTokenInner(MessageParcel& data, MessageParcel& reply); 38 void GetDefPermissionInner(MessageParcel& data, MessageParcel& reply); 39 void GetDefPermissionsInner(MessageParcel& data, MessageParcel& reply); 40 void GetReqPermissionsInner(MessageParcel& data, MessageParcel& reply); 41 void GetSelfPermissionsStateInner(MessageParcel& data, MessageParcel& reply); 42 void GetPermissionFlagInner(MessageParcel& data, MessageParcel& reply); 43 void GrantPermissionInner(MessageParcel& data, MessageParcel& reply); 44 void RevokePermissionInner(MessageParcel& data, MessageParcel& reply); 45 void ClearUserGrantedPermissionStateInner(MessageParcel& data, MessageParcel& reply); 46 void AllocHapTokenInner(MessageParcel& data, MessageParcel& reply); 47 void DeleteTokenInfoInner(MessageParcel& data, MessageParcel& reply); 48 void AllocNativeTokenInner(MessageParcel& data, MessageParcel& reply); 49 void UpdateHapTokenInner(MessageParcel& data, MessageParcel& reply); 50 void GetHapTokenInfoInner(MessageParcel& data, MessageParcel& reply); 51 void GetNativeTokenInfoInner(MessageParcel& data, MessageParcel& reply); 52 void AllocLocalTokenIDInner(MessageParcel& data, MessageParcel& reply); 53 void GetHapTokenIDInner(MessageParcel& data, MessageParcel& reply); 54 void CheckNativeDCapInner(MessageParcel& data, MessageParcel& reply); 55 void GetTokenTypeInner(MessageParcel& data, MessageParcel& reply); 56 void RegisterPermStateChangeCallbackInner(MessageParcel& data, MessageParcel& reply); 57 void UnRegisterPermStateChangeCallbackInner(MessageParcel& data, MessageParcel& reply); 58 void ReloadNativeTokenInfoInner(MessageParcel& data, MessageParcel& reply); 59 void GetNativeTokenIdInner(MessageParcel& data, MessageParcel& reply); 60 61 #ifdef TOKEN_SYNC_ENABLE 62 void GetHapTokenInfoFromRemoteInner(MessageParcel& data, MessageParcel& reply); 63 void GetAllNativeTokenInfoInner(MessageParcel& data, MessageParcel& reply); 64 void SetRemoteHapTokenInfoInner(MessageParcel& data, MessageParcel& reply); 65 void SetRemoteNativeTokenInfoInner(MessageParcel& data, MessageParcel& reply); 66 void DeleteRemoteTokenInner(MessageParcel& data, MessageParcel& reply); 67 void DeleteRemoteDeviceTokensInner(MessageParcel& data, MessageParcel& reply); 68 void GetRemoteNativeTokenIDInner(MessageParcel& data, MessageParcel& reply); 69 void GetRemoteHapTokenIDInner(MessageParcel& data, MessageParcel& reply); 70 #endif 71 72 void DumpTokenInfoInner(MessageParcel& data, MessageParcel& reply); 73 74 bool IsPrivilegedCalling() const; 75 bool IsAccessTokenCalling(); 76 bool IsNativeProcessCalling(); 77 bool IsFoundationCalling() const; 78 static const int32_t SYSTEM_UID = 1000; 79 static const int32_t ROOT_UID = 0; 80 static const int32_t ACCESSTOKEN_UID = 3020; 81 82 AccessTokenID tokenSyncId_ = 0; 83 84 using RequestFuncType = void (AccessTokenManagerStub::*)(MessageParcel &data, MessageParcel &reply); 85 std::map<uint32_t, RequestFuncType> requestFuncMap_; 86 }; 87 } // namespace AccessToken 88 } // namespace Security 89 } // namespace OHOS 90 #endif // ACCESSTOKEN_MANAGER_STUB_H 91