use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class OriginValidatorImpl method validate.
// ~ Instance fields
// ================================================================================================
// ~ Methods
// ========================================================================================================
@Override
public void validate(@NonNull RegistrationObject registrationObject) {
AssertUtil.notNull(registrationObject, "registrationObject must not be null");
CollectedClientData collectedClientData = registrationObject.getCollectedClientData();
ServerProperty serverProperty = registrationObject.getServerProperty();
validate(collectedClientData, serverProperty);
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class OriginValidatorImpl method validate.
@Override
public void validate(@NonNull AuthenticationObject authenticationObject) {
AssertUtil.notNull(authenticationObject, "authenticationObject must not be null");
CollectedClientData collectedClientData = authenticationObject.getCollectedClientData();
ServerProperty serverProperty = authenticationObject.getServerProperty();
validate(collectedClientData, serverProperty);
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class CollectedClientDataConverterTest method convert_clientDataBase64UrlString_with_new_keys_test.
@Test
void convert_clientDataBase64UrlString_with_new_keys_test() {
// noinspection SpellCheckingInspection
String clientDataJson = "{\"challenge\":\"Tgup0LZZQKinvtQcZFYdRw\",\"new_keys_may_be_added_here\":\"do not compare clientDataJSON against a template. See https://goo.gl/yabPex\",\"origin\":\"http://localhost:8080\",\"tokenBinding\":{\"status\":\"not-supported\"},\"type\":\"webauthn.create\"}";
String clientDataBase64UrlString = Base64UrlUtil.encodeToString(clientDataJson.getBytes(StandardCharsets.UTF_8));
CollectedClientData collectedClientData = target.convert(clientDataBase64UrlString);
assertAll(() -> assertThat(collectedClientData.getType()).isEqualTo(ClientDataType.WEBAUTHN_CREATE), () -> assertThat(collectedClientData.getChallenge()).isEqualTo(new DefaultChallenge("Tgup0LZZQKinvtQcZFYdRw")), () -> assertThat(collectedClientData.getOrigin()).isEqualTo(new Origin("http://localhost:8080")), () -> assertThat(collectedClientData.getCrossOrigin()).isNull());
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class CollectedClientDataConverterTest method convertToString_deserialization_test.
@Test
void convertToString_deserialization_test() {
// noinspection SpellCheckingInspection
String clientDataJson = "{\"challenge\":\"tk31UH1ETGGTPj33OhOMzw\",\"origin\":\"http://localhost:8080\",\"tokenBinding\":{\"status\":\"not-supported\"},\"type\":\"webauthn.get\"}";
String clientDataBase64UrlString = Base64UrlUtil.encodeToString(clientDataJson.getBytes(StandardCharsets.UTF_8));
CollectedClientData collectedClientData = target.convert(clientDataBase64UrlString);
String result = target.convertToBase64UrlString(collectedClientData);
// noinspection SpellCheckingInspection
assertThat(result).isEqualTo("eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoidGszMVVIMUVUR0dUUGozM09oT016dyIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MCIsInRva2VuQmluZGluZyI6eyJzdGF0dXMiOiJub3Qtc3VwcG9ydGVkIn19");
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class CollectedClientDataConverterTest method convert_deserialization_test.
@Test
void convert_deserialization_test() {
// noinspection SpellCheckingInspection
String clientDataJson = "{\"challenge\":\"tk31UH1ETGGTPj33OhOMzw\",\"origin\":\"http://localhost:8080\",\"crossOrigin\":true,\"tokenBinding\":{\"status\":\"not-supported\"},\"type\":\"webauthn.get\"}";
String clientDataBase64UrlString = Base64UrlUtil.encodeToString(clientDataJson.getBytes(StandardCharsets.UTF_8));
CollectedClientData collectedClientData = target.convert(clientDataBase64UrlString);
assertAll(() -> assertThat(collectedClientData.getType()).isEqualTo(ClientDataType.WEBAUTHN_GET), () -> assertThat(collectedClientData.getChallenge()).isEqualTo(new DefaultChallenge("tk31UH1ETGGTPj33OhOMzw")), () -> assertThat(collectedClientData.getOrigin()).isEqualTo(new Origin("http://localhost:8080")), () -> assertThat(collectedClientData.getCrossOrigin()).isTrue());
}
Aggregations