use of com.webauthn4j.data.attestation.statement.CertificateBaseAttestationStatement in project webauthn4j by webauthn4j.
the class FidoMdsMetadataValidator method validate.
@Override
public void validate(RegistrationObject registrationObject) {
AssertUtil.notNull(registrationObject.getAttestationObject().getAuthenticatorData(), "authenticatorData must not be null");
AssertUtil.notNull(registrationObject.getAttestationObject().getAuthenticatorData().getAttestedCredentialData(), "attestedCredentialData must not be null");
AAGUID aaguid = registrationObject.getAttestationObject().getAuthenticatorData().getAttestedCredentialData().getAaguid();
AttestationStatement attestationStatement = registrationObject.getAttestationObject().getAttestationStatement();
Set<MetadataItem> metadataItems = metadataItemsResolver.resolve(aaguid);
List<AuthenticatorAttestationType> authenticatorAttestationTypes = metadataItems.stream().flatMap(item -> item.getMetadataStatement().getAttestationTypes().stream()).collect(Collectors.toList());
boolean isSurrogate = !authenticatorAttestationTypes.isEmpty() && authenticatorAttestationTypes.stream().allMatch(type -> type.equals(AuthenticatorAttestationType.BASIC_SURROGATE));
if (isSurrogate && attestationStatement instanceof CertificateBaseAttestationStatement) {
CertificateBaseAttestationStatement certificateBaseAttestationStatement = (CertificateBaseAttestationStatement) attestationStatement;
if (certificateBaseAttestationStatement.getX5c() != null) {
throw new BadAttestationStatementException("Although AAGUID is registered for surrogate attestation in metadata, x5c contains certificates.");
}
}
for (MetadataItem metadataItem : metadataItems) {
doAdditionalValidationForFidoMdsMetadataItem(metadataItem);
}
}
use of com.webauthn4j.data.attestation.statement.CertificateBaseAttestationStatement in project webauthn4j by webauthn4j.
the class DefaultCertPathTrustworthinessValidatorTest method validate_full_chain_test.
@Test
void validate_full_chain_test() {
Set<TrustAnchor> trustAnchors = CertificateUtil.generateTrustAnchors(Collections.singletonList(TestAttestationUtil.load3tierTestRootCACertificate()));
when(trustAnchorRepository.find(aaguid)).thenReturn(trustAnchors);
AttestationCertificatePath attestationCertificatePath = new AttestationCertificatePath(Arrays.asList(TestAttestationUtil.load3tierTestAuthenticatorAttestationCertificate(), TestAttestationUtil.load3tierTestIntermediateCACertificate(), TestAttestationUtil.load3tierTestRootCACertificate()));
CertificateBaseAttestationStatement attestationStatement = TestAttestationStatementUtil.createBasicPackedAttestationStatement(attestationCertificatePath);
target.setFullChainProhibited(true);
assertThrows(CertificateException.class, () -> target.validate(aaguid, attestationStatement));
}
use of com.webauthn4j.data.attestation.statement.CertificateBaseAttestationStatement in project webauthn4j by webauthn4j.
the class DefaultCertPathTrustworthinessValidatorTest method validate_with_empty_trustAnchors_test.
@Test
void validate_with_empty_trustAnchors_test() {
Set<TrustAnchor> trustAnchors = Collections.emptySet();
when(trustAnchorRepository.find(aaguid)).thenReturn(trustAnchors);
CertificateBaseAttestationStatement attestationStatement = TestAttestationStatementUtil.createFIDOU2FAttestationStatement(TestAttestationUtil.load2tierTestAttestationCertificatePath());
assertThrows(TrustAnchorNotFoundException.class, () -> target.validate(aaguid, attestationStatement));
}
use of com.webauthn4j.data.attestation.statement.CertificateBaseAttestationStatement in project webauthn4j by webauthn4j.
the class DefaultCertPathTrustworthinessValidatorTest method validate_u2f_test.
@Test
void validate_u2f_test() {
Set<TrustAnchor> trustAnchors = CertificateUtil.generateTrustAnchors(Collections.singletonList(TestAttestationUtil.load2tierTestRootCACertificate()));
when(trustAnchorRepository.find((byte[]) any())).thenReturn(trustAnchors);
CertificateBaseAttestationStatement attestationStatement = TestAttestationStatementUtil.createFIDOU2FAttestationStatement(TestAttestationUtil.load2tierTestAttestationCertificatePath());
target.validate(aaguid, attestationStatement);
}
use of com.webauthn4j.data.attestation.statement.CertificateBaseAttestationStatement in project webauthn4j by webauthn4j.
the class TrustAnchorCertPathTrustworthinessValidatorTest method validate_test.
@Test
void validate_test() {
Set<TrustAnchor> trustAnchors = CertificateUtil.generateTrustAnchors(Collections.singletonList(TestAttestationUtil.load2tierTestRootCACertificate()));
when(trustAnchorsResolver.resolve(aaguid)).thenReturn(trustAnchors);
CertificateBaseAttestationStatement attestationStatement = TestAttestationStatementUtil.createFIDOU2FAttestationStatement(TestAttestationUtil.load2tierTestAttestationCertificatePath());
target.validate(aaguid, attestationStatement);
}
Aggregations