updateOrStoreWebAuthnCredentials(Authenticator authenticator) {
+ WebAuthnCredential credential1 = new WebAuthnCredential(authenticator);
+ usersRepo.getUser(authenticator.getUserName())
+ .ifPresentOrElse(
+ user -> usersRepo.register(user.withAddedCredential(credential1)),
+ () -> usersRepo.register(new User(authenticator.getUserName(), null, List.of(credential1)))
+ );
+ return Uni.createFrom().nullItem();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ysoft/geecon/webauthn/WebAuthnCredential.java b/src/main/java/com/ysoft/geecon/webauthn/WebAuthnCredential.java
new file mode 100644
index 0000000..200c5ab
--- /dev/null
+++ b/src/main/java/com/ysoft/geecon/webauthn/WebAuthnCredential.java
@@ -0,0 +1,95 @@
+package com.ysoft.geecon.webauthn;
+
+import io.vertx.ext.auth.webauthn.Authenticator;
+import io.vertx.ext.auth.webauthn.PublicKeyCredential;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class WebAuthnCredential {
+
+ /**
+ * The username linked to this authenticator
+ */
+ public String userName;
+
+ /**
+ * The type of key (must be "public-key")
+ */
+ public String type = "public-key";
+
+ /**
+ * The non user identifiable id for the authenticator
+ */
+ public String credID;
+
+ /**
+ * The public key associated with this authenticator
+ */
+ public String publicKey;
+
+ /**
+ * The signature counter of the authenticator to prevent replay attacks
+ */
+ public long counter;
+
+ public String aaguid;
+
+ /**
+ * The Authenticator attestation certificates object, a JSON like:
+ * {@code
+ * {
+ * "alg": "string",
+ * "x5c": [
+ * "base64"
+ * ]
+ * }
+ * }
+ */
+ /**
+ * The algorithm used for the public credential
+ */
+ public PublicKeyCredential alg;
+
+ /**
+ * The list of X509 certificates encoded as base64url.
+ */
+ public List x5c = new ArrayList<>();
+
+ public String fmt;
+
+ public WebAuthnCredential() {
+ }
+
+ public WebAuthnCredential(Authenticator authenticator) {
+ aaguid = authenticator.getAaguid();
+ if (authenticator.getAttestationCertificates() != null)
+ alg = authenticator.getAttestationCertificates().getAlg();
+ counter = authenticator.getCounter();
+ credID = authenticator.getCredID();
+ fmt = authenticator.getFmt();
+ publicKey = authenticator.getPublicKey();
+ type = authenticator.getType();
+ userName = authenticator.getUserName();
+
+ if (authenticator.getAttestationCertificates() != null
+ && authenticator.getAttestationCertificates().getX5c() != null) {
+ this.x5c.addAll(authenticator.getAttestationCertificates().getX5c());
+ }
+// this.user = user;
+// user.webAuthnCredential = this;
+ }
+
+// public static Uni> findByUserName(String userName) {
+// return list("userName", userName);
+// }
+//
+// public static Uni> findByCredID(String credID) {
+// return list("credID", credID);
+// }
+//
+// public Uni fetch(T association) {
+// return getSession().flatMap(session -> session.fetch(association));
+// }
+}
\ No newline at end of file
diff --git a/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java b/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java
index c4bcc00..0e5d2b9 100644
--- a/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java
+++ b/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java
@@ -37,7 +37,7 @@ public class AuthCodeGrantTest {
@BeforeEach
void beforeAll() {
clientsRepo.register(CLIENT);
- usersRepo.register(new User("bob", "password"));
+ usersRepo.register(new User("bob", "password", List.of()));
}
@Test
diff --git a/src/test/java/com/ysoft/geecon/DeviceAuthGrantTest.java b/src/test/java/com/ysoft/geecon/DeviceAuthGrantTest.java
index 2dcb77f..2e3014e 100644
--- a/src/test/java/com/ysoft/geecon/DeviceAuthGrantTest.java
+++ b/src/test/java/com/ysoft/geecon/DeviceAuthGrantTest.java
@@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.net.URI;
+import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -44,7 +45,7 @@ public class DeviceAuthGrantTest {
@BeforeEach
void beforeAll() {
clientsRepo.register(CLIENT);
- usersRepo.register(new User("bob", "password"));
+ usersRepo.register(new User("bob", "password", List.of()));
}