Giter Club home page Giter Club logo

keepassjava2's Introduction

KeePassJava2

Maven Central javadoc

alt text master CircleCI develop CircleCI

A Java 8 API for databases compatible with the renowned KeePass password safe for Windows. This is a "headless" implementation - if you want something with a UI then KeePassXC and KeePassDX could be just the things for you.

Features to date:

  • Read and write KeePass 2.x format (File formats V3 and V4)
  • Keepass 2.x Password and Keyfile Credentials
  • Read KeePass 1.x format (Rijndael only)
  • No requirement for JCE Policy Files
  • Android compatible
  • Interfaces for Database, Group and Entry allow compatible addition of other formats

It is licensed under the Apache 2 License and is currently usable.

The work is provided on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY,
or FITNESS FOR A PARTICULAR PURPOSE.

You are solely responsible for determining the appropriateness
of using or redistributing the Work and assume any risks
associated with Your exercise of permissions under this License.

(see license)

Current Status

After a period of neglect, the project is (May 2023) back in development.

The current code is version 2.2.2-SNAPSHOT. This is on the main branch. See Build from Source

Key updates relative to 2.1:

  • Java 8 (dependencies no longer support Java 7)
  • Updated dependencies to remove known vulnerabilities
  • File format version 4 support - with Argon2

See the changelog for more details.

Maven Coordinates

Release

The composite POM for the last release (2.2.1), Java 8 compatible, is

    <groupId>org.linguafranca.pwdb</groupId>
    <artifactId>KeePassJava2</artifactId>
    <version>2.2.1</version>

at Maven Central. Note that the artifactId has become Camel Case from release 2.1.x onwards.

Snapshot

Snapshot builds are erratically available at Sonatype:

    <groupId>org.linguafranca.pwdb</groupId>
    <artifactId>KeePassJava2</artifactId>
    <version>2.2.2-SNAPSHOT</version>

with appropriate <repositories> entry, like:

  <repositories>
     <repository>
       <id>oss.sonatype.org-snapshot</id>
       <url>https://oss.sonatype.org/content/repositories/snapshots</url>
       <releases>
         <enabled>false</enabled>
       </releases>
       <snapshots>
         <enabled>true</enabled>
       </snapshots>
     </repository>
   </repositories>

There are also separate POMs for the various modules. The module structure is illustrated below under Build from Source.

Java Version

From release 2.2 it requires Java 1.8. Earlier versions require Java 1.7.

Quick Start

Create credentials and an input stream for the password vault in question:

  KdbxCreds creds = new KdbxCreds("123".getBytes());
  InputStream inputStream = getClass().getClassLoader().getResourceAsStream("test1.kdbx");

then choose a database implementation, and load the database.

  Database database = SimpleDatabase.load(credentials, inputStream)

or

  Database database = JaxbDatabase.load(credentials, inputStream)

or

  Database database = DomDatabaseWrapper.load(credentials, inputStream)

or

  Database database = JacksonDatabase.load(credentials, inputStream)

Different implementations have varying characteristics, primarily speed. The table below illustrates timings for the file test1.kdbx (in the test module resources - it is around 2k bytes and contains a few dozen entries) as assessed by this test in the "examples" module.

Simple 5 loads 20 iterations 257 millis
Jaxb 5 loads 20 iterations 326 millis
Dom 5 loads 20 iterations 758 millis
Jackson 5 loads 20 iterations 374 millis

Simple 10 loads 1 iterations 340 millis
Jaxb 10 loads 1 iterations 552 millis
Dom 10 loads 1 iterations 175 millis
Jackson 10 loads 1 iterations 343 millis

Simple 1 loads 50 iterations 28 millis
Jaxb 1 loads 50 iterations 47 millis
Dom 1 loads 50 iterations 251 millis
Jackson 1 loads 50 iterations 34 millis

Load time is dominant in this example for JAXB and Simple, database traversal for the DOM implementation.

Discussion

Password databases are modelled as a three layer abstraction.

A Database is a collection of records whose physical representation needs only to be capable of rendering as a stream. Entries hold the information of value in the database and Groups allow the structuring of entries into collections, just like a folder structure.

The Database has a root group and by following subgroups of the root group the tree structure of the database can be navigated. Entries belong to groups. Entries can be moved between groups and groups can also be moved between groups. However, entries and groups created in one database cannot be moved to another database without being converted:

database.newEntry(entryToCopy);
database.newGroup(groupToCopy);

