/** * Load KDB and save as KDBX */ public void loadKdb() throws IOException { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("test123.kdb"); // password credentials Credentials credentials = new KdbCredentials.Password("123".getBytes()); // load KdbDatabase KdbDatabase database = KdbDatabase.load(credentials, inputStream); // visit all groups and entries and list them to console database.visit(new Visitor.Print()); // create a KDBX (database D kdbxDatabse = getDatabase(); kdbxDatabse.setName("New Database"); kdbxDatabse.setDescription("Migration of KDB Database to KDBX Database"); // deep copy from group (not including source group, KDB database has simulated root) kdbxDatabse.getRootGroup().copy(database.getRootGroup()); // save it try (FileOutputStream f = new FileOutputStream("testOutput/migration.kdbx")) { kdbxDatabse.save(new KdbxCreds("123".getBytes()), f); } } }
database.visit(new Visitor.Print());
/** * Load KDBX */ public void loadKdbx() throws IOException { // get an input stream try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("test123.kdbx")) { // password credentials Credentials credentials = new KdbxCreds("123".getBytes()); // Jaxb implementation seems a lot faster than the DOM implementation D database = loadDatabase(credentials, inputStream); // visit all groups and entries and list them to console database.visit(new Visitor.Print()); } }
/** * Doesn't do anything other than output the database using default PrintVisitor * @throws IOException when naughty */ @Test public void inspectNewDatabase () throws IOException { Database database = createNewDatabase(); database.visit(new Visitor.Print()); }