X509Util implements Closeable, AutoCloseable { static String[] getDefaultCipherSuitesForJavaVersion(String javaVersion) { Objects.requireNonNull(javaVersion); if (javaVersion.matches("\\d+")) { LOG.debug("Using Java9+ optimized cipher suites for Java version {}", javaVersion); return DEFAULT_CIPHERS_JAVA9; } else if (javaVersion.startsWith("1.")) { LOG.debug("Using Java8 optimized cipher suites for Java version {}", javaVersion); return DEFAULT_CIPHERS_JAVA8; } else { LOG.debug("Could not parse java version {}, using Java8 optimized cipher suites", javaVersion); return DEFAULT_CIPHERS_JAVA8; } } X509Util();  X509Util(ZKConfig zkConfig); String getSslProtocolProperty(); String getSslEnabledProtocolsProperty(); String getCipherSuitesProperty(); String getSslKeystoreLocationProperty(); String getSslCipherSuitesProperty(); String getSslKeystorePasswdProperty(); String getSslKeystoreTypeProperty(); String getSslTruststoreLocationProperty(); String getSslTruststorePasswdProperty(); String getSslTruststoreTypeProperty(); String getSslHostnameVerificationEnabledProperty(); String getSslCrlEnabledProperty(); String getSslOcspEnabledProperty(); String getSslClientAuthProperty(); String getSslHandshakeDetectionTimeoutMillisProperty(); SSLContext getDefaultSSLContext(); SSLContext createSSLContext(ZKConfig config); SSLContextAndOptions getDefaultSSLContextAndOptions(); int getSslHandshakeTimeoutMillis(); SSLContextAndOptions createSSLContextAndOptions(ZKConfig config); static X509KeyManager createKeyManager(
            String keyStoreLocation,
            String keyStorePassword,
            String keyStoreTypeProp); static X509TrustManager createTrustManager(
            String trustStoreLocation,
            String trustStorePassword,
            String trustStoreTypeProp,
            boolean crlEnabled,
            boolean ocspEnabled,
            final boolean serverHostnameVerificationEnabled,
            final boolean clientHostnameVerificationEnabled); SSLSocket createSSLSocket(); SSLSocket createSSLSocket(Socket socket, byte[] pushbackBytes); SSLServerSocket createSSLServerSocket(); SSLServerSocket createSSLServerSocket(int port); void enableCertFileReloading(); @Override void close(); static final int DEFAULT_HANDSHAKE_DETECTION_TIMEOUT_MILLIS; }
@Test public void testGetDefaultCipherSuitesJava8() { String[] cipherSuites = X509Util.getDefaultCipherSuitesForJavaVersion("1.8"); Assert.assertTrue(cipherSuites[0].contains("CBC")); }
@Test public void testGetDefaultCipherSuitesJava9() { String[] cipherSuites = X509Util.getDefaultCipherSuitesForJavaVersion("9"); Assert.assertTrue(cipherSuites[0].contains("GCM")); }
@Test public void testGetDefaultCipherSuitesJava10() { String[] cipherSuites = X509Util.getDefaultCipherSuitesForJavaVersion("10"); Assert.assertTrue(cipherSuites[0].contains("GCM")); }
@Test public void testGetDefaultCipherSuitesJava11() { String[] cipherSuites = X509Util.getDefaultCipherSuitesForJavaVersion("11"); Assert.assertTrue(cipherSuites[0].contains("GCM")); }
@Test public void testGetDefaultCipherSuitesUnknownVersion() { String[] cipherSuites = X509Util.getDefaultCipherSuitesForJavaVersion("notaversion"); Assert.assertTrue(cipherSuites[0].contains("CBC")); }
@Test(expected = NullPointerException.class) public void testGetDefaultCipherSuitesNullVersion() { X509Util.getDefaultCipherSuitesForJavaVersion(null); }