27 : id_type_(id_type), id_(id) {
36 isc_throw(isc::BadValue,
"UserId id string may not be blank");
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());
73const std::vector<uint8_t>&
85 std::stringstream tmp;
88 for (
auto const& it : id_) {
89 if (delim_char && delim) {
93 tmp << std::setw(2) << std::setfill(
'0')
94 <<
static_cast<unsigned int>(it);
103 return ((this->id_type_ == other.id_type_) && (this->id_ == other.id_));
108 return (!(*
this == other));
113 return ((this->id_type_ < other.id_type_) ||
114 ((this->id_type_ == other.id_type_) && (this->id_ < other.id_)));
119 const char* tmp = NULL;
132 return (std::string(tmp));
139 }
else if (type_str.compare(
DUID_STR) == 0) {
149 os << tmp <<
"=" << user_id.
toText();
159 : user_id_(id_type, id) {
163 : user_id_(id_type, id_str) {
171 return (properties_);
176 properties_ = properties;
185 properties_[name]=value;
190 PropertyMap::const_iterator it = properties_.find(name);
191 if (it != properties_.end()) {
192 return ((*it).second);
203 PropertyMap::iterator it = properties_.find(name);
204 if (it != properties_.end()) {
205 properties_.erase(it);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Holds DUID (DHCPv6 Unique Identifier)
Encapsulates a unique identifier for a DHCP client.
const std::vector< uint8_t > & getId() const
Returns a const reference to the actual id value.
bool operator!=(const UserId &other) const
Compares two UserIds for inequality.
UserId(UserIdType id_type, const std::vector< uint8_t > &id)
Constructor.
static UserIdType lookupType(const std::string &type_str)
Returns the id type for a given text label.
std::string toText(char delim_char=0x0) const
Returns textual representation of the id.
static const char * DUID_STR
Define the text label DUID id type.
static std::string lookupTypeStr(UserIdType type)
Returns the text label for a given id type.
bool operator==(const UserId &other) const
Compares two UserIds for equality.
UserIdType getType() const
Returns the user id type.
bool operator<(const UserId &other) const
Performs less than comparison of two UserIds.
static const char * HW_ADDRESS_STR
Defines the text label hardware address id type.
UserIdType
Defines the supported types of user ids.
@ HW_ADDRESS
Hardware addresses (MAC) are used for IPv4 clients.
@ DUID
DUIDs are used for IPv6 clients.
std::string getProperty(const std::string &name) const
Fetches the string value for a given property name.
User(const UserId &user_id)
Constructor.
void setProperties(const PropertyMap &properties)
Sets the user's properties from a given property map.
const UserId & getUserId() const
Returns the user's id.
void setProperty(const std::string &name, const std::string &value)
Sets a given property to the given value.
const PropertyMap & getProperties() const
Returns a reference to the map of properties.
void delProperty(const std::string &name)
Removes the given property from the property map.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
@ HTYPE_ETHER
Ethernet 10Mbps.
void decodeHex(const string &encoded_str, vector< uint8_t > &output)
Decode a base16 encoded string into binary data.
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.
std::ostream & operator<<(std::ostream &os, const UserId &user_id)
Outputs the UserId contents in a string to the given stream.
Hardware type that represents information from DHCPv4 packet.
This file defines classes: UserId and User.