Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
purejava committed Oct 3, 2021
2 parents 8623695 + 376a799 commit 4702a36
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Add `keepassxc-proxy-access` as a dependency to your project.
<dependency>
<groupId>org.purejava</groupId>
<artifactId>keepassxc-proxy-access</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
</dependency>
```

Expand Down Expand Up @@ -48,6 +48,7 @@ Communication with KeePassXC happens via the KeePassXC protocol. Currently, the
* `get-database-groups`: Request to retrieve all database groups together with their groupUuids.
* `create-new-group`: Request to create a new group for the given name or path.
* `get-totp`: Request for receiving the current TOTP.
* `delete-entry`: Request for deleting an entry in the database, identified by its uuid.
* `database-locked`: A signal from KeePassXC, the current active database is locked.
* `database-unlocked`: A signal from KeePassXC, the current active database is unlocked.

Expand All @@ -61,4 +62,4 @@ Copyright (C) 2021 Ralph Plawetzki

The keepassxc-proxy-access logo is based on an [ICONFINDER logo](https://www.iconfinder.com/icons/4484570/hosting_link_proxy_server_url_window_icon) that is published under the [Creative Commons Attribution 3.0 Unported licence](https://creativecommons.org/licenses/by/3.0/) (CC BY 3.0). I modified the icon to my needs by changing the interior and adding the KeePassXC logo.

The KeePassXC logo is Copyright (C) of https://keepassxc.org/
The KeePassXC logo is Copyright (C) of https://keepassxc.org/
9 changes: 5 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.purejava</groupId>
<artifactId>keepassxc-proxy-access</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
<packaging>jar</packaging>

<name>keepassxc-proxy-access</name>
Expand Down Expand Up @@ -54,11 +54,11 @@
<maven.compiler.target>1.9</maven.compiler.target>

<tweetnacl.version>1.1.2</tweetnacl.version>
<junixsocket.version>2.3.4</junixsocket.version>
<junixsocket.version>2.4.0</junixsocket.version>
<json.version>20210307</json.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<junit.version>5.7.0</junit.version>
<slf4j.version>1.7.30</slf4j.version>
<junit.version>5.8.1</junit.version>
<slf4j.version>1.7.32</slf4j.version>
</properties>

<!-- tweetnacl-java -->
Expand All @@ -74,6 +74,7 @@
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-core</artifactId>
<version>${junixsocket.version}</version>
<type>pom</type>
</dependency>

<!-- JSON for Java -->
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/purejava/KeepassProxyAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public Map<String, Object> getLogins(String url, String submitUrl, boolean httpA
}

/**
* Checks, if a password is stored in the KeePassXC databases. This method calls
* Checks, whether a login exists and a given password is stored in the KeePassXC databases. This method calls
* {@link org.purejava.KeepassProxyAccess#getLogins(String, String, boolean, List) getLogins} to search
* the KeePassXC databases.
* @see org.purejava.KeepassProxyAccess#getLogins(String, String, boolean, List)
Expand All @@ -256,19 +256,19 @@ public Map<String, Object> getLogins(String url, String submitUrl, boolean httpA
* @param httpAuth Include database entries into search that are restricted to HTTP Basic Auth.
* @param list Id / key combinations identifying and granting access to KeePassXC databases.
* @param password Password to check.
* @return True, if the password was found in a KeePassXC database, false otherwise.
* @return ValidLogin The object describes whether a valid login exists for the given URL and whether the given password matches too.
*/
public boolean loginExists(String url, String submitUrl, boolean httpAuth, List<Map<String, String>> list, String password) {
public ValidLogin loginExists(String url, String submitUrl, boolean httpAuth, List<Map<String, String>> list, String password) {
var response = getLogins(url, submitUrl, httpAuth, list);
if (response.isEmpty()) {
return false;
return new ValidLogin(false, null);
}
var array = (ArrayList<Object>) response.get("entries");
for (Object o : array) {
var credentials = (HashMap<String, Object>) o;
if (credentials.get("password").equals(password)) return true;
if (credentials.get("password").equals(password)) return new ValidLogin(true, credentials.get("uuid").toString());
}
return false;
return new ValidLogin(true, null);
}

/**
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/org/purejava/ValidLogin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.purejava;

import java.util.List;

/**
* This holds the result of a call to {@link org.purejava.KeepassProxyAccess#loginExists(String, String, boolean, List, String)}
* @see org.purejava.KeepassProxyAccess#loginExists(String, String, boolean, List, String)
*/
public class ValidLogin {
private boolean found;
private String uuid;

/**
* Does a valid login exist for the given URL? And does the given password match too?
* @param found True, if an entry was found in the KeePassXC database for the given URL.
* @param uuid If found is true, this contains either the uuid, in case the given password matches
* the password already stored in the entry or null in case the given password does not match.
*/
public ValidLogin(boolean found, String uuid) {
this.found = found;
this.uuid = uuid;
}

public boolean isFound() {
return found;
}

public String getUuid() {
return uuid;
}
}

0 comments on commit 4702a36

Please sign in to comment.