public class KeePassDatabase extends Object
Currently the following KeePass files are supported:
// open database
KeePassFile database = KeePassDatabase.getInstance("keePassDatabasePath").openDatabase("secret");
// get password entries
List<Entry> entries = database.getEntries();
...
If the database could not be opened a RuntimeException will be thrown.
A typical write use-case should use the following idiom:
// build an entry
Entry entryOne = new EntryBuilder("First entry").username("Carl").password("secret").build();
// build more entries or groups as you like
...
// build KeePass model
KeePassFile keePassFile = new KeePassFileBuilder("testDB").addTopEntries(entryOne).build();
// write KeePass database file
KeePassDatabase.write(keePassFile, "secret", new FileOutputStream("keePassDatabasePath"));
KeePassFile| Modifier and Type | Field and Description |
|---|---|
protected Decrypter |
decrypter |
protected KeePassDatabaseXmlParser |
keePassDatabaseXmlParser |
protected KeyFileXmlParser |
keyFileXmlParser |
| Modifier and Type | Method and Description |
|---|---|
KeePassHeader |
getHeader()
Gets the KeePassDatabase header.
|
static KeePassDatabase |
getInstance(File keePassDatabaseFile)
Retrieves a KeePassDatabase instance.
|
static KeePassDatabase |
getInstance(InputStream keePassDatabaseStream)
Retrieves a KeePassDatabase instance.
|
static KeePassDatabase |
getInstance(String keePassDatabaseFile)
Retrieves a KeePassDatabase instance.
|
KeePassFile |
openDatabase(File keyFile)
Opens a KeePass database with the given password and returns the KeePassFile for further processing.
|
KeePassFile |
openDatabase(InputStream keyFileStream)
Opens a KeePass database with the given keyfile stream and returns the KeePassFile for further processing.
|
KeePassFile |
openDatabase(String password)
Opens a KeePass database with the given password and returns the KeePassFile for further processing.
|
static void |
write(KeePassFile keePassFile,
String password,
OutputStream stream)
Encrypts a
KeePassFile with the given password and writes it to the given stream. |
static void |
write(KeePassFile keePassFile,
String password,
String keePassDatabaseFile)
Encrypts a
KeePassFile with the given password and writes it to the given file location. |
protected Decrypter decrypter
protected KeePassDatabaseXmlParser keePassDatabaseXmlParser
protected KeyFileXmlParser keyFileXmlParser
public static KeePassDatabase getInstance(String keePassDatabaseFile)
keePassDatabaseFile - a KeePass database filename, must not be NULLpublic static KeePassDatabase getInstance(File keePassDatabaseFile)
keePassDatabaseFile - a KeePass database file, must not be NULLpublic static KeePassDatabase getInstance(InputStream keePassDatabaseStream)
keePassDatabaseStream - an input stream of a KeePass database, must not be NULLpublic KeePassFile openDatabase(String password)
If the database cannot be decrypted with the provided password an exception will be thrown.
password - the password to open the databaseKeePassFilepublic KeePassFile openDatabase(File keyFile)
If the database cannot be decrypted with the provided password an exception will be thrown.
keyFile - the password to open the databaseKeePassFilepublic KeePassFile openDatabase(InputStream keyFileStream)
If the database cannot be decrypted with the provided keyfile an exception will be thrown.
keyFileStream - the keyfile to open the database as streamKeePassFilepublic KeePassHeader getHeader()
public static void write(KeePassFile keePassFile, String password, String keePassDatabaseFile)
KeePassFile with the given password and writes it to the given file location.
If the KeePassFile cannot be encrypted an exception will be thrown.
keePassFile - the keePass model which should be writtenpassword - the password to encrypt the databasekeePassDatabaseFile - the target location where the database file will be writtenKeePassFilepublic static void write(KeePassFile keePassFile, String password, OutputStream stream)
KeePassFile with the given password and writes it to the given stream.
If the KeePassFile cannot be encrypted an exception will be thrown.
keePassFile - the keePass model which should be writtenpassword - the password to encrypt the databasestream - the target stream where the output will be writtenKeePassFileCopyright © 2016. All rights reserved.