The class Javadoc on Interface classes Database, Group and Entry describe how to use the methods of those classes to create and modify entries. These classes provide the basis of all implementations of the various database formats, initially KDB, KDBX 3.1 and KDBX 4 (KeePass 2) file formats, subsequently, potentially, others.

The class QuickStart.java provides some illustrations of operations using the Database, Group and Entry interfaces.

KeePassJava2 and KeePass

This project is so named by kind permission of Dominik Reichl the author of KeePass. There is no formal connection with that project.

It has always been the intention to support other specific password database implementations. Hence, the creation of abstract Database interfaces rather than following the KeePass model exactly.

KeePass is in effect defined by the code that Dominik writes to create and maintain the project. Hence, there is not much by way of definitive specification of KeePass files other than that code. There is a discussion of the differences between KDBX version 3.1 and version 4. There is also a discussion of the enhancements in KDBX 4.1, as well as a discussion of Key Files.

Massive credit also to the folks over at KeePassXC who wrote some documentation about their understanding of various format things.

For the sake of clarification and my own satisfaction I have written about my understanding of KeePass formats in the following locations:

  1. The Javadoc header to KdbxSerializer describes KDBX stream formatting.
  2. The XSD Schema KDBX.4.xsd documents my understanding of the Keepass XML, and also my lack of understanding, in parts.
  3. The following graphic illustrates KDBX 3.1 and 4 file formats:

KDBX Formats

Dependencies

Aside from the JRE, at release 2.2, the API depends on:

The Simple XML implementation additionally depends on:

The Jackson implementation depends on:

For Java 11 and later Jaxb implementation depends on explicit inclusion no longer provided by JDK of:

It also depends on SLF4J and Junit for tests.

Build from Source

Included POM is for Maven 3.

Module Structure

There are rather a lot of modules, this is in order to allow loading of minimal necessary functionality. The module dependencies are illustrated below.

Module Structure

Each module corresponds to a Maven artifact. The GroupId is org.linguafranca.pwdb. The version id is as noted above.

ModuleArtifactIdJavaDocDescription
databasedatabase Javadocs Base definition of the Database APIs.
exampleexample Javadocs Worked examples of loading, saving, splicing etc. using the APIs
testtest Javadocs Shared tests to assess the viability of the implementation.
allKeePassJava2 (no JavaDoc) This is the main KeePassJava2 Maven dependency. Provides a route to all artifacts (other than test and examples) via transitive dependency.
kdbKeePassJava2-kdb Javadocs An implementation of the Database APIs supporting KeePass KDB format.
kdbxKeePassJava2-kdbx Javadocs Provides support for KDBX streaming and security.
simpleKeePassJava2-simple Javadocs A Simple XML Platform implementation of KDBX. Could be useful for Android.
jaxbKeePassJava2-jaxb Javadocs A JAXB implementation of KDBX. Probably not useful for Android. The generated class bindings might be useful for building other interfaces.
domKeePassJava2-dom Javadocs A DOM based implementation of KDBX. Being DOM based it is rather slow, but messes less with existing content than the other two implementations. Known to work on Android.
domKeePassJava2-jackson Javadocs A Jackson based implementation of KDBX. Intended to replace the Simple XML implementation. Simple XML seems no longer to be maintained.

Why are there so many implementations for KDBX? Well, the DOM implementation came first, because it can load and save stuff that the implementation doesn't specifically know about. But it is very slow.

Then came the JAXB implementation, but belatedly it seems that Android support is in question. So latterly the Simple implementation. That was probably enough KDBX implementations, however, the Simple XML library seems no longer to be maintained, and along comes the Jackson Implementation.

Gradle

If you prefer Gradle the automatic conversion gradle init has been known to convert the POM successfully, however you will need to add something like gradle-source-sets.txt to the build.gradle for the JAXB module, so that the generated sources get compiled correctly.

Change Log

In this file.

Acknowledgements

Many thanks to Pavel Ivanov @ivanovpv for his help with Android and Gradle compatibility issues.

Thanks to Giuseppe Valente @giusvale-dev for the contribution of the Jackson module.

Thanks to other contributors and raisers of issues.

License

Copyright (c) 2023 Jo Rabin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

keepassjava2's People

Contributors

augustnagro avatar giusvale-dev avatar jorabin avatar nigelrook avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keepassjava2's Issues

Error on trying to load the database with KeyFile + Master Password

I have created a database using the KeePass 2 application, which takes a Master Password and a KeyFile. I want to open that database in Java, using this library. But I get the following error on the load method:

