use of net.ripe.rpki.validator3.domain.BgpSecAssertions in project rpki-validator-3 by RIPE-NCC.
the class ObjectController method list.
@GetMapping(path = "/validated")
public ResponseEntity<ApiResponse<ValidatedObjects>> list(Locale locale) {
final Map<Long, TrustAnchorResource> trustAnchorsById = trustAnchors.findAll().stream().collect(Collectors.toMap(TrustAnchor::getId, ta -> TrustAnchorResource.of(ta, locale)));
final Map<Long, Links> trustAnchorLinks = trustAnchorsById.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> new Links(entry.getValue().getLinks().getLink("self").withRel(TrustAnchor.TYPE))));
final Stream<RoaPrefix> validatedPrefixes = validatedRpkiObjects.findCurrentlyValidatedRoaPrefixes(null, null, null).getObjects().filter(new IgnoreFiltersPredicate(ignoreFilters.all()).negate()).map(prefix -> {
Links links = trustAnchorLinks.get(prefix.getTrustAnchor().getId());
return new RoaPrefix(String.valueOf(prefix.getAsn()), prefix.getPrefix().toString(), prefix.getEffectiveLength(), links);
});
final Stream<RoaPrefix> assertions = roaPrefixAssertions.all().map(assertion -> new RoaPrefix(new Asn(assertion.getAsn()).toString(), IpRange.parse(assertion.getPrefix()).toString(), assertion.getMaximumLength() != null ? assertion.getMaximumLength() : IpRange.parse(assertion.getPrefix()).getPrefixLength(), null));
final Stream<RoaPrefix> combinedPrefixes = Stream.concat(validatedPrefixes, assertions).distinct();
final Stream<ValidatedRpkiObjects.RouterCertificate> certificates = validatedRpkiObjects.findCurrentlyValidatedRouterCertificates().getObjects();
final Stream<RouterCertificate> filteredRouterCertificates = bgpSecFilterService.filterCertificates(certificates).map(o -> new RouterCertificate(o.getAsn(), o.getSubjectKeyIdentifier(), o.getSubjectPublicKeyInfo()));
final Stream<RouterCertificate> bgpSecAssertions = this.bgpSecAssertions.all().map(b -> {
final List<String> asns = Collections.singletonList(String.valueOf(b.getAsn()));
return new RouterCertificate(asns, b.getSki(), b.getPublicKey());
});
final Stream<RouterCertificate> combinedAssertions = Stream.concat(filteredRouterCertificates, bgpSecAssertions).distinct();
return ResponseEntity.ok(ApiResponse.<ValidatedObjects>builder().data(new ValidatedObjects(settings.isInitialValidationRunCompleted(), trustAnchorsById.values(), combinedPrefixes, combinedAssertions)).build());
}
use of net.ripe.rpki.validator3.domain.BgpSecAssertions in project rpki-validator-3 by RIPE-NCC.
the class SlurmParserTest method parse.
@Test
public void parse() throws IOException {
final Slurm slurm = SlurmParser.parse(read("slurm/slurm1.json"));
final List<SlurmPrefixFilter> prefixFilters = slurm.getValidationOutputFilters().getPrefixFilters();
assertEquals(null, prefixFilters.get(0).getAsn());
assertEquals(new Long(64496), prefixFilters.get(1).getAsn());
assertEquals(new Long(64497), prefixFilters.get(2).getAsn());
assertEquals("198.51.100.0/24", prefixFilters.get(2).getPrefix());
assertEquals("All VRPs encompassed by prefix, matching ASN", prefixFilters.get(2).getComment());
final List<SlurmBgpSecFilter> bgpsecFilters = slurm.getValidationOutputFilters().getBgpsecFilters();
assertEquals(new Long(64496), bgpsecFilters.get(0).getAsn());
assertEquals(null, bgpsecFilters.get(1).getAsn());
assertEquals("Zm9v", bgpsecFilters.get(1).getRouterSKI());
assertEquals(new Long(64497), bgpsecFilters.get(2).getAsn());
assertEquals("YmFy", bgpsecFilters.get(2).getRouterSKI());
assertEquals("Key for ASN 64497 matching Router SKI", bgpsecFilters.get(2).getComment());
final List<SlurmPrefixAssertion> prefixAssertions = slurm.getLocallyAddedAssertions().getPrefixAssertions();
assertEquals(new Long(64496), prefixAssertions.get(0).getAsn());
assertEquals("198.51.100.0/24", prefixAssertions.get(0).getPrefix());
assertEquals("My other important route", prefixAssertions.get(0).getComment());
assertEquals(null, prefixAssertions.get(0).getMaxPrefixLength());
assertEquals(new Long(64496), prefixAssertions.get(1).getAsn());
assertEquals("2001:DB8::/32", prefixAssertions.get(1).getPrefix());
assertEquals(new Integer(48), prefixAssertions.get(1).getMaxPrefixLength());
assertEquals("My other important de-aggregated routes", prefixAssertions.get(1).getComment());
final List<SlurmBgpSecAssertion> bgpsecAssertions = slurm.getLocallyAddedAssertions().getBgpsecAssertions();
assertEquals(new Long(64496), bgpsecAssertions.get(0).getAsn());
assertEquals("<some base64 SKI>", bgpsecAssertions.get(0).getSki());
assertEquals("<some base64 public key>", bgpsecAssertions.get(0).getPublicKey());
assertEquals("My known key for my important ASN", bgpsecAssertions.get(0).getComment());
}
Aggregations