blob: 4d6d9b3ac8f2aea16f0f39d08e5f6c4fbb21fdf5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#pragma once
#include "Signature.hpp"
#include "types.hpp"
#include "Permission.hpp"
#include <string>
#include <stdexcept>
#include <vector>
namespace odhtdb
{
class Group;
class DatabaseStorage;
class UserNameTooLongException : public std::runtime_error
{
public:
UserNameTooLongException(const std::string &userName) :
std::runtime_error(std::string("The username ") + userName + " is longer than 255 bytes")
{
}
};
class User
{
friend class DatabaseStorage;
public:
enum class Type : u8
{
LOCAL,
REMOTE
};
virtual ~User();
virtual void addToGroup(Group *group);
Type getType() const { return type; }
const std::string& getName() const { return name; }
virtual const std::vector<Group*>& getGroups() const { return groups; }
virtual const Signature::PublicKey& getPublicKey() const = 0;
virtual bool isAllowedToPerformAction(PermissionType action) const;
protected:
User(Type type, const std::string &name, Group *group);
protected:
Type type;
std::string name;
std::vector<Group*> groups;
};
}
|