Loading...
Searching...
No Matches
sessions_manager.h
1/*
2 * <one line to give the program's name and a brief idea of what it does.>
3 * Copyright (C) 2023 Jose F Rivas C <email>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef NAF_TOOLS_SESSIONSMANAGER
20#define NAF_TOOLS_SESSIONSMANAGER
21
22
23#include <string>
24#include <map>
25#include <mutex>
26#include <exception>
27
28#include "Poco/Exception.h"
29
30#include "query/database_manager.h"
31#include "extras/session.h"
32#include "functions/action.h"
33#include "tools/output_logger.h"
34#include "query/parameter.h"
35#include "tools/dvalue.h"
36#include "tools/settings_manager.h"
37
38namespace NAF
39{
40 namespace Tools
41 {
42 class SessionsManager;
43 }
44}
45
46
48{
49 public:
52
53 static std::map<std::string, NAF::Extras::Session>& get_sessions()
54 {
55 auto& var = sessions_;
56 return var;
57 }
58 static Query::DatabaseManager::Credentials& get_credentials()
59 {
60 auto& var = credentials_;
61 return var;
62 }
63
64 static void ReadSessions_();
65 static NAF::Extras::Session& CreateSession_(int id_user, std::string path, int max_age);
66 static void DeleteSession_(std::string id);
67
68 protected:
69 static bool SessionExists_(std::string id);
70
71 private:
72 static std::mutex mutex_;
73 static std::map<std::string, NAF::Extras::Session> sessions_;
74 static Query::DatabaseManager::Credentials credentials_;
75};
76
77#endif // NAF_TOOLS_SESSIONSMANAGER
Definition session.h:45
Definition sessions_manager.h:48
Definition database_manager.h:51