Fabcoin Core  0.16.2
P2P Digital Currency
SessionManager.h
Go to the documentation of this file.
1 #pragma once
2 #include <unordered_set>
3 #include <unordered_map>
4 
5 #define RPC_ADMIN if (!m_sm.hasPrivilegeLevel(_session, Privilege::Admin)) throw jsonrpc::JsonRpcException("Invalid privileges");
6 
7 namespace dev
8 {
9 namespace rpc
10 {
11 
12 enum class Privilege
13 {
14  Admin
15 };
16 
17 }
18 }
19 
20 namespace std
21 {
22  template<> struct hash<dev::rpc::Privilege>
23  {
24  size_t operator()(dev::rpc::Privilege _value) const { return (size_t)_value; }
25  };
26 }
27 
28 namespace dev
29 {
30 namespace rpc
31 {
32 
34 {
35  std::unordered_set<Privilege> privileges;
36 };
37 
39 {
40 public:
41  std::string newSession(SessionPermissions const& _p);
42  void addSession(std::string const& _session, SessionPermissions const& _p);
43  bool hasPrivilegeLevel(std::string const& _session, Privilege _l) const;
44 
45 private:
46  std::unordered_map<std::string, SessionPermissions> m_sessions;
47 };
48 
49 }
50 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
std::hash for asio::adress
Definition: Common.h:323
std::unordered_map< std::string, SessionPermissions > m_sessions
std::unordered_set< Privilege > privileges
size_t operator()(dev::rpc::Privilege _value) const