AuthenticatorDataConverter { public byte[] extractAttestedCredentialData(byte[] authenticatorData) { byte[] lengthBytes = Arrays.copyOfRange(authenticatorData, L_INDEX, CREDENTIAL_ID_INDEX); int credentialIdLength = UnsignedNumberUtil.getUnsignedShort(lengthBytes); int credentialPublicKeyIndex = CREDENTIAL_ID_INDEX + credentialIdLength; byte[] attestedCredentialDataBytes = Arrays.copyOfRange(authenticatorData, credentialPublicKeyIndex, authenticatorData.length); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(attestedCredentialDataBytes); COSEKeyEnvelope coseKeyEnvelope = attestedCredentialDataConverter.convertToCredentialPublicKey(byteArrayInputStream); int credentialPublicKeyLength = coseKeyEnvelope.getLength(); int attestedCredentialDataLength = AAGUID_LENGTH + L_LENGTH + credentialIdLength + credentialPublicKeyLength; return Arrays.copyOfRange(authenticatorData, ATTESTED_CREDENTIAL_DATA_INDEX, ATTESTED_CREDENTIAL_DATA_INDEX + attestedCredentialDataLength); } AuthenticatorDataConverter(ObjectConverter objectConverter); byte[] convert(AuthenticatorData<T> source); AuthenticatorData<T> convert(byte[] source); byte[] extractAttestedCredentialData(byte[] authenticatorData); long extractSignCount(byte[] authenticatorData);  }
@Test void extractAttestedCredentialData_test() { String input = "SZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2NBAAAARlUOS1SqR0CfmpUat2wTATEAIHEiziyGohCFUc_hJJZGdtSu9ThnEb74K6NZC3U-KbwgpQECAyYgASFYICw4xPmHIvquDRz2KUzyyQlZFhZMbi-mc_YylL1o55jPIlggGQI5ESYAOfR8QM6quTQSoyhjZET806A3yOoCUe2AWJE"; byte[] result = new AuthenticatorDataConverter(objectConverter).extractAttestedCredentialData(Base64UrlUtil.decode(input)); assertThat(result).isEqualTo(Base64UrlUtil.decode("VQ5LVKpHQJ-alRq3bBMBMQAgcSLOLIaiEIVRz-EklkZ21K71OGcRvvgro1kLdT4pvCClAQIDJiABIVggLDjE-Yci-q4NHPYpTPLJCVkWFkxuL6Zz9jKUvWjnmM8iWCAZAjkRJgA59HxAzqq5NBKjKGNkRPzToDfI6gJR7YBYkQ")); }