use of com.webauthn4j.data.attestation.statement.AttestationCertificatePath in project webauthn4j by webauthn4j.
the class AttestationCertificatePathConverterTest method test.
@Test
void test() {
AttestationCertificatePath attestationCertificatePath = new AttestationCertificatePath(Collections.singletonList(TestAttestationUtil.load2tierTestAuthenticatorAttestationCertificate()));
byte[] cbor = cborConverter.writeValueAsBytes(attestationCertificatePath);
AttestationCertificatePath restored = cborConverter.readValue(cbor, AttestationCertificatePath.class);
assertThat(restored).isEqualTo(attestationCertificatePath);
}
use of com.webauthn4j.data.attestation.statement.AttestationCertificatePath in project webauthn4j by webauthn4j.
the class AndroidKeyAttestationStatementValidator method getPublicKey.
@NonNull
private PublicKey getPublicKey(@NonNull AndroidKeyAttestationStatement attestationStatement) {
AttestationCertificatePath x5c = attestationStatement.getX5c();
Certificate cert = x5c.getEndEntityAttestationCertificate().getCertificate();
return cert.getPublicKey();
}
use of com.webauthn4j.data.attestation.statement.AttestationCertificatePath in project webauthn4j by webauthn4j.
the class AppleAppAttestAttestationStatementTest method constructor_test.
@Test
void constructor_test() {
AttestationCertificatePath attestationCertificatePath = new AttestationCertificatePath();
assertAll(() -> assertThatThrownBy(() -> new AppleAppAttestAttestationStatement(null, new byte[32])).isInstanceOf(IllegalArgumentException.class), () -> assertThatThrownBy(() -> new AppleAppAttestAttestationStatement(attestationCertificatePath, null)).isInstanceOf(IllegalArgumentException.class));
}
use of com.webauthn4j.data.attestation.statement.AttestationCertificatePath in project webauthn4j by webauthn4j.
the class AppleAppAttestAttestationStatementValidatorTest method validateX5c_empty_AttestationCertificatePath_test.
@Test
void validateX5c_empty_AttestationCertificatePath_test() {
final AppleAppAttestAttestationStatement appleAppAttestAttestationStatement = new AppleAppAttestAttestationStatement(new AttestationCertificatePath(), new byte[32]);
assertThatThrownBy(() -> target.validateX5c(appleAppAttestAttestationStatement)).isInstanceOf(BadAttestationStatementException.class);
}
use of com.webauthn4j.data.attestation.statement.AttestationCertificatePath in project webauthn4j by webauthn4j.
the class AndroidKeyAuthenticator method createAttestationStatement.
@Override
public AttestationStatement createAttestationStatement(AttestationStatementRequest attestationStatementRequest, RegistrationEmulationOption registrationEmulationOption) {
byte[] signature;
if (registrationEmulationOption.isSignatureOverrideEnabled()) {
signature = registrationEmulationOption.getSignature();
} else {
signature = TestDataUtil.calculateSignature(attestationStatementRequest.getCredentialKeyPair().getPrivate(), attestationStatementRequest.getSignedData());
}
AttestationOption attestationOption = registrationEmulationOption.getAttestationOption() == null ? new AndroidKeyAttestationOption() : registrationEmulationOption.getAttestationOption();
X509Certificate attestationCertificate = getAttestationCertificate(attestationStatementRequest, attestationOption);
AttestationCertificatePath attestationCertificates = new AttestationCertificatePath(attestationCertificate, this.getCACertificatePath());
return new AndroidKeyAttestationStatement(COSEAlgorithmIdentifier.ES256, signature, attestationCertificates);
}
Aggregations