@Test public void testFetchTrustAnchorCertificate_reject_http() throws Exception { given(trustAnchorRetrievalService.fetchTrustAnchorCertificate(any(), any())).willCallRealMethod(); final URI uri = URI.create("http: trustAnchorRetrievalService.fetchTrustAnchorCertificate(uri, validationResult); final List<ValidationCheck> validationChecks = validationResult.getAllValidationChecksForCurrentLocation(); assertThat(validationChecks).hasSize(1); assertThat(validationChecks.get(0).getKey()).isEqualTo(ErrorCodes.TRUST_ANCHOR_FETCH); }
public byte[] fetchTrustAnchorCertificate(URI trustAnchorCertificateURI, ValidationResult validationResult) { try { switch (trustAnchorCertificateURI.getScheme()) { case "rsync": return fetchRsyncTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); case "https": return fetchHttpsTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); case "file": return fetchFileTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); default: validationResult.warn(ErrorCodes.TRUST_ANCHOR_FETCH, trustAnchorCertificateURI.toASCIIString(), "Unsupported URI"); return null; } } catch (IOException e) { validationResult.warn(ErrorCodes.TRUST_ANCHOR_FETCH, trustAnchorCertificateURI.toASCIIString(), e.getMessage()); return null; } }
TrustAnchorRetrievalService { public byte[] fetchTrustAnchorCertificate(URI trustAnchorCertificateURI, ValidationResult validationResult) { try { switch (trustAnchorCertificateURI.getScheme()) { case "rsync": return fetchRsyncTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); case "https": return fetchHttpsTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); case "file": return fetchFileTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); default: validationResult.warn(ErrorCodes.TRUST_ANCHOR_FETCH, trustAnchorCertificateURI.toASCIIString(), "Unsupported URI"); return null; } } catch (IOException e) { validationResult.warn(ErrorCodes.TRUST_ANCHOR_FETCH, trustAnchorCertificateURI.toASCIIString(), e.getMessage()); return null; } } }
TrustAnchorRetrievalService { public byte[] fetchTrustAnchorCertificate(URI trustAnchorCertificateURI, ValidationResult validationResult) { try { switch (trustAnchorCertificateURI.getScheme()) { case "rsync": return fetchRsyncTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); case "https": return fetchHttpsTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); case "file": return fetchFileTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); default: validationResult.warn(ErrorCodes.TRUST_ANCHOR_FETCH, trustAnchorCertificateURI.toASCIIString(), "Unsupported URI"); return null; } } catch (IOException e) { validationResult.warn(ErrorCodes.TRUST_ANCHOR_FETCH, trustAnchorCertificateURI.toASCIIString(), e.getMessage()); return null; } }  }
TrustAnchorRetrievalService { public byte[] fetchTrustAnchorCertificate(URI trustAnchorCertificateURI, ValidationResult validationResult) { try { switch (trustAnchorCertificateURI.getScheme()) { case "rsync": return fetchRsyncTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); case "https": return fetchHttpsTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); case "file": return fetchFileTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); default: validationResult.warn(ErrorCodes.TRUST_ANCHOR_FETCH, trustAnchorCertificateURI.toASCIIString(), "Unsupported URI"); return null; } } catch (IOException e) { validationResult.warn(ErrorCodes.TRUST_ANCHOR_FETCH, trustAnchorCertificateURI.toASCIIString(), e.getMessage()); return null; } }  byte[] fetchTrustAnchorCertificate(URI trustAnchorCertificateURI, ValidationResult validationResult); }
TrustAnchorRetrievalService { public byte[] fetchTrustAnchorCertificate(URI trustAnchorCertificateURI, ValidationResult validationResult) { try { switch (trustAnchorCertificateURI.getScheme()) { case "rsync": return fetchRsyncTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); case "https": return fetchHttpsTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); case "file": return fetchFileTrustAnchorCertificate(trustAnchorCertificateURI, validationResult); default: validationResult.warn(ErrorCodes.TRUST_ANCHOR_FETCH, trustAnchorCertificateURI.toASCIIString(), "Unsupported URI"); return null; } } catch (IOException e) { validationResult.warn(ErrorCodes.TRUST_ANCHOR_FETCH, trustAnchorCertificateURI.toASCIIString(), e.getMessage()); return null; } }  byte[] fetchTrustAnchorCertificate(URI trustAnchorCertificateURI, ValidationResult validationResult);  }