Fabcoin Core  0.16.2
P2P Digital Currency
SessionManager.cpp
Go to the documentation of this file.
1 #include <libdevcore/Base64.h>
2 #include "SessionManager.h"
3 
4 using namespace std;
5 using namespace dev;
6 using namespace dev::rpc;
7 
8 std::string SessionManager::newSession(SessionPermissions const& _p)
9 {
10  std::string s = toBase64(h64::random().ref());
11  m_sessions[s] = _p;
12  return s;
13 }
14 
15 void SessionManager::addSession(std::string const& _session, SessionPermissions const& _p)
16 {
17  m_sessions[_session] = _p;
18 }
19 
20 bool SessionManager::hasPrivilegeLevel(std::string const& _session, Privilege _l) const
21 {
22  auto it = m_sessions.find(_session);
23  return it != m_sessions.end() && it->second.privileges.count(_l);
24 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
vector_ref< _T const > ref(_T const &_t)
Definition: vector_ref.h:115
std::hash for asio::adress
Definition: Common.h:323
std::unordered_set< Privilege > privileges
std::string toBase64(bytesConstRef _in)
Definition: Base64.cpp:49