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();
}
Aggregations