public class KeePassDatabase
extends java.lang.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 an exception of type KeePassDatabaseUnreadable 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 | Method and Description |
---|---|
KeePassHeader |
getHeader()
Gets the KeePassDatabase header.
|
static KeePassDatabase |
getInstance(java.io.File keePassDatabaseFile)
Retrieves a KeePassDatabase instance.
|
static KeePassDatabase |
getInstance(java.io.InputStream keePassDatabaseStream)
Retrieves a KeePassDatabase instance.
|
static KeePassDatabase |
getInstance(java.lang.String keePassDatabaseFile)
Retrieves a KeePassDatabase instance.
|
KeePassFile |
openDatabase(java.io.File keyFile)
Opens a KeePass database with the given keyfile and returns the
KeePassFile for further processing.
|
KeePassFile |
openDatabase(java.io.InputStream keyFileStream)
Opens a KeePass database with the given keyfile stream and returns the
KeePassFile for further processing.
|
KeePassFile |
openDatabase(java.lang.String password)
Opens a KeePass database with the given password and returns the
KeePassFile for further processing.
|
KeePassFile |
openDatabase(java.lang.String password,
java.io.File keyFile)
Opens a KeePass database with the given password and keyfile and returns
the KeePassFile for further processing.
|
KeePassFile |
openDatabase(java.lang.String password,
java.io.InputStream keyFileStream)
Opens a KeePass database with the given password and keyfile stream and
returns the KeePassFile for further processing.
|
static void |
write(KeePassFile keePassFile,
java.lang.String password,
java.io.OutputStream stream)
Encrypts a
KeePassFile with the given password and writes it to
the given stream. |
static void |
write(KeePassFile keePassFile,
java.lang.String password,
java.lang.String keePassDatabaseFile)
Encrypts a
KeePassFile with the given password and writes it to
the given file location. |
public static KeePassDatabase getInstance(java.lang.String keePassDatabaseFile)
keePassDatabaseFile
- a KeePass database filename, must not be NULLpublic static KeePassDatabase getInstance(java.io.File keePassDatabaseFile)
keePassDatabaseFile
- a KeePass database file, must not be NULLpublic static KeePassDatabase getInstance(java.io.InputStream keePassDatabaseStream)
keePassDatabaseStream
- an input stream of a KeePass database, must not be NULLpublic KeePassFile openDatabase(java.lang.String password)
If the database cannot be decrypted with the provided password an exception will be thrown.
password
- the password to open the databaseKeePassFile
public KeePassFile openDatabase(java.lang.String password, java.io.File keyFile)
If the database cannot be decrypted with the provided password and keyfile an exception will be thrown.
password
- the password to open the databasekeyFile
- the password to open the databaseKeePassFile
public KeePassFile openDatabase(java.lang.String password, java.io.InputStream keyFileStream)
If the database cannot be decrypted with the provided password and keyfile stream an exception will be thrown.
password
- the password to open the databasekeyFileStream
- the keyfile to open the database as streamKeePassFile
public KeePassFile openDatabase(java.io.File keyFile)
If the database cannot be decrypted with the provided password an exception will be thrown.
keyFile
- the password to open the databaseKeePassFile
public KeePassFile openDatabase(java.io.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 streamKeePassFile
public KeePassHeader getHeader()
public static void write(KeePassFile keePassFile, java.lang.String password, java.lang.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 writtenKeePassFile
public static void write(KeePassFile keePassFile, java.lang.String password, java.io.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 writtenKeePassFile