JaxbSerializableDatabase implements SerializableDatabase { @Override public JaxbSerializableDatabase load(InputStream inputStream) { try { JAXBContext jc = JAXBContext.newInstance(KeePassFile.class); Unmarshaller u = jc.createUnmarshaller(); u.setListener(new Unmarshaller.Listener() { @Override public void afterUnmarshal(Object target, Object parent) { try { if (target instanceof StringField.Value) { StringField.Value value = (StringField.Value) target; if (value.getProtected() !=null && value.getProtected()) { byte[] encrypted = Base64.decodeBase64(value.getValue().getBytes()); String decrypted = new String(encryption.decrypt(encrypted), "UTF-8"); value.setValue(decrypted); value.setProtected(false); } } if (target instanceof JaxbGroupBinding && (parent instanceof JaxbGroupBinding)) { ((JaxbGroupBinding) target).parent = ((JaxbGroupBinding) parent); } if (target instanceof JaxbEntryBinding && (parent instanceof JaxbGroupBinding)) { ((JaxbEntryBinding) target).parent = ((JaxbGroupBinding) parent); } } catch (UnsupportedEncodingException e) { throw new IllegalStateException(); } } }); keePassFile = (KeePassFile) u.unmarshal(inputStream); return this; } catch (JAXBException e) { throw new IllegalStateException(e); } }  @Override JaxbSerializableDatabase load(InputStream inputStream); @Override void save(OutputStream outputStream); @Override StreamEncryptor getEncryption(); @Override void setEncryption(StreamEncryptor encryption); @Override byte[] getHeaderHash(); @Override void setHeaderHash(byte[] hash); KeePassFile getKeePassFile(); void setKeePassFile(KeePassFile keypassFile);  }
@Test public void loadXml() throws Exception { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("test123.kdbx"); JaxbDatabase database = JaxbDatabase.load(new KdbxCreds("123".getBytes()), inputStream); database.visit(new Visitor.Print()); }