Exception in thread "main" java.lang.IllegalStateException: Inconsistent stream start bytes. This usually means the credentials were wrong.
at org.linguafranca.pwdb.kdbx.stream_3_1.KdbxSerializer.checkStartBytes(KdbxSerializer.java:129)
at org.linguafranca.pwdb.kdbx.stream_3_1.KdbxSerializer.createUnencryptedInputStream(KdbxSerializer.java:88)
at org.linguafranca.pwdb.kdbx.stream_3_1.KdbxStreamFormat.load(KdbxStreamFormat.java:37)
at org.linguafranca.pwdb.kdbx.dom.DomDatabaseWrapper.(DomDatabaseWrapper.java:57)
at org.linguafranca.pwdb.kdbx.dom.DomDatabaseWrapper.load(DomDatabaseWrapper.java:62)
at com.ni.apps.hardware.activation.test.DatabaseTest.(DatabaseTest.java:18)

This is my code for trying to load the database:

InputStream databaseStream = getClass().getResourceAsStream("Database.kdbx");
InputStream keyStream = getClass().getResourceAsStream("Database.keyx");
KeyFile keyFile = new KeyFile("MyPassword".getBytes(), keyStream);
Database database = DomDatabaseWrapper.load(keyFile, databaseStream);
List<Entry> entries = database.findEntries("Sample Entry");
Entry entry = entries.get(0);

I have tried SimpleDatabase and JaxbDatabase, they give this
error. I also tried a version 1.0 keyfile, gives the same error.

I am able to open the database with this password and file in the application fine.
Also, creating a database with just password works fine with the KeePassJava2. Only the Keyfile is the issue.
I have attached the test data with this issue
Database.zip

Loading database failed: race condition in HashedBlockInputStream

Loading a database may fail when accessed by multiple threads. The reason seems to be that in HashedBlockInputStream, there is unsynchronized access to the static field md5. BTW: This is misnamed since it computes SHA256, not MD5.

Stacktrace:

MD5 check failed while reading HashBlock
 at org.linguafranca.pwdb.hashedblock.HashedBlockInputStream.load(HashedBlockInputStream.java:170)
 at org.linguafranca.pwdb.hashedblock.HashedBlockInputStream.get(HashedBlockInputStream.java:122)
 at org.linguafranca.pwdb.hashedblock.HashedBlockInputStream.read(HashedBlockInputStream.java:89)
 at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
 at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
 at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:117)
 at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:122)
 at org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.readAndBuffer(XMLEntityManager.java:3116)
 at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:1018)
 at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:144)
 at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:832)
 at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:798)
 at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
 at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1198)
 at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:564)
 at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:258)
 at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:229)
 at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:136)
 at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:183)
 at org.linguafranca.pwdb.kdbx.jaxb.JaxbSerializableDatabase.load(JaxbSerializableDatabase.java:77)
 at org.linguafranca.pwdb.kdbx.jaxb.JaxbSerializableDatabase.load(JaxbSerializableDatabase.java:41)
 at org.linguafranca.pwdb.kdbx.stream_3_1.KdbxStreamFormat.load(KdbxStreamFormat.java:39)
 at org.linguafranca.pwdb.kdbx.jaxb.JaxbDatabase.load(JaxbDatabase.java:71)
 at org.linguafranca.pwdb.kdbx.jaxb.JaxbDatabase.load(JaxbDatabase.java:64)

Custom icons cause problems

I was given a manually created kdbx file containing a few custom icons. If I load (and edit, but thats not yet relevant) and save the database with KeePassJava2, the following problems occur, depending on the kind of database implementation I use:

SimpleDatabase

SimpleDatabase.load(creds, input).save(creds, output);

The following error is thrown

org.simpleframework.xml.core.ElementException: Element 'CustomIconUUID' does not have a match in class org.linguafranca.pwdb.kdbx.simple.SimpleGroup at line 341

JaxbDatabase

JaxbDatabase.load(creds, input).save(creds, output);

No error is thrown, but the custom icons are replaced with default blue folder icon (48). Also the entire file is skipped when I try to search something via the desktop application (Searching entries in this group: Disabled), which wasn't the case before.

DomDatabaseWrapper

DomDatabaseWrapper.load(creds, input).save(creds, output)

Custom icons are still there and I can also still search via the desktop application, but the loading and saving takes a very long time (a couple of minutes for a ~200kB file).

