Version 2.2.4, KeePassJava2-jackson (the same holds for KeePassJava2-simple).
An application that keeps KeePass data in its own model and writes it back out cannot write back what it read: the entry's and group's UUID, the entry's four timestamps with the expiry flag, and the entry's history.
JacksonEntry declares protected UUID uuid, protected Times times, protected JacksonHistory history; JacksonGroup declares protected UUID uuid, protected Times times. There is no setter for any of them, and setExpiryTime/setExpires are the only time-related setters.
- No factory takes them:
JacksonDatabase.newEntry() and newGroup() are parameterless and assign a random UUID and the current time.
AbstractDatabase.newEntry(Entry) copies properties, binaries and icon, not UUID or times.
- Subclassing does not help:
JacksonEntry.database is package-private, so an entry built by a subclass has no database, and setProperty on it fails.
- Every property or binary setter calls
touch(), which stamps the modification time, so even with access to times it has to be written last.
The effect, measured with a database written by KeePassXC 2.7.10 and read back with keepassxc-cli export -f xml: after reading it and writing it again through newEntry/newGroup of the Simple model, every entry and group had a new UUID, all timestamps were the moment of the write, and the history was empty. The Jackson model offers the same API shape for these fields.
Would you accept setters (or a factory method taking these values) for UUID and Times on entries and groups, and for the history on entries? We reach the fields by reflection until then, in one class, and would switch to the API.
Context: mystic-crypt-ui, astrapi69/mystic-crypt-ui#382 and #384.
Version 2.2.4,
KeePassJava2-jackson(the same holds forKeePassJava2-simple).An application that keeps KeePass data in its own model and writes it back out cannot write back what it read: the entry's and group's UUID, the entry's four timestamps with the expiry flag, and the entry's history.
JacksonEntrydeclaresprotected UUID uuid,protected Times times,protected JacksonHistory history;JacksonGroupdeclaresprotected UUID uuid,protected Times times. There is no setter for any of them, andsetExpiryTime/setExpiresare the only time-related setters.JacksonDatabase.newEntry()andnewGroup()are parameterless and assign a random UUID and the current time.AbstractDatabase.newEntry(Entry)copies properties, binaries and icon, not UUID or times.JacksonEntry.databaseis package-private, so an entry built by a subclass has no database, andsetPropertyon it fails.touch(), which stamps the modification time, so even with access totimesit has to be written last.The effect, measured with a database written by KeePassXC 2.7.10 and read back with
keepassxc-cli export -f xml: after reading it and writing it again throughnewEntry/newGroupof the Simple model, every entry and group had a new UUID, all timestamps were the moment of the write, and the history was empty. The Jackson model offers the same API shape for these fields.Would you accept setters (or a factory method taking these values) for UUID and
Timeson entries and groups, and for the history on entries? We reach the fields by reflection until then, in one class, and would switch to the API.Context: mystic-crypt-ui, astrapi69/mystic-crypt-ui#382 and #384.