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 Sep 11, 2021
2 parents d066d97 + 0b389e9 commit 8623695
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 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.4</version>
<version>0.0.5</version>
</dependency>
```

Expand Down
136 changes: 136 additions & 0 deletions keepassxc-proxy-access.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 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.4</version>
<version>0.0.5</version>
<packaging>jar</packaging>

<name>keepassxc-proxy-access</name>
Expand Down Expand Up @@ -274,4 +274,4 @@
</build>
</profile>
</profiles>
</project>
</project>
17 changes: 17 additions & 0 deletions src/main/java/org/keepassxc/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,23 @@ public JSONObject getTotp(String uuid) throws IOException, KeepassProxyAccessExc

}

/**
* Request to delete an entry, identified by its uuid.
*
* @param uuid The uuid of the entry.
* @return An object that contains the key "success" with the value "true" in case the request was successful.
* @throws IOException The request to delete the entry failed due to technical reasons.
* @throws KeepassProxyAccessException The entry could not be deleted.
*/
public JSONObject deleteEntry(String uuid) throws IOException, KeepassProxyAccessException {
// Send delete-entry request
sendEncryptedMessage(Map.of(
"action", "delete-entry",
"uuid", ensureNotNull(uuid)
));
return getEncryptedResponseAndDecrypt("delete-entry");
}

/**
* Get a String representation of the JSON object.
*
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/org/purejava/KeepassProxyAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public String generatePassword() {
/**
* Request for locking the database from client.
*
* @return True, if the database could not locked, false if something went wrong.
* @return True, if the database could be locked, false if something went wrong.
*/
public boolean lockDatabase() {
try {
Expand Down Expand Up @@ -376,6 +376,22 @@ public String getTotp(String uuid) {
}
}

/**
* Request to delete an entry, identified by its uuid.
*
* @param uuid The uuid of the entry.
* @return True, in case the entry could be deleted, false otherwise.
*/
public boolean deleteEntry(String uuid) {
try {
var response = connection.deleteEntry(uuid);
return response.has("success") && response.getString("success").equals("true");
} catch (IOException | IllegalStateException | KeepassProxyAccessException | JSONException e) {
log.info(e.toString(), e.getCause());
return false;
}
}

/**
* Extract the groupUuid for the newly created group.
* Note: in case a group with the following path was created: level1/level2, only level2 gets returned as name.
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/purejava/UnlockedDatabaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public void shouldHaveNoErrors() {
log.info("Please allow to create new group");
assertEquals(kpa.createNewGroup("Testgroup").get("name"), "Testgroup");
assertTrue(null != kpa.getTotp("2aafee1a89fd435c8bad7df12bbaaa3e") && !kpa.getTotp("2aafee1a89fd435c8bad7df12bbaaa3e").isEmpty());
log.info("Please allow to delete entry");
assertTrue(kpa.deleteEntry("2aafee1a89fd435c8bad7df12bbaaa3e"));
log.info("Please deny to save changes");
assertTrue(kpa.lockDatabase());
}
Expand Down

0 comments on commit 8623695

Please sign in to comment.