Search in sources :

Example 1 with BgpSecAssertions

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());
}
Also used : Links(org.springframework.hateoas.Links) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) BgpSecFilterService(net.ripe.rpki.validator3.api.bgpsec.BgpSecFilterService) Value(lombok.Value) Asn(net.ripe.ipresource.Asn) TrustAnchorResource(net.ripe.rpki.validator3.api.trustanchors.TrustAnchorResource) Api(net.ripe.rpki.validator3.api.Api) RpkiObjects(net.ripe.rpki.validator3.domain.RpkiObjects) Locale(java.util.Locale) Map(java.util.Map) RoaPrefixAssertions(net.ripe.rpki.validator3.domain.RoaPrefixAssertions) GetMapping(org.springframework.web.bind.annotation.GetMapping) TrustAnchor(net.ripe.rpki.validator3.domain.TrustAnchor) ValidatedRpkiObjects(net.ripe.rpki.validator3.domain.ValidatedRpkiObjects) IpRange(net.ripe.ipresource.IpRange) TrustAnchors(net.ripe.rpki.validator3.domain.TrustAnchors) Collection(java.util.Collection) IgnoreFilters(net.ripe.rpki.validator3.domain.IgnoreFilters) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Stream(java.util.stream.Stream) BgpSecAssertions(net.ripe.rpki.validator3.domain.BgpSecAssertions) IgnoreFiltersPredicate(net.ripe.rpki.validator3.domain.IgnoreFiltersPredicate) Settings(net.ripe.rpki.validator3.domain.Settings) ResponseEntity(org.springframework.http.ResponseEntity) ApiResponse(net.ripe.rpki.validator3.api.ApiResponse) Collections(java.util.Collections) ApiModelProperty(io.swagger.annotations.ApiModelProperty) IgnoreFiltersPredicate(net.ripe.rpki.validator3.domain.IgnoreFiltersPredicate) Links(org.springframework.hateoas.Links) Asn(net.ripe.ipresource.Asn) TrustAnchorResource(net.ripe.rpki.validator3.api.trustanchors.TrustAnchorResource) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with BgpSecAssertions

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());
}
Also used : SlurmPrefixAssertion(net.ripe.rpki.validator3.api.slurm.dtos.SlurmPrefixAssertion) Slurm(net.ripe.rpki.validator3.api.slurm.dtos.Slurm) SlurmBgpSecFilter(net.ripe.rpki.validator3.api.slurm.dtos.SlurmBgpSecFilter) SlurmPrefixFilter(net.ripe.rpki.validator3.api.slurm.dtos.SlurmPrefixFilter) SlurmBgpSecAssertion(net.ripe.rpki.validator3.api.slurm.dtos.SlurmBgpSecAssertion) Test(org.junit.Test)

Aggregations

ApiModelProperty (io.swagger.annotations.ApiModelProperty)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Value (lombok.Value)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Asn (net.ripe.ipresource.Asn)1 IpRange (net.ripe.ipresource.IpRange)1 Api (net.ripe.rpki.validator3.api.Api)1 ApiResponse (net.ripe.rpki.validator3.api.ApiResponse)1 BgpSecFilterService (net.ripe.rpki.validator3.api.bgpsec.BgpSecFilterService)1 Slurm (net.ripe.rpki.validator3.api.slurm.dtos.Slurm)1 SlurmBgpSecAssertion (net.ripe.rpki.validator3.api.slurm.dtos.SlurmBgpSecAssertion)1 SlurmBgpSecFilter (net.ripe.rpki.validator3.api.slurm.dtos.SlurmBgpSecFilter)1 SlurmPrefixAssertion (net.ripe.rpki.validator3.api.slurm.dtos.SlurmPrefixAssertion)1 SlurmPrefixFilter (net.ripe.rpki.validator3.api.slurm.dtos.SlurmPrefixFilter)1