@Test public void testGenerateWhiteListFileNoParentDirectory() throws IOException, CertificateException { Path anotherFile = Paths.get("anotherFileInRootDir"); trustManager = new TrustOnFirstUseManager(anotherFile); when(certificate.getEncoded()).thenReturn("certificate".getBytes(UTF_8)); X500Principal cn = new X500Principal("CN=localhost"); when(certificate.getSubjectX500Principal()).thenReturn(cn); assertThat(Files.exists(anotherFile)).isFalse(); trustManager.checkServerTrusted(new X509Certificate[]{certificate}, "str"); assertThat(Files.exists(anotherFile)).isTrue(); verify(certificate).getEncoded(); verify(certificate).getSubjectX500Principal(); Files.deleteIfExists(anotherFile); assertThat(Files.exists(anotherFile)).isFalse(); }
@Override public void checkServerTrusted(X509Certificate[] serverCertificates, String authType) throws CertificateException { checkTrusted(serverCertificates); }
TrustOnFirstUseManager extends AbstractTrustManager { @Override public void checkServerTrusted(X509Certificate[] serverCertificates, String authType) throws CertificateException { checkTrusted(serverCertificates); } }
TrustOnFirstUseManager extends AbstractTrustManager { @Override public void checkServerTrusted(X509Certificate[] serverCertificates, String authType) throws CertificateException { checkTrusted(serverCertificates); } TrustOnFirstUseManager(Path knownHosts); }
TrustOnFirstUseManager extends AbstractTrustManager { @Override public void checkServerTrusted(X509Certificate[] serverCertificates, String authType) throws CertificateException { checkTrusted(serverCertificates); } TrustOnFirstUseManager(Path knownHosts); @Override void checkClientTrusted(X509Certificate[] clientCertificates, String authType); @Override void checkServerTrusted(X509Certificate[] serverCertificates, String authType); @Override X509Certificate[] getAcceptedIssuers(); }
TrustOnFirstUseManager extends AbstractTrustManager { @Override public void checkServerTrusted(X509Certificate[] serverCertificates, String authType) throws CertificateException { checkTrusted(serverCertificates); } TrustOnFirstUseManager(Path knownHosts); @Override void checkClientTrusted(X509Certificate[] clientCertificates, String authType); @Override void checkServerTrusted(X509Certificate[] serverCertificates, String authType); @Override X509Certificate[] getAcceptedIssuers();  }