Skip to content

Commit 3930a43

Browse files
committed
Catch up changes of WebAuthn4j 0.24.0
1 parent 89f2392 commit 3930a43

File tree

12 files changed

+185
-263
lines changed

12 files changed

+185
-263
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ buildscript {
2525
httpBuilderVersion = '0.7.2'
2626

2727
//Libraries
28-
webauthn4jVersion = '0.23.0.RELEASE'
28+
webauthn4jVersion = '0.24.0.RELEASE'
2929
springSecurityVersion = '6.0.2'
3030
hibernateValidatorVersion = '8.0.1.Final'
3131
thymeleafVersion = '3.0.4.RELEASE'

samples/spa/src/main/java/com/webauthn4j/springframework/security/webauthn/sample/app/util/AppSpecificMapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public ProfileForm mapToProfileForm(UserEntity userEntity) {
5858
private AuthenticatorEntity mapForCreate(AuthenticatorForm authenticatorForm) {
5959
AuthenticatorEntity authenticatorEntity = new AuthenticatorEntity();
6060
authenticatorEntity.setName(authenticatorForm.getName());
61+
authenticatorEntity.setClientData(authenticatorForm.getClientData().getCollectedClientData());
62+
authenticatorEntity.setUvInitialized(authenticatorForm.getAttestationObject().getAttestationObject().getAuthenticatorData().isFlagUV());
63+
authenticatorEntity.setBackupEligible(authenticatorForm.getAttestationObject().getAttestationObject().getAuthenticatorData().isFlagBE());
64+
authenticatorEntity.setBackedUp(authenticatorForm.getAttestationObject().getAttestationObject().getAuthenticatorData().isFlagBS());
6165
authenticatorEntity.setAttestationStatement(authenticatorForm.getAttestationObject().getAttestationObject().getAttestationStatement());
6266
authenticatorEntity.setAttestedCredentialData(authenticatorForm.getAttestationObject().getAttestationObject().getAuthenticatorData().getAttestedCredentialData());
6367
return authenticatorEntity;

samples/spa/src/main/java/com/webauthn4j/springframework/security/webauthn/sample/domain/entity/AuthenticatorEntity.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.webauthn4j.data.AuthenticatorTransport;
2020
import com.webauthn4j.data.attestation.authenticator.AttestedCredentialData;
2121
import com.webauthn4j.data.attestation.statement.AttestationStatement;
22+
import com.webauthn4j.data.client.CollectedClientData;
2223
import com.webauthn4j.data.extension.authenticator.AuthenticationExtensionsAuthenticatorOutputs;
2324
import com.webauthn4j.data.extension.authenticator.RegistrationExtensionAuthenticatorOutput;
2425
import com.webauthn4j.data.extension.client.AuthenticationExtensionsClientOutputs;
@@ -48,6 +49,10 @@ public class AuthenticatorEntity implements WebAuthnAuthenticator {
4849

4950
private long counter;
5051

52+
private boolean uvInitialized;
53+
private boolean backupEligible;
54+
private boolean backedUp;
55+
5156
@ElementCollection(fetch = FetchType.EAGER)
5257
@CollectionTable(name = "m_transport", joinColumns = @JoinColumn(name = "authenticator_id"))
5358
@Column(name = "transport")
@@ -70,6 +75,10 @@ public class AuthenticatorEntity implements WebAuthnAuthenticator {
7075
@Convert(converter = AttestationStatementConverter.class)
7176
private AttestationStatement attestationStatement;
7277

78+
@Lob
79+
@Convert(converter = CollectedClientDataConverter.class)
80+
private CollectedClientData clientData;
81+
7382
@Lob
7483
@Convert(converter = ClientExtensionsConverter.class)
7584
private AuthenticationExtensionsClientOutputs<RegistrationExtensionClientOutput> clientExtensions;
@@ -162,4 +171,43 @@ public AuthenticationExtensionsAuthenticatorOutputs<RegistrationExtensionAuthent
162171
public void setAuthenticatorExtensions(AuthenticationExtensionsAuthenticatorOutputs<RegistrationExtensionAuthenticatorOutput> authenticatorExtensions) {
163172
this.authenticatorExtensions = authenticatorExtensions;
164173
}
174+
175+
@Override
176+
public CollectedClientData getClientData() {
177+
return this.clientData;
178+
}
179+
180+
public void setClientData(CollectedClientData clientData) {
181+
this.clientData = clientData;
182+
}
183+
184+
@Override
185+
public Boolean isUvInitialized() {
186+
return this.uvInitialized;
187+
}
188+
189+
@Override
190+
public void setUvInitialized(boolean value) {
191+
this.uvInitialized = value;
192+
}
193+
194+
@Override
195+
public Boolean isBackupEligible() {
196+
return this.backupEligible;
197+
}
198+
199+
@Override
200+
public void setBackupEligible(boolean value) {
201+
this.backupEligible = value;
202+
}
203+
204+
@Override
205+
public Boolean isBackedUp() {
206+
return this.backedUp;
207+
}
208+
209+
@Override
210+
public void setBackedUp(boolean value) {
211+
this.backedUp = value;
212+
}
165213
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.webauthn4j.springframework.security.webauthn.sample.infrastructure.util.jpa.converter;
2+
3+
import com.webauthn4j.converter.util.ObjectConverter;
4+
import com.webauthn4j.data.client.CollectedClientData;
5+
import jakarta.persistence.AttributeConverter;
6+
7+
public class CollectedClientDataConverter implements AttributeConverter<CollectedClientData, String> {
8+
9+
private final com.webauthn4j.converter.CollectedClientDataConverter converter;
10+
11+
public CollectedClientDataConverter(ObjectConverter objectConverter) {
12+
this.converter = new com.webauthn4j.converter.CollectedClientDataConverter(objectConverter);
13+
}
14+
15+
@Override
16+
public String convertToDatabaseColumn(CollectedClientData attribute) {
17+
if (attribute == null) return null;
18+
return converter.convertToBase64UrlString(attribute);
19+
}
20+
21+
@Override
22+
public CollectedClientData convertToEntityAttribute(String dbData) {
23+
if (dbData == null) return null;
24+
return converter.convert(dbData);
25+
}
26+
}

samples/spa/src/main/resources/db/migration/h2/V0_0_0__create_tables.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ CREATE TABLE m_authenticator(
3030
name VARCHAR(32) NOT NULL,
3131
user_id INTEGER NOT NULL REFERENCES m_user(id),
3232
counter BIGINT NOT NULL,
33+
uv_initialized BOOLEAN NOT NULL,
34+
backup_eligible BOOLEAN NOT NULL,
35+
backed_up BOOLEAN NOT NULL,
3336
aaguid VARBINARY(16) NOT NULL,
3437
credential_id VARBINARY(1024) NOT NULL,
3538
cose_key VARBINARY(1024) NOT NULL,
3639
attestation_statement CLOB NOT NULL,
40+
client_data CLOB NOT NULL,
3741
client_extensions CLOB NOT NULL,
3842
authenticator_extensions CLOB NOT NULL,
3943
primary key(id)

webauthn4j-spring-security-core/src/main/java/com/webauthn4j/springframework/security/anchor/CertFileResourcesTrustAnchorsProvider.java renamed to webauthn4j-spring-security-core/src/main/java/com/webauthn4j/springframework/security/anchor/CertFileResourcesTrustAnchorRepository.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.webauthn4j.springframework.security.anchor;
1818

19+
import com.webauthn4j.anchor.TrustAnchorRepository;
1920
import com.webauthn4j.data.attestation.authenticator.AAGUID;
2021
import com.webauthn4j.util.AssertUtil;
2122
import com.webauthn4j.util.CertificateUtil;
@@ -26,19 +27,14 @@
2627
import java.io.UncheckedIOException;
2728
import java.security.cert.TrustAnchor;
2829
import java.security.cert.X509Certificate;
29-
import java.util.Collections;
3030
import java.util.List;
31-
import java.util.Map;
3231
import java.util.Set;
3332
import java.util.stream.Collectors;
3433

3534
/**
36-
* An implementation of {@link com.webauthn4j.anchor.TrustAnchorsProvider} that loads {@link TrustAnchor}(s) from X.509 certificate file in Spring {@link Resource}
37-
* @deprecated
35+
* An implementation of {@link com.webauthn4j.anchor.TrustAnchorRepository} that loads {@link TrustAnchor}(s) from X.509 certificate file in Spring {@link Resource}
3836
*/
39-
@Deprecated
40-
@SuppressWarnings("deprecation")
41-
public class CertFileResourcesTrustAnchorsProvider extends com.webauthn4j.anchor.CachingTrustAnchorsProviderBase implements InitializingBean {
37+
public class CertFileResourcesTrustAnchorRepository implements TrustAnchorRepository, InitializingBean {
4238

4339
// ~ Instance fields
4440
// ================================================================================================
@@ -48,10 +44,10 @@ public class CertFileResourcesTrustAnchorsProvider extends com.webauthn4j.anchor
4844
// ~ Constructor
4945
// ========================================================================================================
5046

51-
public CertFileResourcesTrustAnchorsProvider() {
47+
public CertFileResourcesTrustAnchorRepository() {
5248
}
5349

54-
public CertFileResourcesTrustAnchorsProvider(List<Resource> certificates) {
50+
public CertFileResourcesTrustAnchorRepository(List<Resource> certificates) {
5551
this.certificates = certificates;
5652
}
5753

@@ -67,19 +63,21 @@ private void checkConfig() {
6763
AssertUtil.notNull(certificates, "certificates must not be null");
6864
}
6965

70-
/**
71-
* Retrieves {@link TrustAnchor}s from {@link Resource}s.
72-
*
73-
* @return null key {@link TrustAnchor} {@link Set} value {@link Map}
74-
*/
7566
@Override
76-
protected Map<AAGUID, Set<TrustAnchor>> loadTrustAnchors() {
67+
public Set<TrustAnchor> find(AAGUID aaguid) {
7768
checkConfig();
78-
Set<TrustAnchor> trustAnchors = certificates.stream().map(this::loadTrustAnchor).collect(Collectors.toSet());
79-
return Collections.singletonMap(AAGUID.NULL, trustAnchors);
69+
return certificates.stream().map(this::loadTrustAnchor).collect(Collectors.toSet());
8070
}
8171

72+
@Override
73+
public Set<TrustAnchor> find(byte[] bytes) {
74+
checkConfig();
75+
return certificates.stream().map(this::loadTrustAnchor).collect(Collectors.toSet());
76+
}
77+
78+
8279
public List<Resource> getCertificates() {
80+
checkConfig();
8381
return certificates;
8482
}
8583

@@ -95,4 +93,5 @@ TrustAnchor loadTrustAnchor(Resource certificate) {
9593
throw new UncheckedIOException(e);
9694
}
9795
}
96+
9897
}

webauthn4j-spring-security-core/src/main/java/com/webauthn4j/springframework/security/anchor/KeyStoreResourceTrustAnchorProvider.java

Lines changed: 0 additions & 137 deletions
This file was deleted.

webauthn4j-spring-security-core/src/main/java/com/webauthn4j/springframework/security/authenticator/WebAuthnAuthenticator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
package com.webauthn4j.springframework.security.authenticator;
1818

19-
import com.webauthn4j.authenticator.Authenticator;
19+
import com.webauthn4j.credential.CredentialRecord;
2020

2121
/**
2222
* Models core authenticator information retrieved by a {@link WebAuthnAuthenticatorService}
2323
*
2424
* @see WebAuthnAuthenticatorService
2525
*/
26-
public interface WebAuthnAuthenticator extends Authenticator {
26+
public interface WebAuthnAuthenticator extends CredentialRecord {
2727

2828
/**
2929
* Return a principal that represents user

0 commit comments

Comments
 (0)