|
16 | 16 |
|
17 | 17 | package org.springframework.security.web.webauthn.management;
|
18 | 18 |
|
| 19 | +import java.io.ByteArrayInputStream; |
| 20 | +import java.io.ByteArrayOutputStream; |
| 21 | +import java.io.ObjectInputStream; |
| 22 | +import java.io.ObjectOutputStream; |
19 | 23 | import java.nio.charset.StandardCharsets;
|
20 | 24 | import java.time.Duration;
|
21 | 25 | import java.util.Arrays;
|
|
60 | 64 | import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialCreationOptions;
|
61 | 65 | import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialUserEntity;
|
62 | 66 | import org.springframework.security.web.webauthn.api.UserVerificationRequirement;
|
| 67 | +import org.springframework.util.SerializationUtils; |
63 | 68 |
|
64 | 69 | import static org.assertj.core.api.Assertions.assertThat;
|
65 | 70 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
@@ -494,6 +499,30 @@ void createCredentialRequestOptionsThenUserVerificationSameAsCreation() {
|
494 | 499 | .isEqualTo(creationOptions.getAuthenticatorSelection().getUserVerification());
|
495 | 500 | }
|
496 | 501 |
|
| 502 | + @Test |
| 503 | + void convertParamToWebauthn4jPublicKeyComparison() throws Exception { |
| 504 | + |
| 505 | + PublicKeyCredentialCreationOptions options = TestPublicKeyCredentialCreationOptions |
| 506 | + .createPublicKeyCredentialCreationOptions() |
| 507 | + .build(); |
| 508 | + |
| 509 | + // Simulate storage into external session storage: serialize/deserialize of the creation options |
| 510 | + ByteArrayOutputStream bo = new ByteArrayOutputStream(); |
| 511 | + ObjectOutputStream oos = new ObjectOutputStream(bo); |
| 512 | + oos.writeObject(options); |
| 513 | + |
| 514 | + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bo.toByteArray())); |
| 515 | + PublicKeyCredentialCreationOptions copiedOptions = (PublicKeyCredentialCreationOptions)ois.readObject() ; |
| 516 | + |
| 517 | + // Check that the deep copied options are still valid |
| 518 | + PublicKeyCredential publicKey = TestPublicKeyCredential.createPublicKeyCredential().build(); |
| 519 | + ImmutableRelyingPartyRegistrationRequest registrationRequest = new ImmutableRelyingPartyRegistrationRequest( |
| 520 | + copiedOptions, new RelyingPartyPublicKey(publicKey, this.label)); |
| 521 | + |
| 522 | + var test = this.rpOperations.registerCredential(registrationRequest); |
| 523 | + |
| 524 | + } |
| 525 | + |
497 | 526 | private static AuthenticatorAttestationResponse setFlag(byte... flags) throws Exception {
|
498 | 527 | AuthenticatorAttestationResponseBuilder authAttResponseBldr = TestAuthenticatorAttestationResponse
|
499 | 528 | .createAuthenticatorAttestationResponse();
|
|
0 commit comments