use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class TestDataUtil method createRegistrationObject.
public static RegistrationObject createRegistrationObject(Function<byte[], AttestationObject> attestationObjectProvider) {
CollectedClientData collectedClientData = createClientData(ClientDataType.WEBAUTHN_CREATE);
byte[] collectedClientDataBytes = collectedClientDataConverter.convertToBytes(collectedClientData);
AttestationObject attestationObject = attestationObjectProvider.apply(collectedClientDataBytes);
byte[] attestationObjectBytes = attestationObjectConverter.convertToBytes(attestationObject);
Set<AuthenticatorTransport> transports = Collections.emptySet();
AuthenticationExtensionsClientOutputs<RegistrationExtensionClientOutput> authenticationExtensionsClientOutputs = new AuthenticationExtensionsClientOutputs<>();
return new RegistrationObject(attestationObject, attestationObjectBytes, collectedClientData, collectedClientDataBytes, authenticationExtensionsClientOutputs, transports, TestDataUtil.createServerProperty());
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class WebAuthnAuthenticationManager method parse.
@SuppressWarnings("squid:S1130")
@NonNull
public AuthenticationData parse(@NonNull AuthenticationRequest authenticationRequest) throws DataConversionException {
AssertUtil.notNull(authenticationRequest, "authenticationRequest must not be null");
byte[] credentialId = authenticationRequest.getCredentialId();
byte[] signature = authenticationRequest.getSignature();
byte[] userHandle = authenticationRequest.getUserHandle();
byte[] clientDataBytes = authenticationRequest.getClientDataJSON();
CollectedClientData collectedClientData = clientDataBytes == null ? null : collectedClientDataConverter.convert(clientDataBytes);
byte[] authenticatorDataBytes = authenticationRequest.getAuthenticatorData();
AuthenticatorData<AuthenticationExtensionAuthenticatorOutput> authenticatorData = authenticatorDataBytes == null ? null : authenticatorDataConverter.convert(authenticatorDataBytes);
AuthenticationExtensionsClientOutputs<AuthenticationExtensionClientOutput> clientExtensions = authenticationRequest.getClientExtensionsJSON() == null ? null : authenticationExtensionsClientOutputsConverter.convert(authenticationRequest.getClientExtensionsJSON());
return new AuthenticationData(credentialId, userHandle, authenticatorData, authenticatorDataBytes, collectedClientData, clientDataBytes, clientExtensions, signature);
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class OriginValidatorImplTest method multiple_origins_test.
@Test
void multiple_origins_test() {
final Origin originA = new Origin("https://example.com:14443");
final Origin originB = new Origin("http://localhost:9090");
final Origin originC = new Origin("android:apk-key-hash:pNiP5iKyQ8JwgGOaKA1zGPUPJIS-0H1xKCQcfIoGLck");
final Origin originD = new Origin("android:apk-key-hash-sha256:qSiQ5iKyQ8JwgGOaKA1zGPUPJIS-0H1xKCQcfIoGLck");
final ServerProperty serverProperty = new ServerProperty(new HashSet<>(Arrays.asList(originA, originB, originC, originD)), "example.com", TestDataUtil.createChallenge(), null);
final CollectedClientData collectedClientDataA = new CollectedClientData(ClientDataType.WEBAUTHN_CREATE, TestDataUtil.createChallenge(), originA, null);
final CollectedClientData collectedClientDataB = new CollectedClientData(ClientDataType.WEBAUTHN_CREATE, TestDataUtil.createChallenge(), originB, null);
final CollectedClientData collectedClientDataC = new CollectedClientData(ClientDataType.WEBAUTHN_GET, TestDataUtil.createChallenge(), originC, null);
final CollectedClientData collectedClientDataD = new CollectedClientData(ClientDataType.WEBAUTHN_GET, TestDataUtil.createChallenge(), originD, null);
target.validate(collectedClientDataA, serverProperty);
target.validate(collectedClientDataB, serverProperty);
target.validate(collectedClientDataC, serverProperty);
target.validate(collectedClientDataD, serverProperty);
}
use of com.webauthn4j.data.client.CollectedClientData in project webauthn4j by webauthn4j.
the class OriginValidatorImplTest method test_with_not_equal_origins.
@SuppressWarnings("java:S5976")
@Test
void test_with_not_equal_origins() {
Origin originA = new Origin("https://example.com:14443");
Origin originB = new Origin("http://example.com");
CollectedClientData collectedClientData = new CollectedClientData(ClientDataType.WEBAUTHN_CREATE, TestDataUtil.createChallenge(), originA, null);
ServerProperty serverProperty = new ServerProperty(originB, "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 apk_key_hash_test_with_not_equal_origins.
@SuppressWarnings("java:S5976")
@Test
void apk_key_hash_test_with_not_equal_origins() {
Origin originA = new Origin("android:apk-key-hash:aNiP5iKyQ8JwgGOaKA1zGPUPJIS-0H1xKCQcfIoGLck");
Origin originB = new Origin("android:apk-key-hash:pNiP5iKyQ8JwgGOaKA1zGPUPJIS-0H1xKCQcfIoGLck");
CollectedClientData collectedClientData = new CollectedClientData(ClientDataType.WEBAUTHN_CREATE, TestDataUtil.createChallenge(), originA, null);
ServerProperty serverProperty = new ServerProperty(originB, "1.example.com", TestDataUtil.createChallenge(), null);
assertThrows(BadOriginException.class, () -> target.validate(collectedClientData, serverProperty));
}
Aggregations