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 USERAUTH_DATAMGR_H 17 #define USERAUTH_DATAMGR_H 18 19 #include <mutex> 20 #include <set> 21 #include "nocopyable.h" 22 #include "iuserauth_callback.h" 23 #include "userauth_adapter.h" 24 25 namespace OHOS { 26 namespace UserIAM { 27 namespace UserAuth { 28 constexpr int32_t OPENSSLSUCCESS = 1; 29 class UserAuthDataMgr { 30 public: 31 DISALLOW_COPY_AND_MOVE(UserAuthDataMgr); 32 static UserAuthDataMgr &GetInstance(); 33 int32_t AddContextId(uint64_t contextId); 34 int32_t IsContextIdExist(uint64_t contextId); 35 int32_t GenerateContextId(uint64_t &contextId); 36 int32_t DeleteContextId(uint64_t contextId); 37 38 private: 39 UserAuthDataMgr() = default; 40 ~UserAuthDataMgr() = default; 41 std::mutex mutex_; 42 std::set<uint64_t> contextIds_; 43 }; 44 } // namespace UserAuth 45 } // namespace UserIAM 46 } // namespace OHOS 47 #endif // USERAUTH_DATAMGR_H 48