Search in sources :

Example 26 with TrustAnchor

use of net.ripe.rpki.validator3.domain.TrustAnchor in project rpki-validator-3 by RIPE-NCC.

the class RpkiRepositoryValidationService method processRsyncRepository.

protected ValidationResult processRsyncRepository(Set<TrustAnchor> affectedTrustAnchors, RsyncRepositoryValidationRun validationRun, Map<URI, RpkiRepository> fetchedLocations, Map<String, RpkiObject> objectsBySha256, RpkiRepository repository) {
    ValidationResult validationResult = ValidationResult.withLocation(URI.create(repository.getRsyncRepositoryUri()));
    validationRun.addRpkiRepository(repository);
    try {
        File targetDirectory = RsyncUtils.localFileFromRsyncUri(rsyncLocalStorageDirectory, URI.create(repository.getRsyncRepositoryUri()));
        RpkiRepository parentRepository = findDownloadedParentRepository(fetchedLocations, repository);
        if (parentRepository == null) {
            fetchRsyncRepository(repository, targetDirectory, validationResult);
            if (validationResult.hasFailureForCurrentLocation()) {
                return validationResult;
            }
        }
        if (repository.getType() == RpkiRepository.Type.RSYNC && (parentRepository == null || parentRepository.getType() == RpkiRepository.Type.RSYNC_PREFETCH)) {
            storeObjects(targetDirectory, validationRun, validationResult, objectsBySha256, repository);
        }
    } catch (IOException e) {
        repository.setFailed();
        validationResult.error(ErrorCodes.RSYNC_REPOSITORY_IO, e.toString(), ExceptionUtils.getStackTrace(e));
    }
    affectedTrustAnchors.addAll(repository.getTrustAnchors());
    repository.setDownloaded();
    fetchedLocations.put(URI.create(repository.getRsyncRepositoryUri()), repository);
    return validationResult;
}
Also used : RpkiRepository(net.ripe.rpki.validator3.domain.RpkiRepository) IOException(java.io.IOException) ValidationResult(net.ripe.rpki.commons.validation.ValidationResult) File(java.io.File)

Example 27 with TrustAnchor

use of net.ripe.rpki.validator3.domain.TrustAnchor in project rpki-validator-3 by RIPE-NCC.

the class TrustAnchorValidationServiceTest method test_success.

@Test
public void test_success() {
    TrustAnchor ta = createRipeNccTrustAnchor();
    trustAnchors.add(ta);
    ta.setLocations(Arrays.asList("src/test/resources/ripe-ncc-ta.cer"));
    subject.validate(ta.getId());
    ta.setLocations(Arrays.asList(DUMMY_RSYNC_URI));
    X509ResourceCertificate certificate = ta.getCertificate();
    assertThat(certificate).isNotNull();
    Optional<TrustAnchorValidationRun> validationRun = validationRuns.findLatestCompletedForTrustAnchor(ta);
    assertThat(validationRun).isPresent();
    assertThat(validationRun.get().getStatus()).isEqualTo(ValidationRun.Status.SUCCEEDED);
    assertThat(validationRun.get().getValidationChecks()).isEmpty();
}
Also used : TrustAnchor(net.ripe.rpki.validator3.domain.TrustAnchor) X509ResourceCertificate(net.ripe.rpki.commons.crypto.x509cert.X509ResourceCertificate) TrustAnchorValidationRun(net.ripe.rpki.validator3.domain.TrustAnchorValidationRun) Test(org.junit.Test) IntegrationTest(net.ripe.rpki.validator3.IntegrationTest)

Example 28 with TrustAnchor

use of net.ripe.rpki.validator3.domain.TrustAnchor in project rpki-validator-3 by RIPE-NCC.

the class TrustAnchorValidationServiceTest method test_empty_file.

@Test
public void test_empty_file() {
    TrustAnchor ta = createRipeNccTrustAnchor();
    trustAnchors.add(ta);
    ta.setLocations(Arrays.asList("src/test/resources/empty-file.cer"));
    subject.validate(ta.getId());
    ta.setLocations(Arrays.asList(DUMMY_RSYNC_URI));
    assertThat(ta.getCertificate()).isNull();
    Optional<TrustAnchorValidationRun> validationRun = validationRuns.findLatestCompletedForTrustAnchor(ta);
    assertThat(validationRun).isPresent();
    List<ValidationCheck> validationChecks = validationRun.get().getValidationChecks();
    assertThat(validationChecks).hasSize(1);
    assertThat(validationChecks.get(0).getKey()).isEqualTo(ErrorCodes.REPOSITORY_OBJECT_MINIMUM_SIZE);
}
Also used : TrustAnchor(net.ripe.rpki.validator3.domain.TrustAnchor) TrustAnchorValidationRun(net.ripe.rpki.validator3.domain.TrustAnchorValidationRun) ValidationCheck(net.ripe.rpki.validator3.domain.ValidationCheck) Test(org.junit.Test) IntegrationTest(net.ripe.rpki.validator3.IntegrationTest)

