Skip to content

Commit e42865b

Browse files
committed
Merge branch '6.4.x'
2 parents f9e0459 + 9468126 commit e42865b

20 files changed

+155
-18
lines changed

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

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.apereo.cas.client.validation.AssertionImpl;
5151
import org.instancio.Instancio;
5252
import org.instancio.InstancioApi;
53+
import org.instancio.InstancioOfClassApi;
5354
import org.instancio.Select;
5455
import org.instancio.generator.Generator;
5556
import org.junit.jupiter.api.Disabled;
@@ -59,6 +60,7 @@
5960

6061
import org.springframework.beans.factory.config.BeanDefinition;
6162
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
63+
import org.springframework.core.ResolvableType;
6264
import org.springframework.core.type.filter.AssignableTypeFilter;
6365
import org.springframework.mock.web.MockHttpServletRequest;
6466
import org.springframework.mock.web.MockHttpSession;
@@ -217,21 +219,31 @@
217219
import org.springframework.security.web.server.firewall.ServerExchangeRejectedException;
218220
import org.springframework.security.web.session.HttpSessionCreatedEvent;
219221
import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInputs;
222+
import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientOutputs;
223+
import org.springframework.security.web.webauthn.api.AuthenticatorAssertionResponse;
224+
import org.springframework.security.web.webauthn.api.AuthenticatorAttachment;
220225
import org.springframework.security.web.webauthn.api.AuthenticatorTransport;
221226
import org.springframework.security.web.webauthn.api.Bytes;
222227
import org.springframework.security.web.webauthn.api.CredProtectAuthenticationExtensionsClientInput;
228+
import org.springframework.security.web.webauthn.api.CredentialPropertiesOutput;
223229
import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInput;
224230
import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInputs;
231+
import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientOutputs;
225232
import org.springframework.security.web.webauthn.api.ImmutablePublicKeyCredentialUserEntity;
233+
import org.springframework.security.web.webauthn.api.PublicKeyCredential;
226234
import org.springframework.security.web.webauthn.api.PublicKeyCredentialDescriptor;
227235
import org.springframework.security.web.webauthn.api.PublicKeyCredentialRequestOptions;
228236
import org.springframework.security.web.webauthn.api.PublicKeyCredentialType;
229237
import org.springframework.security.web.webauthn.api.PublicKeyCredentialUserEntity;
238+
import org.springframework.security.web.webauthn.api.TestAuthenticationAssertionResponses;
230239
import org.springframework.security.web.webauthn.api.TestBytes;
240+
import org.springframework.security.web.webauthn.api.TestPublicKeyCredential;
231241
import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialRequestOptions;
232242
import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialUserEntity;
233243
import org.springframework.security.web.webauthn.api.UserVerificationRequirement;
234244
import org.springframework.security.web.webauthn.authentication.WebAuthnAuthentication;
245+
import org.springframework.security.web.webauthn.authentication.WebAuthnAuthenticationRequestToken;
246+
import org.springframework.security.web.webauthn.management.RelyingPartyAuthenticationRequest;
235247
import org.springframework.util.ReflectionUtils;
236248

237249
import static org.assertj.core.api.Assertions.assertThat;
@@ -621,6 +633,27 @@ class SpringSecurityCoreVersionSerializableTests {
621633
.allowCredentials(List.of(descriptor))
622634
.build()
623635
);
636+
637+
CredentialPropertiesOutput credentialOutput = new CredentialPropertiesOutput(false);
638+
AuthenticationExtensionsClientOutputs outputs = new ImmutableAuthenticationExtensionsClientOutputs(credentialOutput);
639+
AuthenticatorAssertionResponse response = TestAuthenticationAssertionResponses.createAuthenticatorAssertionResponse()
640+
.build();
641+
PublicKeyCredential<AuthenticatorAssertionResponse> credential = TestPublicKeyCredential.createPublicKeyCredential(
642+
response, outputs)
643+
.build();
644+
RelyingPartyAuthenticationRequest authRequest = new RelyingPartyAuthenticationRequest(
645+
TestPublicKeyCredentialRequestOptions.create().build(),
646+
credential
647+
);
648+
WebAuthnAuthenticationRequestToken requestToken = new WebAuthnAuthenticationRequestToken(authRequest);
649+
requestToken.setDetails(details);
650+
generatorByClassName.put(CredentialPropertiesOutput.class, (o) -> credentialOutput);
651+
generatorByClassName.put(ImmutableAuthenticationExtensionsClientOutputs.class, (o) -> outputs);
652+
generatorByClassName.put(AuthenticatorAssertionResponse.class, (r) -> response);
653+
generatorByClassName.put(RelyingPartyAuthenticationRequest.class, (r) -> authRequest);
654+
generatorByClassName.put(PublicKeyCredential.class, (r) -> credential);
655+
generatorByClassName.put(WebAuthnAuthenticationRequestToken.class, (r) -> requestToken);
656+
generatorByClassName.put(AuthenticatorAttachment.class, (r) -> AuthenticatorAttachment.PLATFORM);
624657
// @formatter:on
625658
generatorByClassName.put(ImmutablePublicKeyCredentialUserEntity.class,
626659
(r) -> TestPublicKeyCredentialUserEntity.userEntity().id(TestBytes.get()).build());
@@ -784,7 +817,11 @@ static Stream<Class<?>> getClassesToSerialize() throws Exception {
784817
}
785818

