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 16
16
17
17
package org .springframework .security .web .webauthn .api ;
18
18
19
+ import java .io .Serializable ;
19
20
import java .security .SecureRandom ;
20
21
import java .util .Arrays ;
21
22
import java .util .Base64 ;
22
23
24
+ import org .springframework .security .core .SpringSecurityCoreVersion ;
23
25
import org .springframework .util .Assert ;
24
26
25
27
/**
28
30
* @author Rob Winch
29
31
* @since 6.4
30
32
*/
31
- public final class Bytes {
33
+ public final class Bytes implements Serializable {
34
+
35
+ private static final long serialVersionUID = SpringSecurityCoreVersion .SERIAL_VERSION_UID ;
32
36
33
37
private static final SecureRandom RANDOM = new SecureRandom ();
34
38
Original file line number Diff line number Diff line change 16
16
17
17
package org .springframework .security .web .webauthn .api ;
18
18
19
+ import java .io .Serializable ;
20
+
19
21
/**
20
22
* <a href=
21
23
* "https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialuserentity">PublicKeyCredentialUserEntity</a>
27
29
* @since 6.4
28
30
* @see org.springframework.security.web.webauthn.management.WebAuthnRelyingPartyOperations#authenticate(org.springframework.security.web.webauthn.management.RelyingPartyAuthenticationRequest)
29
31
*/
30
- public interface PublicKeyCredentialUserEntity {
32
+ public interface PublicKeyCredentialUserEntity extends Serializable {
31
33
32
34
/**
33
35
* The <a href=
Original file line number Diff line number Diff line change 24
24
import org .springframework .security .core .authority .AuthorityUtils ;
25
25
import org .springframework .security .web .webauthn .api .PublicKeyCredentialUserEntity ;
26
26
import org .springframework .security .web .webauthn .api .TestPublicKeyCredentialUserEntity ;
27
+ import org .springframework .util .SerializationUtils ;
27
28
28
29
import static org .assertj .core .api .Assertions .assertThat ;
29
30
import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
@@ -55,4 +56,16 @@ void setAuthenticationWhenFalseThenNotAuthenticated() {
55
56
assertThat (authentication .isAuthenticated ()).isFalse ();
56
57
}
57
58
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
+
58
71
}
You can’t perform that action at this time.
0 commit comments