Example 29 with TrustAnchor

use of net.ripe.rpki.validator3.domain.TrustAnchor in project rpki-validator-3 by RIPE-NCC.

the class TrustAnchorValidationServiceTest method test_rsync_failure.

@Test
public void test_rsync_failure() {
    TrustAnchor ta = createRipeNccTrustAnchor();
    ta.setLocations(Arrays.asList(DUMMY_RSYNC_URI));
    trustAnchors.add(ta);
    subject.validate(ta.getId());
    assertThat(ta.getCertificate()).isNull();
    Optional<TrustAnchorValidationRun> validationRun = validationRuns.findLatestCompletedForTrustAnchor(ta);
    assertThat(validationRun).isPresent();
    List<ValidationCheck> validationChecks = validationRun.get().getValidationChecks();
    assertThat(validationChecks).hasSize(1);
    assertThat(validationChecks.get(0).getKey()).isEqualTo(ErrorCodes.RSYNC_FETCH);
}
Also used : TrustAnchor(net.ripe.rpki.validator3.domain.TrustAnchor) TrustAnchorValidationRun(net.ripe.rpki.validator3.domain.TrustAnchorValidationRun) ValidationCheck(net.ripe.rpki.validator3.domain.ValidationCheck) Test(org.junit.Test) IntegrationTest(net.ripe.rpki.validator3.IntegrationTest)

Example 30 with TrustAnchor

use of net.ripe.rpki.validator3.domain.TrustAnchor in project rpki-validator-3 by RIPE-NCC.

the class TrustAnchorValidationServiceTest method test_bad_subject_public_key.

@Test
public void test_bad_subject_public_key() {
    TrustAnchor ta = createRipeNccTrustAnchor();
    ta.setSubjectPublicKeyInfo(ta.getSubjectPublicKeyInfo().toUpperCase());
    trustAnchors.add(ta);
    ta.setLocations(Arrays.asList("src/test/resources/ripe-ncc-ta.cer"));
    subject.validate(ta.getId());
    ta.setLocations(Arrays.asList(DUMMY_RSYNC_URI));
    assertThat(ta.getCertificate()).isNull();
    Optional<TrustAnchorValidationRun> validationRun = validationRuns.findLatestCompletedForTrustAnchor(ta);
    assertThat(validationRun).isPresent();
    List<ValidationCheck> validationChecks = validationRun.get().getValidationChecks();
    assertThat(validationChecks).hasSize(1);
    assertThat(validationChecks.get(0).getKey()).isEqualTo("trust.anchor.subject.key.matches.locator");
}
Also used : TrustAnchor(net.ripe.rpki.validator3.domain.TrustAnchor) TrustAnchorValidationRun(net.ripe.rpki.validator3.domain.TrustAnchorValidationRun) ValidationCheck(net.ripe.rpki.validator3.domain.ValidationCheck) Test(org.junit.Test) IntegrationTest(net.ripe.rpki.validator3.IntegrationTest)

Aggregations

TrustAnchor (net.ripe.rpki.validator3.domain.TrustAnchor)36 IntegrationTest (net.ripe.rpki.validator3.IntegrationTest)23 RpkiRepository (net.ripe.rpki.validator3.domain.RpkiRepository)23 Test (org.junit.Test)23 RpkiObject (net.ripe.rpki.validator3.domain.RpkiObject)15 RpkiObjects (net.ripe.rpki.validator3.domain.RpkiObjects)15 ValidationCheck (net.ripe.rpki.validator3.domain.ValidationCheck)14 CertificateTreeValidationRun (net.ripe.rpki.validator3.domain.CertificateTreeValidationRun)10 RrdpRepositoryValidationRun (net.ripe.rpki.validator3.domain.RrdpRepositoryValidationRun)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 List (java.util.List)9 Transactional (javax.transaction.Transactional)9 TestObjects (net.ripe.rpki.validator3.TestObjects)9 URI (java.net.URI)8 ValidationResult (net.ripe.rpki.commons.validation.ValidationResult)8 EntityManager (javax.persistence.EntityManager)7 Optional (java.util.Optional)6 RpkiRepositories (net.ripe.rpki.validator3.domain.RpkiRepositories)6 TrustAnchors (net.ripe.rpki.validator3.domain.TrustAnchors)6 ValidationRuns (net.ripe.rpki.validator3.domain.ValidationRuns)6