786819
private static InstancioApi<?> instancioWithDefaults(Class<?> clazz) {
787-
InstancioApi<?> instancio = Instancio.of(clazz);
820+
InstancioOfClassApi<?> instancio = Instancio.of(clazz);
821+
ResolvableType[] generics = ResolvableType.forClass(clazz).getGenerics();
822+
for (ResolvableType type : generics) {
823+
instancio.withTypeParameters(type.resolve());
824+
}
788825
if (generatorByClassName.containsKey(clazz)) {
789826
instancio.supply(Select.all(clazz), generatorByClassName.get(clazz));
790827
}

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

Lines changed: 4 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,8 @@
1616

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

19+
import java.io.Serializable;
20+
1921
/**
2022
* A <a href="https://www.w3.org/TR/webauthn-3/#client-extension-output">client extension
2123
* output</a> entry in {@link AuthenticationExtensionsClientOutputs}.
@@ -24,7 +26,7 @@
2426
* @see AuthenticationExtensionsClientOutputs#getOutputs()
2527
* @see CredentialPropertiesOutput
2628
*/
27-
public interface AuthenticationExtensionsClientOutput<T> {
29+
public interface AuthenticationExtensionsClientOutput<T> extends Serializable {
2830

2931
/**
3032
* Gets the <a href="https://www.w3.org/TR/webauthn-3/#extension-identifier">extension

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

Lines changed: 3 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,7 @@
1616

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

19+
import java.io.Serializable;
1920
import java.util.List;
2021

2122
/**
@@ -31,7 +32,7 @@
3132
* @since 6.4
3233
* @see PublicKeyCredential#getClientExtensionResults()
3334
*/
34-
public interface AuthenticationExtensionsClientOutputs {
35+
public interface AuthenticationExtensionsClientOutputs extends Serializable {
3536

3637
/**
3738
* Gets all of the {@link AuthenticationExtensionsClientOutput}.

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

Lines changed: 6 additions & 1 deletion
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,8 @@
1616

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

19+
import java.io.Serial;
20+
1921
/**
2022
* The <a href=
2123
* "https://www.w3.org/TR/webauthn-3/#authenticatorassertionresponse">AuthenticatorAssertionResponse</a>
@@ -38,6 +40,9 @@
3840
*/
3941
public final class AuthenticatorAssertionResponse extends AuthenticatorResponse {
4042

43+
@Serial
44+
private static final long serialVersionUID = 324976481675434298L;
45+
4146
private final Bytes authenticatorData;
4247

4348
private final Bytes signature;

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@
1616

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

19+
import java.io.ObjectStreamException;
20+
import java.io.Serial;
21+
import java.io.Serializable;
22+
1923
/**
2024
* The <a href=
2125
* "https://www.w3.org/TR/webauthn-3/#enumdef-authenticatorattachment">AuthenticatorAttachment</a>.
2226
*
2327
* @author Rob Winch
2428
* @since 6.4
2529
*/
26-
public final class AuthenticatorAttachment {
30+
public final class AuthenticatorAttachment implements Serializable {
31+
32+
@Serial
33+
private static final long serialVersionUID = 8446133215195918090L;
2734

2835
/**
2936
* Indicates <a href=
@@ -85,4 +92,9 @@ public static AuthenticatorAttachment[] values() {
8592
return new AuthenticatorAttachment[] { CROSS_PLATFORM, PLATFORM };
8693
}
8794

95+
@Serial
96+
private Object readResolve() throws ObjectStreamException {
97+
return valueOf(this.value);
98+
}
99+
88100
}

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

Lines changed: 4 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,8 @@
1616

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

19+
import java.io.Serializable;
20+
1921
/**
2022
* The <a href=
2123
* "https://www.w3.org/TR/webauthn-3/#iface-authenticatorresponse">AuthenticatorResponse</a>
@@ -26,7 +28,7 @@
2628
* @author Rob Winch
2729
* @since 6.4
2830
*/
29-
public abstract class AuthenticatorResponse {
31+
public abstract class AuthenticatorResponse implements Serializable {
3032

3133
private final Bytes clientDataJSON;
3234

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

Lines changed: 11 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-credentialpropertiesoutput">CredentialPropertiesOutput</a>
@@ -27,6 +30,9 @@
2730
public class CredentialPropertiesOutput
2831
implements AuthenticationExtensionsClientOutput<CredentialPropertiesOutput.ExtensionOutput> {
2932

33+
@Serial
34+
private static final long serialVersionUID = -3201699313968303331L;
35+
3036
/**
3137
* The extension id.
3238
*/
@@ -59,7 +65,10 @@ public ExtensionOutput getOutput() {
5965
* @since 6.4
6066
* @see #getOutput()
6167
*/
62-
public static final class ExtensionOutput {
68+
public static final class ExtensionOutput implements Serializable {
69+
70+
@Serial
71+
private static final long serialVersionUID = 4557406414847424019L;
6372

6473
private final boolean rk;
6574

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

Lines changed: 5 additions & 1 deletion
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,7 @@
1616

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

19+
import java.io.Serial;
1920
import java.util.Arrays;
2021
import java.util.List;
2122

@@ -26,6 +27,9 @@
2627
*/
2728
public class ImmutableAuthenticationExtensionsClientOutputs implements AuthenticationExtensionsClientOutputs {
2829

30+
@Serial
31+
private static final long serialVersionUID = -4656390173585180393L;
32+
2933
private final List<AuthenticationExtensionsClientOutput<?>> outputs;
3034

3135
public ImmutableAuthenticationExtensionsClientOutputs(List<AuthenticationExtensionsClientOutput<?>> outputs) {

web/src/main/java/org/springframework/security/web/webauthn/api/PublicKeyCredential.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/#iface-pkcredential">PublicKeyCredential</a>
2124
* contains the attributes that are returned to the caller when a new credential is
@@ -24,7 +27,10 @@
2427
* @author Rob Winch
2528
* @since 6.4
2629
*/
27-
public final class PublicKeyCredential<R extends AuthenticatorResponse> {
30+
public final class PublicKeyCredential<R extends AuthenticatorResponse> implements Serializable {
31+
32+
@Serial
33+
private static final long serialVersionUID = -1864035469276082606L;
2834

2935
private final String id;
3036

web/src/main/java/org/springframework/security/web/webauthn/authentication/WebAuthnAuthenticationRequestToken.java

Lines changed: 6 additions & 1 deletion
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,8 @@
1616

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

19+
import java.io.Serial;
20+
1921
import org.springframework.security.authentication.AbstractAuthenticationToken;
2022
import org.springframework.security.core.authority.AuthorityUtils;
2123
import org.springframework.security.web.webauthn.management.RelyingPartyAuthenticationRequest;
@@ -30,6 +32,9 @@
3032
*/
3133
public class WebAuthnAuthenticationRequestToken extends AbstractAuthenticationToken {
3234

35+
@Serial
36+
private static final long serialVersionUID = -1682693433877522403L;
37+
3338
private final RelyingPartyAuthenticationRequest webAuthnRequest;
3439

3540
/**

web/src/main/java/org/springframework/security/web/webauthn/management/RelyingPartyAuthenticationRequest.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.management;
1818

19+
import java.io.Serial;
20+
import java.io.Serializable;
21+
1922
import org.springframework.security.web.webauthn.api.AuthenticatorAssertionResponse;
2023
import org.springframework.security.web.webauthn.api.PublicKeyCredential;
2124
import org.springframework.security.web.webauthn.api.PublicKeyCredentialRequestOptions;
@@ -29,7 +32,10 @@
2932
* @since 6.4
3033
* @see WebAuthnRelyingPartyOperations#authenticate(RelyingPartyAuthenticationRequest)
3134
*/
32-
public class RelyingPartyAuthenticationRequest {
35+
public class RelyingPartyAuthenticationRequest implements Serializable {
36+
37+
@Serial
38+
private static final long serialVersionUID = -928083091875202086L;
3339

3440
private final PublicKeyCredentialRequestOptions requestOptions;
3541

0 commit comments

Comments
 (0)