mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-06 00:32:32 -08:00
UI and backend refactoring to support both database versions.
This commit is contained in:
1 parent
a363dd677b
commit
d78f900fcd
52 files changed
+1382
-339
No files matched your search
@@ -23,7 +23,13 @@ import java.io.IOException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.UUID;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.keepassdroid.database.exception.InconsistentDBException;
|
||||
import com.keepassdroid.database.exception.InvalidKeyFileException;
|
||||
|
||||
|
||||
@@ -32,7 +38,11 @@ public class PwDatabaseV4 extends PwDatabase {
|
||||
public UUID dataCipher;
|
||||
public PwCompressionAlgorithm compressionAlgorithm;
|
||||
public long numKeyEncRounds;
|
||||
|
||||
private Document doc;
|
||||
|
||||
//private Vector<PwGroupV4> groups = new Vector<PwGroupV4>();
|
||||
private PwGroupV4 rootGroup;
|
||||
|
||||
@Override
|
||||
public byte[] getMasterKey(String key, String keyFileName)
|
||||
throws InvalidKeyFileException, IOException {
|
||||
@@ -65,4 +75,51 @@ public class PwDatabaseV4 extends PwDatabase {
|
||||
return getPasswordKey(key, "UTF-8");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<PwGroup> getGroups() {
|
||||
Vector<PwGroup> list = new Vector<PwGroup>();
|
||||
rootGroup.buildChildGroupsRecursive(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void parseDB(Document d) throws InconsistentDBException {
|
||||
doc = d;
|
||||
|
||||
NodeList list = doc.getElementsByTagName("Root");
|
||||
|
||||
int len = list.getLength();
|
||||
if ( len < 0 || len > 1 ) {
|
||||
throw new InconsistentDBException("Missing root node");
|
||||
}
|
||||
|
||||
Node root = list.item(1);
|
||||
|
||||
rootGroup = new PwGroupV4(root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<PwGroup> getGrpRoots() {
|
||||
return rootGroup.childGroups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<PwEntry> getEntries() {
|
||||
Vector<PwEntry> list = new Vector<PwEntry>();
|
||||
rootGroup.buildChildEntriesRecursive(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNumRounds() {
|
||||
return numKeyEncRounds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNumRonuds(long rounds) throws NumberFormatException {
|
||||
numKeyEncRounds = rounds;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user