Search in sources :

Example 1 with DCAssertion

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]);
}
Also used : DCAssertion(com.webauthn4j.appattest.data.DCAssertion) RegistrationExtensionAuthenticatorOutput(com.webauthn4j.data.extension.authenticator.RegistrationExtensionAuthenticatorOutput) DCAssertionData(com.webauthn4j.appattest.data.DCAssertionData) DCAssertionRequest(com.webauthn4j.appattest.data.DCAssertionRequest) Test(org.junit.jupiter.api.Test)

Example 2 with DCAssertion

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);
}
Also used : DCAssertion(com.webauthn4j.appattest.data.DCAssertion) AuthenticationExtensionAuthenticatorOutput(com.webauthn4j.data.extension.authenticator.AuthenticationExtensionAuthenticatorOutput) DCAssertionData(com.webauthn4j.appattest.data.DCAssertionData) NonNull(org.checkerframework.checker.nullness.qual.NonNull)

Aggregations

DCAssertion (com.webauthn4j.appattest.data.DCAssertion)2 DCAssertionData (com.webauthn4j.appattest.data.DCAssertionData)2 DCAssertionRequest (com.webauthn4j.appattest.data.DCAssertionRequest)1 AuthenticationExtensionAuthenticatorOutput (com.webauthn4j.data.extension.authenticator.AuthenticationExtensionAuthenticatorOutput)1 RegistrationExtensionAuthenticatorOutput (com.webauthn4j.data.extension.authenticator.RegistrationExtensionAuthenticatorOutput)1 NonNull (org.checkerframework.checker.nullness.qual.NonNull)1 Test (org.junit.jupiter.api.Test)1