@Test public void testCertificatesNotInWhiteList() throws CertificateException { when(certificate.getEncoded()).thenReturn("some-other-thumbprint".getBytes(UTF_8)); try { trustManager.checkClientTrusted(new X509Certificate[]{certificate}, "str"); failBecauseExceptionWasNotThrown(Exception.class); } catch (Exception ex){ assertThat(ex) .isInstanceOf(CertificateException.class) .hasMessage("Connections not allowed"); } verify(certificate, times(2)).getEncoded(); verify(certificate).getSubjectX500Principal(); }
@Override public void checkClientTrusted(X509Certificate[] clientCertificates, String authType) throws CertificateException { checkTrusted(clientCertificates); }
WhiteListTrustManager extends AbstractTrustManager { @Override public void checkClientTrusted(X509Certificate[] clientCertificates, String authType) throws CertificateException { checkTrusted(clientCertificates); } }
WhiteListTrustManager extends AbstractTrustManager { @Override public void checkClientTrusted(X509Certificate[] clientCertificates, String authType) throws CertificateException { checkTrusted(clientCertificates); } WhiteListTrustManager(Path knownHosts); }
WhiteListTrustManager extends AbstractTrustManager { @Override public void checkClientTrusted(X509Certificate[] clientCertificates, String authType) throws CertificateException { checkTrusted(clientCertificates); } WhiteListTrustManager(Path knownHosts); @Override void checkClientTrusted(X509Certificate[] clientCertificates, String authType); @Override void checkServerTrusted(X509Certificate[] serverCertificates, String authType); @Override X509Certificate[] getAcceptedIssuers(); }
WhiteListTrustManager extends AbstractTrustManager { @Override public void checkClientTrusted(X509Certificate[] clientCertificates, String authType) throws CertificateException { checkTrusted(clientCertificates); } WhiteListTrustManager(Path knownHosts); @Override void checkClientTrusted(X509Certificate[] clientCertificates, String authType); @Override void checkServerTrusted(X509Certificate[] serverCertificates, String authType); @Override X509Certificate[] getAcceptedIssuers();  }