File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
main/java/org/springframework/security/web/webauthn/api
test/java/org/springframework/security/web/webauthn/authentication Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1616
1717package org .springframework .security .web .webauthn .api ;
1818
19+ import java .io .Serializable ;
1920import java .security .SecureRandom ;
2021import java .util .Arrays ;
2122import java .util .Base64 ;
2223
24+ import org .springframework .security .core .SpringSecurityCoreVersion ;
2325import org .springframework .util .Assert ;
2426
2527/**
2830 * @author Rob Winch
2931 * @since 6.4
3032 */
31- public final class Bytes {
33+ public final class Bytes implements Serializable {
34+
35+ private static final long serialVersionUID = SpringSecurityCoreVersion .SERIAL_VERSION_UID ;
3236
3337 private static final SecureRandom RANDOM = new SecureRandom ();
3438
Original file line number Diff line number Diff line change 1616
1717package 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>
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=
Original file line number Diff line number Diff line change 2424import org .springframework .security .core .authority .AuthorityUtils ;
2525import org .springframework .security .web .webauthn .api .PublicKeyCredentialUserEntity ;
2626import org .springframework .security .web .webauthn .api .TestPublicKeyCredentialUserEntity ;
27+ import org .springframework .util .SerializationUtils ;
2728
2829import static org .assertj .core .api .Assertions .assertThat ;
2930import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
@@ -55,4 +56,16 @@ void setAuthenticationWhenFalseThenNotAuthenticated() {
5556 assertThat (authentication .isAuthenticated ()).isFalse ();
5657 }
5758
59+ @ Test
60+ void testSerialization () {
61+ PublicKeyCredentialUserEntity userEntity = TestPublicKeyCredentialUserEntity .userEntity ().build ();
62+ List <GrantedAuthority > authorities = AuthorityUtils .createAuthorityList ("ROLE_USER" );
63+ WebAuthnAuthentication authentication = new WebAuthnAuthentication (userEntity , authorities );
64+ byte [] serialize = SerializationUtils .serialize (authentication );
65+ WebAuthnAuthentication deserializeAuthentication = (WebAuthnAuthentication ) SerializationUtils .deserialize (serialize );
66+ assertThat (deserializeAuthentication .getPrincipal ().getName ()).isEqualTo (authentication .getPrincipal ().getName ());
67+ assertThat (deserializeAuthentication .getPrincipal ().getDisplayName ()).isEqualTo (authentication .getPrincipal ().getDisplayName ());
68+ assertThat (deserializeAuthentication .getPrincipal ().getId ()).isEqualTo (authentication .getPrincipal ().getId ());
69+ }
70+
5871}
You can’t perform that action at this time.
0 commit comments