Skip to content

Commit e31564f

Browse files
Implement Serial for PublicKeyCredentialCreationOptions
Signed-off-by: Tran Ngoc Nhan <[email protected]>
1 parent f96b9bb commit e31564f

15 files changed

+80
-14
lines changed

config/src/test/java/org/springframework/security/SerializationSamples.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,32 +207,41 @@
207207
import org.springframework.security.web.server.firewall.ServerExchangeRejectedException;
208208
import org.springframework.security.web.session.HttpSessionCreatedEvent;
209209
import org.springframework.security.web.session.HttpSessionIdChangedEvent;
210+
import org.springframework.security.web.webauthn.api.AttestationConveyancePreference;
210211
import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInputs;
211212
import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientOutputs;
212213
import org.springframework.security.web.webauthn.api.AuthenticatorAssertionResponse;
213214
import org.springframework.security.web.webauthn.api.AuthenticatorAttachment;
215+
import org.springframework.security.web.webauthn.api.AuthenticatorSelectionCriteria;
214216
import org.springframework.security.web.webauthn.api.AuthenticatorTransport;
215217
import org.springframework.security.web.webauthn.api.Bytes;
218+
import org.springframework.security.web.webauthn.api.COSEAlgorithmIdentifier;
216219
import org.springframework.security.web.webauthn.api.CredProtectAuthenticationExtensionsClientInput;
217220
import org.springframework.security.web.webauthn.api.CredentialPropertiesOutput;
218221
import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInput;
219222
import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInputs;
220223
import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientOutputs;
221224
import org.springframework.security.web.webauthn.api.ImmutablePublicKeyCredentialUserEntity;
222225
import org.springframework.security.web.webauthn.api.PublicKeyCredential;
226+
import org.springframework.security.web.webauthn.api.PublicKeyCredentialCreationOptions;
223227
import org.springframework.security.web.webauthn.api.PublicKeyCredentialDescriptor;
228+
import org.springframework.security.web.webauthn.api.PublicKeyCredentialParameters;
224229
import org.springframework.security.web.webauthn.api.PublicKeyCredentialRequestOptions;
230+
import org.springframework.security.web.webauthn.api.PublicKeyCredentialRpEntity;
225231
import org.springframework.security.web.webauthn.api.PublicKeyCredentialType;
226232
import org.springframework.security.web.webauthn.api.PublicKeyCredentialUserEntity;
233+
import org.springframework.security.web.webauthn.api.ResidentKeyRequirement;
227234
import org.springframework.security.web.webauthn.api.TestAuthenticationAssertionResponses;
228235
import org.springframework.security.web.webauthn.api.TestBytes;
236+
import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialCreationOptions;
229237
import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialRequestOptions;
230238
import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialUserEntities;
231239
import org.springframework.security.web.webauthn.api.TestPublicKeyCredentials;
232240
import org.springframework.security.web.webauthn.api.UserVerificationRequirement;
233241
import org.springframework.security.web.webauthn.authentication.WebAuthnAuthentication;
234242
import org.springframework.security.web.webauthn.authentication.WebAuthnAuthenticationRequestToken;
235243
import org.springframework.security.web.webauthn.management.RelyingPartyAuthenticationRequest;
244+
import org.springframework.security.web.webauthn.management.TestPublicKeyCredentialRpEntities;
236245
import org.springframework.util.ReflectionUtils;
237246

238247
final class SerializationSamples {
@@ -668,6 +677,22 @@ final class SerializationSamples {
668677
});
669678
// @formatter:on
670679

680+
generatorByClassName.put(AttestationConveyancePreference.class,
681+
(r) -> AttestationConveyancePreference.INDIRECT);
682+
generatorByClassName.put(AuthenticatorSelectionCriteria.class,
683+
(r) -> AuthenticatorSelectionCriteria.builder()
684+
.userVerification(UserVerificationRequirement.REQUIRED)
685+
.build());
686+
generatorByClassName.put(COSEAlgorithmIdentifier.class, (r) -> COSEAlgorithmIdentifier.ES256);
687+
generatorByClassName.put(PublicKeyCredentialParameters.class, (r) -> PublicKeyCredentialParameters.ES256);
688+
generatorByClassName.put(PublicKeyCredentialRpEntity.class,
689+
(r) -> TestPublicKeyCredentialRpEntities.createRpEntity().build());
690+
generatorByClassName.put(ResidentKeyRequirement.class, (r) -> ResidentKeyRequirement.REQUIRED);
691+
generatorByClassName.put(PublicKeyCredentialCreationOptions.class,
692+
(r) -> TestPublicKeyCredentialCreationOptions.createPublicKeyCredentialCreationOptions()
693+
.rp(TestPublicKeyCredentialRpEntities.createRpEntity().build())
694+
.build());
695+
671696
generatorByClassName.put(CredentialPropertiesOutput.ExtensionOutput.class,
672697
(r) -> new CredentialPropertiesOutput(true).getOutput());
673698

web/src/main/java/org/springframework/security/web/webauthn/api/AttestationConveyancePreference.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,9 @@
1616

1717
package org.springframework.security.web.webauthn.api;
1818

19+
import java.io.Serial;
20+
import java.io.Serializable;
21+
1922
/**
2023
* <a href="https://www.w3.org/TR/webauthn-3/#webauthn-relying-party">WebAuthn Relying
2124
* Parties</a> may use <a href=
@@ -26,7 +29,10 @@
2629
* @author Rob Winch
2730
* @since 6.4
2831
*/
29-
public final class AttestationConveyancePreference {
32+
public final class AttestationConveyancePreference implements Serializable {
33+
34+
@Serial
35+
private static final long serialVersionUID = -4821525312099695991L;
3036

3137
/**
3238
* The <a href=

web/src/main/java/org/springframework/security/web/webauthn/api/AuthenticatorSelectionCriteria.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,9 @@
1616

1717
package org.springframework.security.web.webauthn.api;
1818

19+
import java.io.Serial;
20+
import java.io.Serializable;
21+
1922
/**
2023
* <a href=
2124
* "https://www.w3.org/TR/webauthn-3/#dictdef-authenticatorselectioncriteria">AuthenticatorAttachment</a>
@@ -31,7 +34,10 @@
3134
* @since 6.4
3235
* @see PublicKeyCredentialCreationOptions#getAuthenticatorSelection()
3336
*/
34-
public final class AuthenticatorSelectionCriteria {
37+
public final class AuthenticatorSelectionCriteria implements Serializable {
38+
39+
@Serial
40+
private static final long serialVersionUID = -4273495550621636950L;
3541

3642
private final AuthenticatorAttachment authenticatorAttachment;
3743

0 commit comments

Comments
 (0)