65 std::shared_ptr<Binary> binary_;
69 const std::string&
name()
const {
return name_; }
72 void set_name(
const std::string& name) { name_ = name; }
75 std::shared_ptr<Binary>
binary()
const {
return binary_; }
78 void set_binary(std::shared_ptr<Binary> binary) { binary_ = std::move(binary); }
85 std::string
ToJson(
bool include_data =
false)
const;
89 return name_ == other.name_ &&
indirect_equal(binary_, other.binary_);
107 std::string sequence_;
112 : window_(std::move(window)), sequence_(std::move(sequence)) {}
115 const std::string&
window()
const {
return window_; }
118 const std::string&
sequence()
const {
return sequence_; }
122 return window_ == other.window_ && sequence_ == other.sequence_;
130 bool enabled_ =
false;
131 uint32_t obfuscation_ = 0;
132 std::string sequence_;
133 std::vector<Association> associations_;
149 const std::string&
sequence()
const {
return sequence_; }
152 void set_sequence(
const std::string& sequence) { sequence_ = sequence; }
155 const std::vector<Association>&
associations()
const {
return associations_; }
159 associations_.emplace_back(window, sequence);
164 return enabled_ == other.enabled_ && obfuscation_ == other.obfuscation_ &&
165 sequence_ == other.sequence_ && associations_ == other.associations_;
183 : key_(std::move(key)), value_(std::move(value)) {}
188 value_ = other.value_;
193 key_ = std::move(other.key_);
194 value_ = std::move(other.value_);
198 const std::string&
key()
const {
return key_; }
208 key_ = std::move(other.key_);
209 value_ = std::move(other.value_);
215 return key_ == other.key_ && value_ == other.value_;
223 std::array<uint8_t, 16> uuid_;
225 std::weak_ptr<Icon> custom_icon_;
226 std::weak_ptr<Group> parent_;
229 std::string override_url_;
234 bool quality_check_ =
true;
235 std::optional<std::array<uint8_t, 16>> previous_parent_group_;
236 std::time_t creation_time_ = 0;
237 std::time_t modification_time_ = 0;
238 std::time_t access_time_ = 0;
239 std::time_t expiry_time_ = 0;
240 std::time_t move_time_ = 0;
241 bool expires_ =
false;
242 uint32_t usage_count_ = 0;
243 std::string bg_color_;
244 std::string fg_color_;
246 std::vector<std::shared_ptr<Attachment>> attachments_;
247 std::vector<std::shared_ptr<Entry>> history_;
248 std::vector<Field> custom_fields_;
255 const std::array<uint8_t, 16>&
uuid()
const {
return uuid_; }
258 void set_uuid(
const std::array<uint8_t, 16>& uuid) { uuid_ = uuid; }
261 uint32_t
icon()
const {
return icon_; }
264 void set_icon(
const uint32_t& icon) { icon_ = icon; }
309 const std::string&
tags()
const {
return tags_; }
312 void set_tags(
const std::string& tags) { tags_ = tags; }
322 return previous_parent_group_;
328 previous_parent_group_ = uuid;
374 const std::string&
bg_color()
const {
return bg_color_; }
377 void set_bg_color(
const std::string& bg_color) { bg_color_ = bg_color; }
380 const std::string&
fg_color()
const {
return fg_color_; }
383 void set_fg_color(
const std::string& fg_color) { fg_color_ = fg_color; }
389 const std::vector<std::shared_ptr<Attachment>>&
attachments()
const {
return attachments_; }
399 const std::vector<std::shared_ptr<Entry>>&
history()
const {
return history_; }
405 std::weak_ptr<Group>
parent()
const {
return parent_; }
408 void set_parent(std::weak_ptr<Group> parent) { parent_ = std::move(parent); }
457 std::optional<TotpConfig>
totp()
const;
518 std::string
ToJson(
bool include_attachments =
false)
const;
Type representing a binary blob stored in a database.
A file attachment of an entry.
Definition entry.hh:62
std::string ToJson(bool include_data=false) const
Serializes the attachment to a JSON fragment.
void set_binary(std::shared_ptr< Binary > binary)
Sets the attachment binary payload.
Definition entry.hh:78
std::shared_ptr< Binary > binary() const
Returns the attachment binary payload.
Definition entry.hh:75
bool operator!=(const Attachment &other) const
Inequality comparison.
Definition entry.hh:93
void set_name(const std::string &name)
Sets the attachment name.
Definition entry.hh:72
bool operator==(const Attachment &other) const
Equality comparison.
Definition entry.hh:88
const std::string & name() const
Returns the attachment name.
Definition entry.hh:69
Association between a target window and a keystroke sequence.
Definition entry.hh:104
const std::string & sequence() const
Returns the keystroke sequence sent to the window.
Definition entry.hh:118
bool operator==(const Association &other) const
Equality comparison.
Definition entry.hh:121
Association(std::string window, std::string sequence)
Creates an association for the given window and sequence.
Definition entry.hh:111
bool operator!=(const Association &other) const
Inequality comparison.
Definition entry.hh:126
const std::string & window() const
Returns the target window title.
Definition entry.hh:115
Keystroke-sending (auto-type) configuration for an entry.
Definition entry.hh:99
void set_obfuscation(bool obfuscation)
Sets the obfuscation level.
Definition entry.hh:146
bool operator==(const AutoType &other) const
Equality comparison.
Definition entry.hh:163
uint32_t obfuscation() const
Returns the obfuscation level.
Definition entry.hh:143
const std::string & sequence() const
Returns the default keystroke sequence.
Definition entry.hh:149
bool operator!=(const AutoType &other) const
Inequality comparison.
Definition entry.hh:169
void set_sequence(const std::string &sequence)
Sets the default keystroke sequence.
Definition entry.hh:152
void set_enabled(bool enabled)
Sets whether auto-type is enabled.
Definition entry.hh:140
const std::vector< Association > & associations() const
Returns the window/sequence associations.
Definition entry.hh:155
void AddAssociation(const std::string &window, const std::string &sequence)
Adds an association between a window and a keystroke sequence.
Definition entry.hh:158
bool enabled() const
Returns whether auto-type is enabled.
Definition entry.hh:137
An arbitrary custom string (key/value) field.
Definition entry.hh:175
Field(Field &&other) noexcept
Move constructor.
Definition entry.hh:192
Field(std::string key, protect< secure_string > value)
Creates a field with the given key and protected value.
Definition entry.hh:182
Field & operator=(Field &&other) noexcept
Move assignment.
Definition entry.hh:207
bool operator!=(const Field &other) const
Inequality comparison.
Definition entry.hh:219
Field & operator=(const Field &other)=default
Copy assignment.
const protect< secure_string > & value() const
Returns the field value.
Definition entry.hh:201
const std::string & key() const
Returns the field key.
Definition entry.hh:198
bool operator==(const Field &other) const
Equality comparison.
Definition entry.hh:214
Field(const Field &other)
Copy constructor.
Definition entry.hh:186
A single KeePass entry (a username/password record).
Definition entry.hh:55
std::weak_ptr< Group > parent() const
Returns the parent group (empty if this entry is not attached).
Definition entry.hh:405
void set_icon(const uint32_t &icon)
Sets the index of the stock icon.
Definition entry.hh:264
const std::vector< std::shared_ptr< Attachment > > & attachments() const
Returns the list of attachments.
Definition entry.hh:389
void DeleteOldHistory(std::size_t max_items)
Alias for delete_old_history(std::size_t) matching the KeePass API.
Definition entry.hh:490
const std::vector< Field > & custom_fields() const
Returns the list of custom fields.
Definition entry.hh:402
const std::vector< std::shared_ptr< Entry > > & history() const
Definition entry.hh:399
void save_history()
Saves a copy of the current state into the entry history.
std::weak_ptr< Icon > custom_icon() const
Returns a weak reference to the custom icon (if any).
Definition entry.hh:267
Entry()
Creates an empty entry.
void set_uuid(const std::array< uint8_t, 16 > &uuid)
Sets the entry's unique identifier (UUID).
Definition entry.hh:258
void set_move_time(const std::time_t &time)
Sets the last move time.
Definition entry.hh:359
void set_username(const protect< secure_string > &username)
Sets the username.
Definition entry.hh:294
const protect< secure_string > & url() const
Returns the URL.
Definition entry.hh:279
void set_expires(bool expires)
Sets whether the entry expires.
Definition entry.hh:365
std::optional< TotpConfig > totp() const
uint32_t icon() const
Returns the index of the stock icon.
Definition entry.hh:261
bool HasAttachment() const
Returns whether the entry has at least one attachment.
const protect< secure_string > & title() const
Returns the entry title.
Definition entry.hh:273
bool operator!=(const Entry &other) const
Inequality comparison.
const protect< secure_string > & password() const
Returns the password.
Definition entry.hh:297
const std::string & override_url() const
Returns the override URL.
Definition entry.hh:285
std::map< std::string, std::string > custom_properties() const
Returns the custom fields as a key/value map.
const protect< secure_string > & username() const
Returns the username.
Definition entry.hh:291
void touch(bool modify=false)
Updates the last access time (and optionally the modification time).
void AddHistoryEntry(const std::shared_ptr< Entry > &entry)
Adds a previous version of this entry to its history.
const protect< secure_string > & notes() const
Returns the notes.
Definition entry.hh:303
bool operator==(const Entry &other) const
Equality comparison.
std::time_t creation_time() const
Returns the creation time.
Definition entry.hh:332
std::vector< uint8_t > get_binary_property(const std::string &name) const
Returns the data of the binary property with the given name.
bool HasAttachment(const std::string &name) const
Returns whether an attachment with the given name exists.
bool HasString(const std::string &key) const
Returns whether the given string field exists.
void set_url(const protect< secure_string > &url)
Sets the URL.
Definition entry.hh:282
void set_title(const protect< secure_string > &title)
Sets the entry title.
Definition entry.hh:276
uint32_t usage_count() const
Returns the usage count.
Definition entry.hh:368
std::string GetString(const std::string &key) const
Returns the value of the given string field.
std::time_t expiry_time() const
Returns the expiry time.
Definition entry.hh:350
void set_fg_color(const std::string &fg_color)
Sets the foreground color.
Definition entry.hh:383
void set_override_url(const std::string &url)
Sets the override URL.
Definition entry.hh:288
void set_usage_count(uint32_t usage_count)
Sets the usage count.
Definition entry.hh:371
void set_parent(std::weak_ptr< Group > parent)
Sets the parent group.
Definition entry.hh:408
void set_access_time(const std::time_t &time)
Sets the last access time.
Definition entry.hh:347
void set_creation_time(const std::time_t &time)
Sets the creation time.
Definition entry.hh:335
std::time_t access_time() const
Returns the last access time.
Definition entry.hh:344
const std::string & fg_color() const
Returns the foreground color.
Definition entry.hh:380
bool HasNonDefaultAutoTypeSettings() const
Returns whether the auto-type settings differ from the defaults.
std::time_t move_time() const
Returns the last move time.
Definition entry.hh:356
void delete_old_history(std::size_t max_items, std::size_t max_bytes)
void set_custom_property(const std::string &key, const std::string &value)
Sets a custom field, creating it if it does not exist.
bool expires() const
Returns whether the entry expires.
Definition entry.hh:362
std::vector< std::string > attachment_names() const
Returns the names of all attachments in attachment order.
void delete_binary_property(const std::string &name)
Removes the binary property with the given name.
void set_custom_icon(std::weak_ptr< Icon > icon)
Sets the custom icon.
Definition entry.hh:270
const std::optional< std::array< uint8_t, 16 > > & previous_parent_group() const
Returns the UUID of the previous parent group (KDBX 4.1); empty if unset.
Definition entry.hh:321
bool IsMetaEntry() const
Returns whether the entry is a KeePassX metadata entry.
std::string path() const
Returns the full path of this entry including its title.
std::time_t modification_time() const
Returns the last modification time.
Definition entry.hh:338
void set_binary_property(const std::string &name, const std::vector< uint8_t > &data)
Sets (or replaces) a binary property (attachment) of this entry.
void set_quality_check(bool quality_check)
Sets whether the password quality warning is enabled for this entry.
Definition entry.hh:318
void set_previous_parent_group(const std::optional< std::array< uint8_t, 16 > > &uuid)
Definition entry.hh:327
void AddCustomField(std::string &key, const protect< secure_string > &value)
Adds a custom field with the given key and value.
bool quality_check() const
Returns whether the password quality warning is enabled for this entry.
Definition entry.hh:315
void set_password(const protect< secure_string > &password)
Sets the password.
Definition entry.hh:300
void set_tags(const std::string &tags)
Sets the tags (space-separated).
Definition entry.hh:312
std::string totp_code(std::time_t time=0) const
Generates the current TOTP code from the entry's custom fields.
void delete_history()
Clears the entry history.
void set_modification_time(const std::time_t &time)
Sets the last modification time.
Definition entry.hh:341
std::string ToJson(bool include_attachments=false) const
Serializes the entry to a JSON object.
void set_expiry_time(const std::time_t &time)
Sets the expiry time.
Definition entry.hh:353
void set_notes(const protect< secure_string > ¬es)
Sets the notes.
Definition entry.hh:306
AutoType & auto_type()
Returns the auto-type configuration.
Definition entry.hh:386
void AddAttachment(const std::shared_ptr< Attachment > &attachment)
Adds an attachment to the entry.
std::shared_ptr< Binary > FindAttachment(const std::string &name) const
Returns the attachment object with the given name, or null if absent.
const std::string & bg_color() const
Returns the background color.
Definition entry.hh:374
void delete_old_history(std::size_t max_items)
Removes the oldest history items, keeping at most max_items.
void delete_custom_property(const std::string &key)
Removes a custom field.
const std::array< uint8_t, 16 > & uuid() const
Returns the entry's unique identifier (UUID).
Definition entry.hh:255
void set_bg_color(const std::string &bg_color)
Sets the background color.
Definition entry.hh:377
const std::string & tags() const
Returns the tags (space-separated).
Definition entry.hh:309
Wrapper that marks a value as sensitive and tracks the protection flag of a KeePass field.
Definition security.hh:41
Visibility/export macro for the shared library.
#define LIBKEEPASS_API
Marks a class, function or variable as part of the public ABI.
Definition export.hh:43
Secure memory handling: zeroization, locked allocations and sensitive value containers.
Wrapper type for protecting sensitive KeePass field values.
Helpers for the KeePass TOTP custom fields and time-based one-time password generation.
Utility functions for clamp, comparison, traversal, and time formatting.
bool indirect_equal(const std::vector< T > &v0, const std::vector< T > &v1)
Definition util.hh:59