27 : id_type_(id_type), id_(id) {
41 std::vector<uint8_t> addr_bytes;
44 std::string clean_id_str = id_str;
45 std::string::iterator end_pos = std::remove(clean_id_str.begin(),
46 clean_id_str.end(),
':');
47 clean_id_str.erase(end_pos, clean_id_str.end());
73 const std::vector<uint8_t>&
85 std::stringstream tmp;
88 for (std::vector<uint8_t>::const_iterator it = id_.begin();
89 it != id_.end(); ++it) {
90 if (delim_char && delim) {
94 tmp << std::setw(2) << std::setfill(
'0')
95 <<
static_cast<unsigned int>(*it);
104 return ((this->id_type_ == other.id_type_) && (this->id_ == other.id_));
109 return (!(*
this == other));
114 return ((this->id_type_ < other.id_type_) ||
115 ((this->id_type_ == other.id_type_) && (this->id_ < other.id_)));
120 const char* tmp = NULL;
133 return (std::string(tmp));
140 }
else if (type_str.compare(
DUID_STR) == 0) {
150 os << tmp <<
"=" << user_id.
toText();
160 : user_id_(id_type, id) {
164 : user_id_(id_type, id_str) {
172 return (properties_);
177 properties_ = properties;
186 properties_[name]=value;
191 PropertyMap::const_iterator it = properties_.find(name);
192 if (it != properties_.end()) {
193 return ((*it).second);
204 PropertyMap::iterator it = properties_.find(name);
205 if (it != properties_.end()) {
206 properties_.erase(it);
UserIdType
Defines the supported types of user ids.
static std::string lookupTypeStr(UserIdType type)
Returns the text label for a given id type.
void setProperties(const PropertyMap &properties)
Sets the user's properties from a given property map.
static const char * DUID_STR
Define the text label DUID id type.
std::string getProperty(const std::string &name) const
Fetches the string value for a given property name.
UserIdType getType() const
Returns the user id type.
Encapsulates a unique identifier for a DHCP client.
User(const UserId &user_id)
Constructor.
Holds DUID (DHCPv6 Unique Identifier)
void setProperty(const std::string &name, const std::string &value)
Sets a given property to the given value.
Defines the logger used by the user check hooks library.
std::map< std::string, std::string > PropertyMap
Defines a map of string values keyed by string labels.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
This file defines classes: UserId and User.
bool operator<(const UserId &other) const
Performs less than comparison of two UserIds.
const PropertyMap & getProperties() const
Returns a reference to the map of properties.
void decodeHex(const string &input, vector< uint8_t > &result)
Decode a text encoded in the base16 ('hex') format into the original data.
std::string toText(char delim_char=0x0) const
Returns textual representation of the id.
void delProperty(const std::string &name)
Removes the given property from the property map.
bool operator==(const UserId &other) const
Compares two UserIds for equality.
static UserIdType lookupType(const std::string &type_str)
Returns the id type for a given text label.
const UserId & getUserId() const
Returns the user's id.
UserId(UserIdType id_type, const std::vector< uint8_t > &id)
Constructor.
Hardware addresses (MAC) are used for IPv4 clients.
Hardware type that represents information from DHCPv4 packet.
std::ostream & operator<<(std::ostream &os, const UserId &user_id)
Outputs the UserId contents in a string to the given stream.
bool operator!=(const UserId &other) const
Compares two UserIds for inequality.
static const char * HW_ADDRESS_STR
Defines the text label hardware address id type.
const std::vector< uint8_t > & getId() const
Returns a const reference to the actual id value.
DUIDs are used for IPv6 clients.