#pragma once #include "Signature.hpp" #include "types.hpp" #include "Permission.hpp" #include #include #include 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& 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 groups; }; }