use of com.webauthn4j.appattest.data.DCAssertion in project webauthn4j by webauthn4j.
the class DeviceCheckAssertionManagerTest method parse_DCAssertion_with_signature_null_authenticatorData_null_test.
@Test
void parse_DCAssertion_with_signature_null_authenticatorData_null_test() {
DeviceCheckAssertionManager deviceCheckAssertionManager = new DeviceCheckAssertionManager();
AuthenticatorData<RegistrationExtensionAuthenticatorOutput> authenticatorData = TestDataUtil.createAuthenticatorData();
byte[] keyId = new byte[64];
byte[] authenticatorDataBytes = authenticatorDataConverter.convert(authenticatorData);
byte[] assertion = cborConverter.writeValueAsBytes(new DCAssertion(new byte[32], authenticatorDataBytes));
byte[] clientDataHash = new byte[32];
DCAssertionData dcAssertionData = deviceCheckAssertionManager.parse(new DCAssertionRequest(keyId, assertion, clientDataHash));
assertThat(dcAssertionData.getKeyId()).isEqualTo(new byte[64]);
assertThat(dcAssertionData.getSignature()).isEqualTo(new byte[32]);
assertThat(dcAssertionData.getAuthenticatorData()).isEqualTo(authenticatorData);
assertThat(dcAssertionData.getClientDataHash()).isEqualTo(new byte[32]);
}
use of com.webauthn4j.appattest.data.DCAssertion in project webauthn4j by webauthn4j.
the class DeviceCheckAssertionManager method parse.
@SuppressWarnings("squid:S1130")
@NonNull
public DCAssertionData parse(@NonNull DCAssertionRequest dcAssertionRequest) throws DataConversionException {
AssertUtil.notNull(dcAssertionRequest, "dcAssertionRequest must not be null");
byte[] credentialId = dcAssertionRequest.getKeyId();
DCAssertion assertion = cborConverter.readValue(dcAssertionRequest.getAssertion(), DCAssertion.class);
byte[] authenticatorDataBytes = assertion == null ? null : assertion.getAuthenticatorData();
AuthenticatorData<AuthenticationExtensionAuthenticatorOutput> authenticatorData = authenticatorDataBytes == null ? null : authenticatorDataConverter.convert(authenticatorDataBytes);
byte[] clientDataHash = dcAssertionRequest.getClientDataHash();
byte[] signature = assertion == null ? null : assertion.getSignature();
return new DCAssertionData(credentialId, authenticatorData, authenticatorDataBytes, clientDataHash, signature);
}
Aggregations