use of net.ripe.rpki.validator3.domain.ValidationRun in project rpki-validator-3 by RIPE-NCC.
the class TrustAnchorController method validationResults.
@GetMapping(path = "/{id}/validation-run")
public ResponseEntity<ApiResponse<ValidationRunResource>> validationResults(@PathVariable long id, HttpServletResponse response, Locale locale) throws IOException {
TrustAnchor trustAnchor = trustAnchorRepository.get(id);
ValidationRun validationRun = validationRunRepository.findLatestCompletedForTrustAnchor(trustAnchor).orElseThrow(() -> new EmptyResultDataAccessException("latest validation run for trust anchor " + id, 1));
response.sendRedirect(linkTo(methodOn(ValidationRunController.class).get(validationRun.getId(), locale)).toString());
return null;
}
use of net.ripe.rpki.validator3.domain.ValidationRun in project rpki-validator-3 by RIPE-NCC.
the class RrdpService method doStoreRepository.
private void doStoreRepository(RpkiRepository rpkiRepository, RpkiRepositoryValidationRun validationRun) {
final Notification notification = rrdpClient.readStream(rpkiRepository.getRrdpNotifyUri(), rrdpParser::notification);
log.info("The local serial is '{}' and the latest serial is {}", rpkiRepository.getRrdpSerial(), notification.serial);
if (notification.sessionId.equals(rpkiRepository.getRrdpSessionId())) {
if (rpkiRepository.getRrdpSerial().compareTo(notification.serial) <= 0) {
try {
final List<Delta> deltas = notification.deltas.parallelStream().filter(d -> d.getSerial().compareTo(rpkiRepository.getRrdpSerial()) > 0).sorted(Comparator.comparing(DeltaInfo::getSerial)).map(di -> readDelta(notification, di)).collect(Collectors.toList());
verifyDeltaSerials(deltas, notification, rpkiRepository);
deltas.forEach(d -> {
storeDelta(d, validationRun);
rpkiRepository.setRrdpSerial(rpkiRepository.getRrdpSerial().add(BigInteger.ONE));
});
} catch (RrdpException e) {
log.info("Processing deltas failed {}, falling back to snapshot processing.", e.getMessage());
ValidationCheck validationCheck = new ValidationCheck(validationRun, rpkiRepository.getRrdpNotifyUri(), ValidationCheck.Status.WARNING, ErrorCodes.RRDP_FETCH_DELTAS, e.getMessage());
validationRun.addCheck(validationCheck);
readSnapshot(rpkiRepository, validationRun, notification);
}
}
} else {
log.info("Repository has session id '{}' but the downloaded version has session id '{}', fetching the snapshot", rpkiRepository.getRrdpSessionId(), notification.sessionId);
readSnapshot(rpkiRepository, validationRun, notification);
}
}
use of net.ripe.rpki.validator3.domain.ValidationRun in project rpki-validator-3 by RIPE-NCC.
the class RrdpService method addRpkiObject.
private void addRpkiObject(RpkiRepositoryValidationRun validationRun, String uri, DeltaPublish deltaPublish, final byte[] existingHash) {
final Either<ValidationResult, RpkiObject> maybeRpkiObject = createRpkiObject(uri, deltaPublish.getContent());
if (maybeRpkiObject.isLeft()) {
validationRun.addChecks(maybeRpkiObject.left().value());
} else {
RpkiObject object = maybeRpkiObject.right().value();
if (existingHash == null || !Arrays.equals(object.getSha256(), existingHash)) {
validationRun.addRpkiObject(object);
rpkiObjectRepository.add(object);
} else {
log.debug("The object added is the same {}", object);
}
log.debug("Added to database {}", object);
}
}
Aggregations