Skip to content

Commit 8623695

Browse files
committed
Merge branch 'develop' into main
2 parents d066d97 + 0b389e9 commit 8623695

File tree

6 files changed

+175
-4
lines changed

6 files changed

+175
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Add `keepassxc-proxy-access` as a dependency to your project.
1515
<dependency>
1616
<groupId>org.purejava</groupId>
1717
<artifactId>keepassxc-proxy-access</artifactId>
18-
<version>0.0.4</version>
18+
<version>0.0.5</version>
1919
</dependency>
2020
```
2121

keepassxc-proxy-access.svg

Lines changed: 136 additions & 0 deletions
Loading

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.purejava</groupId>
88
<artifactId>keepassxc-proxy-access</artifactId>
9-
<version>0.0.4</version>
9+
<version>0.0.5</version>
1010
<packaging>jar</packaging>
1111

1212
<name>keepassxc-proxy-access</name>
@@ -274,4 +274,4 @@
274274
</build>
275275
</profile>
276276
</profiles>
277-
</project>
277+
</project>

src/main/java/org/keepassxc/Connection.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,23 @@ public JSONObject getTotp(String uuid) throws IOException, KeepassProxyAccessExc
451451

452452
}
453453

454+
/**
455+
* Request to delete an entry, identified by its uuid.
456+
*
457+
* @param uuid The uuid of the entry.
458+
* @return An object that contains the key "success" with the value "true" in case the request was successful.
459+
* @throws IOException The request to delete the entry failed due to technical reasons.
460+
* @throws KeepassProxyAccessException The entry could not be deleted.
461+
*/
462+
public JSONObject deleteEntry(String uuid) throws IOException, KeepassProxyAccessException {
463+
// Send delete-entry request
464+
sendEncryptedMessage(Map.of(
465+
"action", "delete-entry",
466+
"uuid", ensureNotNull(uuid)
467+
));
468+
return getEncryptedResponseAndDecrypt("delete-entry");
469+
}
470+
454471
/**
455472
* Get a String representation of the JSON object.
456473
*

src/main/java/org/purejava/KeepassProxyAccess.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public String generatePassword() {
330330
/**
331331
* Request for locking the database from client.
332332
*
333-
* @return True, if the database could not locked, false if something went wrong.
333+
* @return True, if the database could be locked, false if something went wrong.
334334
*/
335335
public boolean lockDatabase() {
336336
try {
@@ -376,6 +376,22 @@ public String getTotp(String uuid) {
376376
}
377377
}
378378

379+
/**
380+
* Request to delete an entry, identified by its uuid.
381+
*
382+
* @param uuid The uuid of the entry.
383+
* @return True, in case the entry could be deleted, false otherwise.
384+
*/
385+
public boolean deleteEntry(String uuid) {
386+
try {
387+
var response = connection.deleteEntry(uuid);
388+
return response.has("success") && response.getString("success").equals("true");
389+
} catch (IOException | IllegalStateException | KeepassProxyAccessException | JSONException e) {
390+
log.info(e.toString(), e.getCause());
391+
return false;
392+
}
393+
}
394+
379395
/**
380396
* Extract the groupUuid for the newly created group.
381397
* Note: in case a group with the following path was created: level1/level2, only level2 gets returned as name.

src/test/java/org/purejava/UnlockedDatabaseTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public void shouldHaveNoErrors() {
4040
log.info("Please allow to create new group");
4141
assertEquals(kpa.createNewGroup("Testgroup").get("name"), "Testgroup");
4242
assertTrue(null != kpa.getTotp("2aafee1a89fd435c8bad7df12bbaaa3e") && !kpa.getTotp("2aafee1a89fd435c8bad7df12bbaaa3e").isEmpty());
43+
log.info("Please allow to delete entry");
44+
assertTrue(kpa.deleteEntry("2aafee1a89fd435c8bad7df12bbaaa3e"));
4345
log.info("Please deny to save changes");
4446
assertTrue(kpa.lockDatabase());
4547
}

0 commit comments

Comments
 (0)