Skip to content

Commit 50af7f6

Browse files
committed
In opposite to the protocol documentation
the successful response contains a JSONObject
1 parent 1a3f891 commit 50af7f6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public boolean requestAutotype(String url) {
424424
}
425425
}
426426

427-
public String passkeysRegister(JSONObject publicKey, String origin, List<Map<String, String>> list) {
427+
public JSONObject passkeysRegister(JSONObject publicKey, String origin, List<Map<String, String>> list) {
428428
try {
429429
var response = connection.passkeysRegister(publicKey, origin, list);
430430
if (response.has("response") && response.has("success") && response.getString("success").equals("true")) {
@@ -433,15 +433,15 @@ public String passkeysRegister(JSONObject publicKey, String origin, List<Map<Str
433433
throw new KeepassProxyAccessException("ErrorCode: " + errorCode);
434434

435435
} catch (JSONException e) {
436-
return response.getString("response"); // PublicKeyCredential
436+
return response.getJSONObject("response"); // PublicKeyCredential
437437
}
438438
} else {
439-
return "";
439+
return new JSONObject();
440440
}
441441
} catch (IOException | KeepassProxyAccessException e) {
442442
LOG.info(e.toString(), e.getCause());
443443
}
444-
return "";
444+
return new JSONObject();
445445
}
446446

447447
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ public void shouldHaveNoErrors() throws InterruptedException {
5151
assertTrue(kpa.requestAutotype("https://github.com"));
5252
LOG.info("Please allow to delete entry");
5353
assertTrue(kpa.deleteEntry("2aafee1a89fd435c8bad7df12bbaaa3e"));
54+
LOG.info("Please register the offered Passkey");
5455
String publicKey = "{\"attestation\":\"direct\",\"authenticatorSelection\":{\"requireResidentKey\":true,\"residentKey\":\"required\",\"userVerification\":\"preferred\"},\"challenge\":\"AICQS3rj6P-dIDb5if3OCte-Y7CEs_BEnpTgoasQRXg\",\"excludeCredentials\":[],\"extensions\":{\"credProps\":true},\"pubKeyCredParams\":[{\"alg\":-7,\"type\":\"public-key\"},{\"alg\":-257,\"type\":\"public-key\"}],\"rp\":{\"id\":\"passkey.org\",\"name\":\"Yubico Demo\"},\"timeout\":90000,\"user\":{\"displayName\":\"purejava\",\"id\":\"DEMO__9fX19ERU1P\",\"name\":\"purejava\"}}";
5556
JSONObject p = new JSONObject(publicKey);
56-
LOG.info(kpa.passkeysRegister(p, "https://passkey.org", l));
57+
assertTrue(kpa.passkeysRegister(p, "https://passkey.org", l).getJSONObject("response").getString("clientDataJSON").equals("eyJjaGFsbGVuZ2UiOiJBSUNRUzNyajZQLWRJRGI1aWYzT0N0ZS1ZN0NFc19CRW5wVGdvYXNRUlhnIiwiY3Jvc3NPcmlnaW4iOmZhbHNlLCJvcmlnaW4iOiJodHRwczovL3Bhc3NrZXkub3JnIiwidHlwZSI6IndlYmF1dGhuLmNyZWF0ZSJ9"));
5758
LOG.info("Please deny to save changes");
5859
assertTrue(kpa.lockDatabase());
5960
assertTrue(kpa.shutdown());

0 commit comments

Comments
 (0)