Browse Source

Polish Webauthn4JRelyingPartyOperations

Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
pull/17033/head
Tran Ngoc Nhan 7 months ago committed by Rob Winch
parent
commit
709f5db0e5
  1. 5
      web/src/main/java/org/springframework/security/web/webauthn/management/Webauthn4JRelyingPartyOperations.java
  2. 2
      web/src/test/java/org/springframework/security/web/webauthn/management/Webauthn4jRelyingPartyOperationsTests.java

5
web/src/main/java/org/springframework/security/web/webauthn/management/Webauthn4JRelyingPartyOperations.java

@ -199,7 +199,7 @@ public class Webauthn4JRelyingPartyOperations implements WebAuthnRelyingPartyOpe
} }
private static List<PublicKeyCredentialDescriptor> credentialDescriptors(List<CredentialRecord> credentialRecords) { private static List<PublicKeyCredentialDescriptor> credentialDescriptors(List<CredentialRecord> credentialRecords) {
List result = new ArrayList(); List<PublicKeyCredentialDescriptor> result = new ArrayList<>();
for (CredentialRecord credentialRecord : credentialRecords) { for (CredentialRecord credentialRecord : credentialRecords) {
Bytes id = Bytes.fromBase64(credentialRecord.getCredentialId().toBase64UrlString()); Bytes id = Bytes.fromBase64(credentialRecord.getCredentialId().toBase64UrlString());
PublicKeyCredentialDescriptor credentialDescriptor = PublicKeyCredentialDescriptor.builder() PublicKeyCredentialDescriptor credentialDescriptor = PublicKeyCredentialDescriptor.builder()
@ -372,9 +372,6 @@ public class Webauthn4JRelyingPartyOperations implements WebAuthnRelyingPartyOpe
Authenticator authenticator = new AuthenticatorImpl(data, attestationObject.getAttestationStatement(), Authenticator authenticator = new AuthenticatorImpl(data, attestationObject.getAttestationStatement(),
credentialRecord.getSignatureCount()); credentialRecord.getSignatureCount());
if (authenticator == null) {
throw new IllegalStateException("No authenticator found");
}
Set<Origin> origins = toOrigins(); Set<Origin> origins = toOrigins();
Challenge challenge = new DefaultChallenge(requestOptions.getChallenge().getBytes()); Challenge challenge = new DefaultChallenge(requestOptions.getChallenge().getBytes());
// FIXME: should populate this // FIXME: should populate this

2
web/src/test/java/org/springframework/security/web/webauthn/management/Webauthn4jRelyingPartyOperationsTests.java

@ -138,7 +138,7 @@ class Webauthn4jRelyingPartyOperationsTests {
@Test @Test
void createPublicKeyCredentialCreationOptionsWhenAnonymousThenIllegalArgumentException() { void createPublicKeyCredentialCreationOptionsWhenAnonymousThenIllegalArgumentException() {
AnonymousAuthenticationToken anonymous = new AnonymousAuthenticationToken("key", "notAuthenticated", AnonymousAuthenticationToken anonymous = new AnonymousAuthenticationToken("key", "notAuthenticated",
Set.of(() -> "ROLE_ANOYMOUS")); Set.of(() -> "ROLE_ANONYMOUS"));
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> this.rpOperations.createPublicKeyCredentialCreationOptions( .isThrownBy(() -> this.rpOperations.createPublicKeyCredentialCreationOptions(
new ImmutablePublicKeyCredentialCreationOptionsRequest(anonymous))); new ImmutablePublicKeyCredentialCreationOptionsRequest(anonymous)));

Loading…
Cancel
Save