use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class OriginValidatorImplTest method apk_key_hash_sha256_test_with_not_equal_origins.
@SuppressWarnings("java:S5976")
@Test
void apk_key_hash_sha256_test_with_not_equal_origins() {
Origin originA = new Origin("android:apk-key-hash-sha256:aNiP5iKyQ8JwgGOaKA1zGPUPJIS-0H1xKCQcfIoGLck");
Origin originB = new Origin("android:apk-key-hash-sha256:pNiP5iKyQ8JwgGOaKA1zGPUPJIS-0H1xKCQcfIoGLck");
CollectedClientData collectedClientData = new CollectedClientData(ClientDataType.WEBAUTHN_CREATE, TestDataUtil.createChallenge(), originA, null);
ServerProperty serverProperty = new ServerProperty(originB, "2.example.com", TestDataUtil.createChallenge(), null);
assertThrows(BadOriginException.class, () -> target.validate(collectedClientData, serverProperty));
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class OriginValidatorImplTest method test.
@ParameterizedTest
@ValueSource(strings = { // web
"https://example.com:14443", // android:apk-key-hash
"android:apk-key-hash:pNiP5iKyQ8JwgGOaKA1zGPUPJIS-0H1xKCQcfIoGLck", // android:apk-key-hash-sha256
"android:apk-key-hash-sha256:pNiP5iKyQ8JwgGOaKA1zGPUPJIS-0H1xKCQcfIoGLck" })
void test(String origin) {
Origin originA = new Origin(origin);
Origin originB = new Origin(origin);
CollectedClientData collectedClientData = new CollectedClientData(ClientDataType.WEBAUTHN_CREATE, TestDataUtil.createChallenge(), originA, null);
ServerProperty serverProperty = new ServerProperty(originB, "example.com", TestDataUtil.createChallenge(), null);
target.validate(collectedClientData, serverProperty);
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class RegistrationObjectTest method equals_hashCode_test.
@Test
void equals_hashCode_test() {
CollectedClientData clientData = TestDataUtil.createClientData(ClientDataType.WEBAUTHN_CREATE);
byte[] clientDataBytes = new CollectedClientDataConverter(objectConverter).convertToBytes(clientData);
AttestationObject attestationObject = TestDataUtil.createAttestationObjectWithFIDOU2FAttestationStatement();
byte[] attestationObjectBytes = new AttestationObjectConverter(objectConverter).convertToBytes(attestationObject);
Set<AuthenticatorTransport> transports = Collections.emptySet();
AuthenticationExtensionsClientOutputs<RegistrationExtensionClientOutput> clientExtensions = new AuthenticationExtensionsClientOutputs<>();
ServerProperty serverProperty = TestDataUtil.createServerProperty();
Instant timestamp = Instant.now();
RegistrationObject instanceA = new RegistrationObject(attestationObject, attestationObjectBytes, clientData, clientDataBytes, clientExtensions, transports, serverProperty, timestamp);
RegistrationObject instanceB = new RegistrationObject(attestationObject, attestationObjectBytes, clientData, clientDataBytes, clientExtensions, transports, serverProperty, timestamp);
assertAll(() -> assertThat(instanceA).isEqualTo(instanceB), () -> assertThat(instanceA).hasSameHashCodeAs(instanceB));
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class RegistrationObjectTest method getter_test.
@Test
void getter_test() {
CollectedClientData clientData = TestDataUtil.createClientData(ClientDataType.WEBAUTHN_CREATE);
byte[] clientDataBytes = new CollectedClientDataConverter(objectConverter).convertToBytes(clientData);
AttestationObject attestationObject = TestDataUtil.createAttestationObjectWithFIDOU2FAttestationStatement();
byte[] attestationObjectBytes = new AttestationObjectConverter(objectConverter).convertToBytes(attestationObject);
AuthenticatorData<RegistrationExtensionAuthenticatorOutput> authenticatorData = TestDataUtil.createAuthenticatorData();
byte[] authenticatorDataBytes = new AuthenticatorDataConverter(objectConverter).convert(authenticatorData);
Set<AuthenticatorTransport> transports = Collections.emptySet();
AuthenticationExtensionsClientOutputs<RegistrationExtensionClientOutput> clientExtensions = new AuthenticationExtensionsClientOutputs<>();
ServerProperty serverProperty = TestDataUtil.createServerProperty();
Instant timestamp = Instant.now();
RegistrationObject registrationObject = new RegistrationObject(attestationObject, attestationObjectBytes, clientData, clientDataBytes, clientExtensions, transports, serverProperty, timestamp);
assertAll(() -> assertThat(registrationObject.getCollectedClientData()).isEqualTo(clientData), () -> assertThat(registrationObject.getCollectedClientDataBytes()).isEqualTo(clientDataBytes), () -> assertThat(registrationObject.getAttestationObject()).isEqualTo(attestationObject), () -> assertThat(registrationObject.getAttestationObjectBytes()).isEqualTo(attestationObjectBytes), () -> assertThat(registrationObject.getAuthenticatorDataBytes()).isEqualTo(authenticatorDataBytes), () -> assertThat(registrationObject.getTransports()).isEqualTo(transports), () -> assertThat(registrationObject.getClientExtensions()).isEqualTo(clientExtensions), () -> assertThat(registrationObject.getServerProperty()).isEqualTo(serverProperty), () -> assertThat(registrationObject.getTimestamp()).isEqualTo(timestamp));
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class AuthenticationObjectTest method equals_hashCode_test.
@Test
void equals_hashCode_test() {
byte[] credentialId = new byte[32];
CollectedClientData clientData = TestDataUtil.createClientData(ClientDataType.WEBAUTHN_CREATE);
byte[] clientDataBytes = new CollectedClientDataConverter(objectConverter).convertToBytes(clientData);
AuthenticatorData<AuthenticationExtensionAuthenticatorOutput> authenticatorData = TestDataUtil.createAuthenticatorData();
byte[] authenticatorDataBytes = new AuthenticatorDataConverter(objectConverter).convert(authenticatorData);
AuthenticationExtensionsClientOutputs<AuthenticationExtensionClientOutput> clientExtensions = new AuthenticationExtensionsClientOutputs<>();
ServerProperty serverProperty = TestDataUtil.createServerProperty();
Authenticator authenticator = TestDataUtil.createAuthenticator();
AuthenticationObject instanceA = new AuthenticationObject(credentialId, authenticatorData, authenticatorDataBytes, clientData, clientDataBytes, clientExtensions, serverProperty, authenticator);
AuthenticationObject instanceB = new AuthenticationObject(credentialId, authenticatorData, authenticatorDataBytes, clientData, clientDataBytes, clientExtensions, serverProperty, authenticator);
assertAll(() -> assertThat(instanceA).isEqualTo(instanceB), () -> assertThat(instanceA).hasSameHashCodeAs(instanceB));
}
Aggregations