Search in sources :

Example 1 with AuthenticationExtensionsAuthenticatorOutputsEnvelope

use of com.webauthn4j.converter.jackson.deserializer.cbor.AuthenticationExtensionsAuthenticatorOutputsEnvelope in project webauthn4j by webauthn4j.

the class AuthenticatorDataConverter method convertToExtensions.

@Nullable
<T extends ExtensionAuthenticatorOutput> AuthenticationExtensionsAuthenticatorOutputs<T> convertToExtensions(@NonNull ByteBuffer byteBuffer) {
    // Since convertToExtensions is called when ED flag is set, return empty AuthenticationExtensionsAuthenticatorOutputs even when remaining is zero.
    if (byteBuffer.remaining() == 0) {
        return new AuthenticationExtensionsAuthenticatorOutputs<>();
    }
    byte[] remaining = new byte[byteBuffer.remaining()];
    byteBuffer.get(remaining);
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(remaining);
    AuthenticationExtensionsAuthenticatorOutputsEnvelope<T> envelope = cborConverter.readValue(byteArrayInputStream, new TypeReference<AuthenticationExtensionsAuthenticatorOutputsEnvelope<T>>() {
    });
    if (envelope == null) {
        return null;
    }
    int leftoverLength = remaining.length - envelope.getLength();
    byteBuffer.position(byteBuffer.position() - leftoverLength);
    return envelope.getAuthenticationExtensionsAuthenticatorOutputs();
}
Also used : AuthenticationExtensionsAuthenticatorOutputs(com.webauthn4j.data.extension.authenticator.AuthenticationExtensionsAuthenticatorOutputs) ByteArrayInputStream(java.io.ByteArrayInputStream) AuthenticationExtensionsAuthenticatorOutputsEnvelope(com.webauthn4j.converter.jackson.deserializer.cbor.AuthenticationExtensionsAuthenticatorOutputsEnvelope) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Aggregations

AuthenticationExtensionsAuthenticatorOutputsEnvelope (com.webauthn4j.converter.jackson.deserializer.cbor.AuthenticationExtensionsAuthenticatorOutputsEnvelope)1 AuthenticationExtensionsAuthenticatorOutputs (com.webauthn4j.data.extension.authenticator.AuthenticationExtensionsAuthenticatorOutputs)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Nullable (org.checkerframework.checker.nullness.qual.Nullable)1