aboutsummaryrefslogtreecommitdiff
path: root/include/User.hpp
blob: fb37876c85f94f70fd282bd6f3bfbd72f1dd4303 (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
#pragma once

#include "Signature.hpp"
#include <string>
#include <stdexcept>
#include <vector>

namespace odhtdb
{
    class Group;
    
    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
    {
    public:
        virtual ~User(){}
        
        void addToGroup(Group *group);
        
        const std::string& getName() const { return name; }
        const std::vector<Group*>& getGroups() const { return groups; }
        virtual const Signature::PublicKey& getPublicKey() const = 0;
    protected:
        User(const std::string &name, Group *group);
    private:
        std::string name;
        std::vector<Group*> groups;
    };
}