Comments (6)
You code is quite confusing.What are you trying to achieve?
Actually the following line does nothing, because you're not using the result of the build method:
new GroupBuilder(keePassFile.getRoot().getGroups().get(0)).addEntry(enrty).build();
Maybe it could help if you would take a look into the unit tests of the project to get familiar with the api.
from openkeepass.
I open an existing database file, and some update, want to write to a new file. Test code is already read.
Did you look at the results that were actually run the test code written by me?
new GroupBuilder(keePassFile.getRoot().getGroups().get(0)).addEntry(enrty).build();
In fact, the new entry is registered in the database file.
However, like the write method it has side effects, made to state the password is encoded in the entry of KeePassFile instance.
The correct update how I want you to explain in index.md.
from openkeepass.
Thanks, I've got your point. I agree that entries should not be modified during writing.
from openkeepass.
This fix does not pass my test code.
I will pull request.
from openkeepass.
@yososs I've implemented your test in method shouldEnsureThatEntriesAreNotModifiedDuringWriting()
. Can you tell me why this does method does not fulfill your requirement?
from openkeepass.
Because it does not pass the following line, which I wrote, it was investigated.
Assert.assertEquals("password", keePassFile.getRoot().getGroups().get(0).getEntries().get(0).getPassword());
Since this line is to pass and to comment out the write () method, it is obvious there are still side effects.
- Looking at the original correction code, but have created a clone, not a clone instance to the input of the toXML method.
return new KeePassDatabaseXmlParser().toXml(keePassFile).toByteArray();
private byte[] marshallXml(KeePassFile keePassFile, KeePassHeader header) {
KeePassFile clonedKeePassFile = new GroupZipper(keePassFile).cloneKeePassFile();
ProtectedStringCrypto protectedStringCrypto = Salsa20.createInstance(header.getProtectedStreamKey());
new ProtectedValueProcessor().processProtectedValues(new EncryptionStrategy(protectedStringCrypto), clonedKeePassFile);
return new KeePassDatabaseXmlParser().toXml(keePassFile).toByteArray();
}
Believes that there is a problem with the test, I was plus written to test code written by you.
@Test
public void shouldEnsureThatEntriesAreNotModifiedDuringWriting () {
// Open DB
. Final KeePassFile keePassFile = KeePassDatabase.getInstance ( "target / test-classes / testDatabase.kdbx") openDatabase ( "abcdefg");
Group generalGroup = keePassFile.getGroupByName ( "General");
// Add entry
... Entry entry = new EntryBuilder (UUID.randomUUID ()) title ( "title") password ( "password") build ();
new GroupBuilder (generalGroup) .addEntry (entry) .build ();
// Compare password in current DB
Assert.assertEquals (. Entry.getPassword (), generalGroup.getEntryByTitle ( "title") getPassword ());
// Get origin passwords
List <String> originPasswords = new ArrayList <String> ();
List <Entry> entries = keePassFile.getEntries ();
for (Entry e: entries) {
originPasswords.add (e.getPassword ());
}
// Write to new DB
KeePassDatabase.write (keePassFile, "abcdefg", "target / test-classes / testDatabase_new.kdbx");
// Get final passwords
List <String> finalPasswords = new ArrayList <String> ();
for (Entry e: entries) {
finalPasswords.add (e.getPassword ());
}
// Compare original passwords with final ones
assertThat (finalPasswords, is (originPasswords));
// Add by Yos ---------------------------------------------- -----------------------------
List <String> finalPasswords2 = new ArrayList <String> ();
List <Entry> entries2 = keePassFile.getEntries ();
for (Entry e: entries2) {
finalPasswords2.add (e.getPassword ());
}
assertThat (originPasswords, is (finalPasswords2));
}
from openkeepass.
Related Issues (20)
- Reading / Writing Entry attachments HOT 3
- Memory leak HOT 1
- Password is gibberish when opening file last saved by KeeWeb HOT 7
- java 9 warning HOT 9
- getUsername does not resolve referenced field's value HOT 2
- Some improvement ideas HOT 1
- The key has the wrong size. Have you installed Java Cryptography Extension (JCE)? Is the master key correct? HOT 2
- Could not deserialize object to XML HOT 7
- Can't read other app's files HOT 12
- Is it possible to create a new database with the API ? HOT 1
- Trouble with reading of created by this library file.kdbx HOT 1
- EntryBuilder.iconData() strange behavior for me HOT 6
- ChaCha20 encryption with Argon2 key derivation support HOT 1
- openkeepass in Oracle 12c JVM Wrong IV length: must be 16 bytes long HOT 2
- Write database with keyfile
- writing to custom properties doesnt seem possible
- Idea to replace simple-xml-2.7.1.jar with com.carrotsearch.thirdparty:simple-xml-safe:2.7.1 ?
- KDBX 4 Support
- Why does it use spongycastle instead of bouncycastle?
- NPE loading keepass archive created using KeepassXC 2.7.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openkeepass.