212
212
import org .springframework .security .web .server .firewall .ServerExchangeRejectedException ;
213
213
import org .springframework .security .web .session .HttpSessionCreatedEvent ;
214
214
import org .springframework .security .web .webauthn .api .AuthenticationExtensionsClientInputs ;
215
+ import org .springframework .security .web .webauthn .api .AuthenticationExtensionsClientOutputs ;
216
+ import org .springframework .security .web .webauthn .api .AuthenticatorAssertionResponse ;
215
217
import org .springframework .security .web .webauthn .api .AuthenticatorTransport ;
216
218
import org .springframework .security .web .webauthn .api .Bytes ;
217
219
import org .springframework .security .web .webauthn .api .CredProtectAuthenticationExtensionsClientInput ;
220
+ import org .springframework .security .web .webauthn .api .CredentialPropertiesOutput ;
218
221
import org .springframework .security .web .webauthn .api .ImmutableAuthenticationExtensionsClientInput ;
219
222
import org .springframework .security .web .webauthn .api .ImmutableAuthenticationExtensionsClientInputs ;
223
+ import org .springframework .security .web .webauthn .api .ImmutableAuthenticationExtensionsClientOutputs ;
220
224
import org .springframework .security .web .webauthn .api .ImmutablePublicKeyCredentialUserEntity ;
225
+ import org .springframework .security .web .webauthn .api .PublicKeyCredential ;
221
226
import org .springframework .security .web .webauthn .api .PublicKeyCredentialDescriptor ;
222
227
import org .springframework .security .web .webauthn .api .PublicKeyCredentialRequestOptions ;
223
228
import org .springframework .security .web .webauthn .api .PublicKeyCredentialType ;
224
229
import org .springframework .security .web .webauthn .api .PublicKeyCredentialUserEntity ;
230
+ import org .springframework .security .web .webauthn .api .TestAuthenticationAssertionResponses ;
225
231
import org .springframework .security .web .webauthn .api .TestBytes ;
232
+ import org .springframework .security .web .webauthn .api .TestPublicKeyCredential ;
226
233
import org .springframework .security .web .webauthn .api .TestPublicKeyCredentialRequestOptions ;
227
234
import org .springframework .security .web .webauthn .api .TestPublicKeyCredentialUserEntity ;
228
235
import org .springframework .security .web .webauthn .api .UserVerificationRequirement ;
229
236
import org .springframework .security .web .webauthn .authentication .WebAuthnAuthentication ;
237
+ import org .springframework .security .web .webauthn .authentication .WebAuthnAuthenticationRequestToken ;
238
+ import org .springframework .security .web .webauthn .management .RelyingPartyAuthenticationRequest ;
230
239
import org .springframework .util .ReflectionUtils ;
231
240
232
241
import static org .assertj .core .api .Assertions .assertThat ;
@@ -629,6 +638,26 @@ class SpringSecurityCoreVersionSerializableTests {
629
638
.allowCredentials (List .of (descriptor ))
630
639
.build ()
631
640
);
641
+
642
+ CredentialPropertiesOutput credentialOutput = new CredentialPropertiesOutput (false );
643
+ AuthenticationExtensionsClientOutputs outputs = new ImmutableAuthenticationExtensionsClientOutputs (credentialOutput );
644
+ AuthenticatorAssertionResponse response = TestAuthenticationAssertionResponses .createAuthenticatorAssertionResponse ()
645
+ .build ();
646
+ PublicKeyCredential <AuthenticatorAssertionResponse > credential = TestPublicKeyCredential .createPublicKeyCredential (
647
+ response , outputs )
648
+ .build ();
649
+ RelyingPartyAuthenticationRequest authRequest = new RelyingPartyAuthenticationRequest (
650
+ TestPublicKeyCredentialRequestOptions .create ().build (),
651
+ credential
652
+ );
653
+ WebAuthnAuthenticationRequestToken requestToken = new WebAuthnAuthenticationRequestToken (authRequest );
654
+ requestToken .setDetails (details );
655
+ generatorByClassName .put (CredentialPropertiesOutput .class , (o ) -> credentialOutput );
656
+ generatorByClassName .put (ImmutableAuthenticationExtensionsClientOutputs .class , (o ) -> outputs );
657
+ generatorByClassName .put (AuthenticatorAssertionResponse .class , (r ) -> response );
658
+ generatorByClassName .put (RelyingPartyAuthenticationRequest .class , (r ) -> authRequest );
659
+ generatorByClassName .put (PublicKeyCredential .class , (r ) -> credential );
660
+ generatorByClassName .put (WebAuthnAuthenticationRequestToken .class , (r ) -> requestToken );
632
661
// @formatter:on
633
662
}
634
663
@@ -643,8 +672,15 @@ void serializeCurrentVersionClasses(Class<?> clazz) throws Exception {
643
672
return ;
644
673
}
645
674
Files .createFile (filePath );
646
- Object instance = instancioWithDefaults (clazz ).create ();
647
- assertThat (instance ).isInstanceOf (clazz );
675
+ Object instance ;
676
+ if (clazz .equals (PublicKeyCredential .class )) {
677
+ instance = instancioWithParameter ((Class <PublicKeyCredential >) clazz ).create ();
678
+ }
679
+ else {
680
+ instance = instancioWithDefaults (clazz ).create ();
681
+ }
682
+ // Object instance = instancioWithDefaults(clazz).create();
683
+ // assertThat(instance).isInstanceOf(clazz);
648
684
try (FileOutputStream fileOutputStream = new FileOutputStream (file );
649
685
ObjectOutputStream objectOutputStream = new ObjectOutputStream (fileOutputStream )) {
650
686
objectOutputStream .writeObject (instance );
@@ -656,6 +692,14 @@ void serializeCurrentVersionClasses(Class<?> clazz) throws Exception {
656
692
}
657
693
}
658
694
695
+ private static InstancioApi <?> instancioWithParameter (Class <PublicKeyCredential > clazz ) {
696
+ InstancioApi <?> instancio = Instancio .of (clazz ).withTypeParameters (AuthenticatorAssertionResponse .class );
697
+ if (generatorByClassName .containsKey (clazz )) {
698
+ instancio .supply (Select .all (clazz ), generatorByClassName .get (clazz ));
699
+ }
700
+ return instancio ;
701
+ }
702
+
659
703
@ ParameterizedTest
660
704
@ MethodSource ("getFilesToDeserialize" )
661
705
void shouldBeAbleToDeserializeClassFromPreviousVersion (Path filePath ) {
0 commit comments