Is there a way to preserve the custom icons and the searchability while using one of the faster database implementations?

Split Packages and JPMS

Because KeePassJava2 has split packages (org.linguafranca.pwdb.kdbx in both KeePassJava2.kdbx and KeePassJava2.simple), the library can't be used with the Java 9 module system.

Would there be any interest in refactoring? For reference: https://stackoverflow.com/a/42358212

Regards,

August

SimpleXML doesn't play nicely with Java17

[ERROR] Errors: 
[ERROR]   KdbxInnerOutputStreamTest.test:46 » IllegalState java.lang.reflect.InaccessibleObjectException: Unable to make field private final long java.util.UUID.mostSigBits accessible: module java.base does not "opens java.util" to unnamed module @a803f94
[ERROR]   SimpleSaveAndReloadTest>SaveAndReloadChecks.saveAndReloadTest:59->saveDatabase:52 » IllegalState java.lang.reflect.InaccessibleObjectException: Unable to make field private final long java.util.UUID.mostSigBits accessible: module java.base does not "opens java.util" to unnamed module @a803f94
[ERROR]   SimpleSaveAndReloadTest>SaveAndReloadChecks.saveAndReloadTest2:103->saveDatabase:52 » IllegalState java.lang.reflect.InaccessibleObjectException: Unable to make field private final long java.util.UUID.mostSigBits accessible: module java.base does not "opens java.util" to unnamed module @a803f94
[ERROR]   SimpleSaveAndReloadTest.uppercaseBooleanTest:74 » IllegalState java.lang.reflect.InaccessibleObjectException: Unable to make field private final long java.util.UUID.mostSigBits accessible: module java.base does not "opens java.util" to unnamed module @a803f94

Looks a lot like it's trying to use reflection and can't.

Database allows to create properties with the same name

