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 #ifndef ACCESSTOKEN_TOKEN_REMOTE_TOKEN_MANAGER_H 17 #define ACCESSTOKEN_TOKEN_REMOTE_TOKEN_MANAGER_H 18 19 #include <map> 20 #include <memory> 21 #include <vector> 22 23 #include "access_token.h" 24 #include "hap_token_info.h" 25 #include "hap_token_info_inner.h" 26 #include "native_token_info.h" 27 #include "native_token_info_inner.h" 28 #include "nocopyable.h" 29 #include "rwlock.h" 30 #include "thread_pool.h" 31 32 namespace OHOS { 33 namespace Security { 34 namespace AccessToken { 35 class AccessTokenRemoteDevice final { 36 public: 37 std::string DeviceID_; // networkID 38 std::map<AccessTokenID, AccessTokenID> MappingTokenIDPairMap_; 39 }; 40 41 class AccessTokenRemoteTokenManager final { 42 public: 43 static AccessTokenRemoteTokenManager& GetInstance(); 44 ~AccessTokenRemoteTokenManager(); 45 AccessTokenID MapRemoteDeviceTokenToLocal(const std::string& deviceID, AccessTokenID remoteID); 46 int GetDeviceAllRemoteTokenID(const std::string& deviceID, std::vector<AccessTokenID>& mapIDs); 47 AccessTokenID GetDeviceMappingTokenID(const std::string& deviceID, AccessTokenID remoteID); 48 int RemoveDeviceMappingTokenID(const std::string& deviceID, AccessTokenID remoteID); 49 50 private: 51 AccessTokenRemoteTokenManager(); 52 DISALLOW_COPY_AND_MOVE(AccessTokenRemoteTokenManager); 53 54 OHOS::Utils::RWLock remoteDeviceLock_; 55 std::map<std::string, AccessTokenRemoteDevice> remoteDeviceMap_; 56 }; 57 } // namespace AccessToken 58 } // namespace Security 59 } // namespace OHOS 60 #endif // ACCESSTOKEN_TOKEN_REMOTE_TOKEN_MANAGER_H 61 62