use of com.webauthn4j.test.client.RegistrationEmulationOption in project webauthn4j by webauthn4j.
the class TPMAuthenticatorTest method generateAttestationStatement_test.
@Test
void generateAttestationStatement_test() {
byte[] signedData = new byte[32];
RegistrationEmulationOption option = new RegistrationEmulationOption();
AttestationStatementRequest attestationStatementRequest = new AttestationStatementRequest(signedData, ECUtil.createKeyPair(), new byte[0]);
assertThatCode(() -> target.createAttestationStatement(attestationStatementRequest, option)).doesNotThrowAnyException();
}
use of com.webauthn4j.test.client.RegistrationEmulationOption in project webauthn4j by webauthn4j.
the class FIDOU2FAuthenticatorRegistrationValidationTest method validate_with_bad_clientData_type_test.
@Test
void validate_with_bad_clientData_type_test() {
String rpId = "example.com";
Challenge challenge = new DefaultChallenge();
PublicKeyCredentialParameters publicKeyCredentialParameters = new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256);
PublicKeyCredentialCreationOptions credentialCreationOptions = new PublicKeyCredentialCreationOptions(new PublicKeyCredentialRpEntity(rpId, "example.com"), new PublicKeyCredentialUserEntity(new byte[32], "username", "displayName"), challenge, Collections.singletonList(publicKeyCredentialParameters));
CollectedClientData collectedClientData = clientPlatform.createCollectedClientData(ClientDataType.WEBAUTHN_GET, challenge);
RegistrationEmulationOption registrationEmulationOption = new RegistrationEmulationOption();
registrationEmulationOption.setCollectedClientData(collectedClientData);
registrationEmulationOption.setCollectedClientDataOverrideEnabled(true);
AuthenticatorAttestationResponse authenticatorAttestationResponse = clientPlatform.create(credentialCreationOptions, registrationEmulationOption).getAuthenticatorResponse();
Set<String> transports = authenticatorTransportConverter.convertSetToStringSet(authenticatorAttestationResponse.getTransports());
ServerProperty serverProperty = new ServerProperty(origin, rpId, challenge, null);
RegistrationRequest registrationRequest = new RegistrationRequest(authenticatorAttestationResponse.getAttestationObject(), authenticatorAttestationResponse.getClientDataJSON(), transports);
RegistrationParameters registrationParameters = new RegistrationParameters(serverProperty, null, false, true);
assertThrows(InconsistentClientDataTypeException.class, () -> target.validate(registrationRequest, registrationParameters));
}
use of com.webauthn4j.test.client.RegistrationEmulationOption in project webauthn4j by webauthn4j.
the class FIDOU2FAuthenticatorRegistrationValidationTest method validate_invalid_format_attestation_signature_test.
@Test
void validate_invalid_format_attestation_signature_test() {
String rpId = "example.com";
Challenge challenge = new DefaultChallenge();
PublicKeyCredentialParameters publicKeyCredentialParameters = new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256);
AuthenticatorSelectionCriteria authenticatorSelectionCriteria = new AuthenticatorSelectionCriteria(AuthenticatorAttachment.CROSS_PLATFORM, true, UserVerificationRequirement.REQUIRED);
AuthenticationExtensionsClientInputs<RegistrationExtensionClientInput> extensions = new AuthenticationExtensionsClientInputs<>();
PublicKeyCredentialCreationOptions credentialCreationOptions = new PublicKeyCredentialCreationOptions(new PublicKeyCredentialRpEntity(rpId, "valid.site.example.com"), new PublicKeyCredentialUserEntity(new byte[32], "username", "displayName"), challenge, Collections.singletonList(publicKeyCredentialParameters), null, Collections.emptyList(), authenticatorSelectionCriteria, AttestationConveyancePreference.DIRECT, extensions);
RegistrationEmulationOption registrationEmulationOption = new RegistrationEmulationOption();
registrationEmulationOption.setSignatureOverrideEnabled(true);
AuthenticatorAttestationResponse authenticatorAttestationResponse = clientPlatform.create(credentialCreationOptions, registrationEmulationOption).getAuthenticatorResponse();
Set<String> transports = authenticatorTransportConverter.convertSetToStringSet(authenticatorAttestationResponse.getTransports());
ServerProperty serverProperty = new ServerProperty(origin, rpId, challenge, null);
RegistrationRequest registrationRequest = new RegistrationRequest(authenticatorAttestationResponse.getAttestationObject(), authenticatorAttestationResponse.getClientDataJSON(), transports);
RegistrationParameters registrationParameters = new RegistrationParameters(serverProperty, null, false, true);
assertThrows(BadSignatureException.class, () -> target.validate(registrationRequest, registrationParameters));
}
Aggregations