TrustAnchorLocator { public static TrustAnchorLocator fromFile(File file) throws TrustAnchorExtractorException { try { String contents = Files.toString(file, Charsets.UTF_8); String trimmed = contents.trim(); if (looksLikeUri(trimmed)) { return readStandardTrustAnchorLocator(file.getName(), trimmed); } else { return readExtendedTrustAnchorLocator(trimmed); } } catch (IllegalArgumentException | URISyntaxException | IOException e) { throw new TrustAnchorExtractorException("failed to load trust anchor locator " + file + ": " + e.getMessage(), e); } } TrustAnchorLocator(String caName, List<URI> location, String publicKeyInfo, List<URI> prefetchUris); static TrustAnchorLocator fromMultipartFile(MultipartFile file); static TrustAnchorLocator fromFile(File file); String getCaName(); List<URI> getCertificateLocations(); String getPublicKeyInfo(); List<URI> getPrefetchUris(); URI getFetchedCertificateUri(); void setFetchedCertificateUri(URI fetchedCertificateUri);  }
@Test public void readStandardTrustAnchor_with_http_location_rejected() throws Exception { File talFile = new ClassPathResource("tals/rfc8630/example-tal-with-http-and-rsync.tal").getFile(); assertThrows(TrustAnchorExtractorException.class, () -> TrustAnchorLocator.fromFile(talFile)); }
@Test public void readExtendedTrustAnchor_with_http_location_rejected() throws Exception { File talFile = new ClassPathResource("tals/ripeextended/example-tal-with-http-and-rsync.tal").getFile(); assertThrows(TrustAnchorExtractorException.class, () -> TrustAnchorLocator.fromFile(talFile)); }