Skip to content

Commit 7838079

Browse files
Implement Serializable for PublicKeyCredentialUserEntity
Closes gh-16273 Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
1 parent d3332e1 commit 7838079

6 files changed

+20
-5
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@
191191
import org.springframework.security.web.firewall.RequestRejectedException;
192192
import org.springframework.security.web.server.firewall.ServerExchangeRejectedException;
193193
import org.springframework.security.web.session.HttpSessionCreatedEvent;
194+
import org.springframework.security.web.webauthn.api.Bytes;
195+
import org.springframework.security.web.webauthn.api.ImmutablePublicKeyCredentialUserEntity;
196+
import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialUserEntity;
194197

195198
import static org.assertj.core.api.Assertions.assertThat;
196199
import static org.assertj.core.api.Assertions.fail;
@@ -508,6 +511,11 @@ class SpringSecurityCoreVersionSerializableTests {
508511
(r) -> new AuthenticationSwitchUserEvent(authentication, user));
509512
generatorByClassName.put(HttpSessionCreatedEvent.class,
510513
(r) -> new HttpSessionCreatedEvent(new MockHttpSession()));
514+
515+
// webauthn
516+
generatorByClassName.put(Bytes.class, (r) -> Bytes.random());
517+
generatorByClassName.put(ImmutablePublicKeyCredentialUserEntity.class,
518+
(r) -> TestPublicKeyCredentialUserEntity.userEntity().build());
511519
}
512520

513521
@ParameterizedTest

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

+5-2
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.security.SecureRandom;
2021
import java.util.Arrays;
2122
import java.util.Base64;
@@ -28,7 +29,9 @@
2829
* @author Rob Winch
2930
* @since 6.4
3031
*/
31-
public final class Bytes {
32+
public final class Bytes implements Serializable {
33+
34+
private static final long serialVersionUID = -3278138671365709777L;
3235

3336
private static final SecureRandom RANDOM = new SecureRandom();
3437

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

+3-1
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.
@@ -28,6 +28,8 @@
2828
*/
2929
public final class ImmutablePublicKeyCredentialUserEntity implements PublicKeyCredentialUserEntity {
3030

31+
private static final long serialVersionUID = -3438693960347279759L;
32+
3133
/**
3234
* When inherited by PublicKeyCredentialUserEntity, it is a human-palatable identifier
3335
* for a user account. It is intended only for display, i.e., aiding the user in

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

+4-2
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 href=
2123
* "https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialuserentity">PublicKeyCredentialUserEntity</a>
@@ -27,7 +29,7 @@
2729
* @since 6.4
2830
* @see org.springframework.security.web.webauthn.management.WebAuthnRelyingPartyOperations#authenticate(org.springframework.security.web.webauthn.management.RelyingPartyAuthenticationRequest)
2931
*/
30-
public interface PublicKeyCredentialUserEntity {
32+
public interface PublicKeyCredentialUserEntity extends Serializable {
3133

3234
/**
3335
* The <a href=

0 commit comments

Comments
 (0)