public static void main( String[] args )
    {
        try {
            
            Database database = new JacksonDatabase();
            Group test = database.newGroup("TEST");
            Entry entry = database.newEntry("Entry");
            
            entry.setTitle("Entry title");
            entry.setPassword("password");
            entry.setNotes("Notes");
            entry.setProperty("Properties 1", "Secret 1");
            entry.setProperty("Properties 1", "Secret 2");
            entry.setUsername("username");
            entry.setUrl("url");
            test.addEntry(entry);
            database.setName("My first DB");
            database.getRootGroup().addGroup(test);

            try (FileOutputStream outputStream = new FileOutputStream("test.kdbx")) {
                database.save(new KdbxCreds("123".getBytes()), outputStream);
            }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

I expected an exception (we can't have 2 properties with the same name) but the result is the property overwritten.
This is an expected result?

add a Database#setRecycleBin(Group g) method

as mentioned by @aivanovski in his pull request #34 this would allow people to programmatically assign a group as a recycle bin for reasons including those stated in the pull request, of some implementations not hooking the metadata together correctly.

There will need to be some thought as to what happens when there is already a recycle bin assigned, would be grateful for some views. Here's the JavaDoc on getRecycleBin() as it currently stands.

Excessively chatty output on tests

I'm trying to re-instate CI builds, which used to be in place till Travis decided they didn't want to support things any more.

Many of the unit tests output a lot of stuff (XML of files, for example). This makes it difficult to assess what is going on when running CI if things go wrong. And they do, especially when you are fumbling around trying to set it all up on a new provider. If anyone has experience with CircleCI ...

So this is a request for me to allow tests to be directed to a null PrintStream on setting of a "inhibitConsoleOutput" Maven profile, but to continue to write to console if that profile is not selected.

At the same time, the granularity of Maven test output is not great, so please implement a MavenRunListener to report on the success of each test. This will increase the amount of output, again, but usefully so.

KeyFiles

As noted in #38 KeyPassJava2 did not support KeyFile XML Version 2.

That's now been fixed, however it seems there is more to this than I had realised. See MasterKey for further details of what can be used as Key Files.

Changes suggested by this information as follows:

  • KeyFile version 2 support to check hash
  • Files of exactly 32 and 64 bytes to be processed as binary or Hex encoded keys (respectively).
  • Random other files to be hashed and used.

gradle init

I tried to compile with gradle:


Gradle 2.10

Groovy: 2.4.5
Ant: Apache Ant(TM) version 1.9.6 compiled on July 20 2018
JVM: 1.8.0_191 (Oracle Corporation 25.191-b12)
OS: Linux 4.4.0-145-generic amd64

I got:

Caused by: org.codehaus.plexus.util.dag.CycleDetectedException: Edge between 'Vertex{label='org.apache.maven.plugin.MavenPluginManager:default'}' and 'Vertex{label='org.apache.maven.plugin.version.PluginVersionResolver:default'}' introduces to cycle in the graph org.apache.maven.plugin.version.PluginVersionResolver:default --> org.apache.maven.plugin.MavenPluginManager:default --> org.apache.maven.plugin.version.PluginVersionResolver:default
at org.codehaus.plexus.util.dag.DAG.addEdge(DAG.java:143)
at org.codehaus.plexus.util.dag.DAG.addEdge(DAG.java:123)
at org.codehaus.plexus.component.composition.DefaultCompositionResolver.addComponentDescriptor(DefaultCompositionResolver.java:60)
... 79 more

any idea?
Thank You

Open database only with key file

Hi. I don't have password to open my database, so how I make this operation with only the key file?

In the code below, I get NullPointerException.

InputStream inputStreamDB = new FileInputStream("C:\TESTE.kdbx");
InputStream inputStreamKeyFile = new FileInputStream("C:\Teste.key");
Credentials credentials = new KdbxCredentials.KeyFile(null, inputStreamKeyFile);
Database database = DomDatabaseWrapper.load(credentials, inputStreamDB);

Android compilation time warning

Gradle reports:

Warning:WARNING: Dependency xpp3:xpp3:1.1.3.3 is ignored for %project_name% as it may be conflicting with the internal version provided by Android.

Performance issue

library which works fine while loading for the first time but from the subsequent calls, it take around 30-40 seconds.

I tried using all 3 loaders but everything takes a long time to load. I have records with 3000 entries. Could you please check this performance issue?

Thanks,
Murthy

Support latest version of KeePass

I created a keepass archive with the latest version of KeePassXC (2.1.7). When loading with KeePassJava2 2.1.4 I get this error:

 Exception in thread "main" java.lang.IllegalStateException: File version did not match

Code:

public static void main(final String... args) throws Exception {
    final var credentials = new KdbxCreds("mypass".getBytes());
    try (final var inputStream = TestLoading.class.getResourceAsStream("myarchive.kdbx")) {
        final var database = SimpleDatabase.load(credentials, inputStream);
        System.out.println(database);
    }
}

Android library compatibility issue

During compilation it reports java.xml.*.class compatibility issues - looks like Maven's jar compiled against Sun's JVM with incompatible binaries within class files

Gradle's error message read:

trouble processing "javax/xml/XMLConstants.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.

DomDatabaseWrapper is slow

DomDatabaseWrapper accesses data using the DOM. While this ensures that things that KeepassJava2 doesn't understand are saved and loaded transparently it also means that it is not very quick. An alternative in-memory implementation would be quicker.

Composite Key with binary key file

Hi,

I'm trying to use your library but it seems that only XML key files are supported, is there any workaround to use a Binary Key File?

Thanks!

Error with composite key

Tried to load test database with DomDatabaseWrapper.

Database was created with KeePass v. 2.34 for Windows and secured with composite key: password+key file.

Code looks like:

  Credentials credentials = new KdbxCreds(password.getBytes(), keyInputStream);
  DomDatabaseWrapper.load(credentials, databaseInputStream);

Meantime, if I remove from database composite key (i.e. only password based encryption) - I'm able to read database correctly using:

  Credentials credentials = new KdbxCreds(password.getBytes());
  DomDatabaseWrapper.load(credentials, databaseInputStream);

java.lang.NoSuchMethodError saving SimpleDatabase on Android

When I save the SimpleDatabase

        val basePath = ContextWrapper(context).filesDir
        val credentials = KdbxCreds(credentials.toByteArray())
        val db = secureDatabase ?: return
        FileOutputStream("$basePath${File.separator}$database.kdbx").use { outputStream ->
            db.save(credentials, outputStream)
        }

I get this error:

java.lang.NoSuchMethodError: No static method encodeBase64String([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)
        at org.linguafranca.pwdb.kdbx.Helpers.encodeBase64Content(Helpers.java:119)
        at org.linguafranca.pwdb.kdbx.simple.converter.Base64ByteArrayConverter.write(Base64ByteArrayConverter.java:38)
        at org.linguafranca.pwdb.kdbx.simple.converter.Base64ByteArrayConverter.write(Base64ByteArrayConverter.java:28)
        at org.simpleframework.xml.convert.AnnotationStrategy.write(AnnotationStrategy.java:180)
        at org.simpleframework.xml.convert.AnnotationStrategy.write(AnnotationStrategy.java:156)
        at org.simpleframework.xml.core.Source.setOverride(Source.java:384)
        at org.simpleframework.xml.core.Factory.setOverride(Factory.java:170)
        at org.simpleframework.xml.core.Composite.isOverridden(Composite.java:1312)
        at org.simpleframework.xml.core.Composite.writeElement(Composite.java:1234)
        at org.simpleframework.xml.core.Composite.writeUnion(Composite.java:1127)
        at org.simpleframework.xml.core.Composite.writeElements(Composite.java:1098)
        at org.simpleframework.xml.core.Composite.writeSection(Composite.java:1004)
        at org.simpleframework.xml.core.Composite.write(Composite.java:975)
        at org.simpleframework.xml.core.Composite.write(Composite.java:952)
        at org.simpleframework.xml.core.Composite.writeElement(Composite.java:1256)
        at org.simpleframework.xml.core.Composite.writeElement(Composite.java:1239)
        at org.simpleframework.xml.core.Composite.writeUnion(Composite.java:1127)
        at org.simpleframework.xml.core.Composite.writeElements(Composite.java:1098)
        at org.simpleframework.xml.core.Composite.writeSection(Composite.java:1004)
        at org.simpleframework.xml.core.Composite.write(Composite.java:975)
        at org.simpleframework.xml.core.Composite.write(Composite.java:952)
        at org.simpleframework.xml.core.Traverser.write(Traverser.java:236)
        at org.simpleframework.xml.core.Traverser.write(Traverser.java:208)
        at org.simpleframework.xml.core.Traverser.write(Traverser.java:186)
        at org.simpleframework.xml.core.Persister.write(Persister.java:1180)
        at org.simpleframework.xml.core.Persister.write(Persister.java:1162)
        at org.simpleframework.xml.core.Persister.write(Persister.java:1140)
        at org.simpleframework.xml.core.Persister.write(Persister.java:1259)
        at org.simpleframework.xml.core.Persister.write(Persister.java:1241)
        at org.simpleframework.xml.core.Persister.write(Persister.java:1222)
        at org.linguafranca.pwdb.kdbx.simple.SimpleDatabase.save(SimpleDatabase.java:236)
...

any suggestion?

compile error with Java 11

The project does not compile with Java 11 or later. JAXB has been removed from JavaSE and needs to be provided explicitly.

Unparseable date

I am getting this exception when parsing KDBX 3.1 file that was edited (loaded, modified, saved) by pykeepass:

Caused by: java.lang.IllegalStateException: java.text.ParseException: Unparseable date: "2021-01-02T03:31:49.386013+00:00"
	at org.linguafranca.pwdb.kdbx.Helpers.toDate(Helpers.java:83)
	at org.linguafranca.pwdb.kdbx.simple.converter.TimeConverter.read(TimeConverter.java:36)
	at org.linguafranca.pwdb.kdbx.simple.converter.TimeConverter.read(TimeConverter.java:29)
	...
	at org.linguafranca.pwdb.kdbx.simple.SimpleDatabase.load(SimpleDatabase.java:192)
	...

KeePassJava2 expects timestamps to match format yyyy-MM-dd'T'HH:mm:ss'Z'.

So which implementation of the format is wrong, pykeepass or KeePassJava2?

KeePassX opens the file without error and displays the timestamps correctly.

[Bug] Issues with Dependencies

There are following CVE issues with some of the dependencies used by KeePassJava2 that need to be addressed:

  1. commons-codec:commons-codec:jar:1.10: WS-2019-0379: This library is vulnerable to information disclosure due to Improper Input validation.
  2. org.simpleframework:simple-xml:jar:2.7.1: CVE-2017-1000190: SimpleXML (latest version 2.7.1) is vulnerable to an XXE vulnerability resulting SSRF, information disclosure, DoS and so on.
  3. com.google.guava:guava:jar:20.0: CVE-2018-10237 Unbounded memory allocation in Google Guava 11.0 through 24.x before 24.1.1 allows remote attackers to conduct denial of service attacks against servers that depend on this library and deserialize attacker-provided data, because the AtomicDoubleArray class (when serialized with Java serialization) and the CompoundOrdering class (when serialized with GWT serialization) perform eager allocation without appropriate checks on what a client has sent and whether the data size is reasonable.

These CVEs need to be addressed on KeePassJava2 library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.