List of usage examples for javax.net.ssl SSLSocket setSSLParameters
public void setSSLParameters(SSLParameters params)
From source file:com.vmware.bdd.security.tls.SimpleSeverTrustTlsSocketFactory.java
/** * Wrap a socket to enable custom configuration(ciphers and protocols) to be * supported for the connection/* w w w . j av a 2 s . c om*/ * * @param sock a socket created by the * {@link SSLSocketFactory#createSocket() method} * @return a wrapped socket which has the client specified configuration */ private Socket wrapSocket(Socket sock) { SSLSocket sslSock = (SSLSocket) sock; sslSock.setSSLParameters(sslParams); try { sslSock.setSoTimeout(30000); } catch (SocketException e) { // } return sslSock; }
From source file:com.predic8.membrane.core.transport.ssl.SSLContext.java
public void applyCiphers(SSLSocket sslSocket) { if (ciphers != null) { SSLParameters sslParameters = sslSocket.getSSLParameters(); applyCipherOrdering(sslParameters); sslParameters.setCipherSuites(ciphers); sslSocket.setSSLParameters(sslParameters); }//from ww w . j a v a 2 s . c om }
From source file:com.microsoft.tfs.core.config.httpclient.internal.DefaultSSLProtocolSocketFactory.java
private void configureSNI(final Socket socket, final String host) { if (System.getProperty("java.version").compareTo("1.8") < 0) { //$NON-NLS-1$ //$NON-NLS-2$ return;//from www . j av a2 s. c om } /* * Classes used to configure Server Name client-hello extension were * introduced in Java 8. So, we neither can use nor compile this code * using Java 6-7. Thus, let's use reflection. */ try { final SSLSocket sslSocket = (SSLSocket) socket; final SSLParameters params = sslSocket.getSSLParameters(); final Class<?> sniHostNameClass = Class.forName("javax.net.ssl.SNIHostName"); //$NON-NLS-1$ final Constructor<?> sniHostNameClassConstructor = sniHostNameClass.getConstructor(String.class); final Object serverName = sniHostNameClassConstructor.newInstance(host); final List<Object> serverNames = new ArrayList<Object>(1); serverNames.add(serverName); final Class<?> paramsClass = params.getClass(); final Method setServerNames = paramsClass.getMethod("setServerNames", List.class); //$NON-NLS-1$ setServerNames.invoke(params, serverNames); sslSocket.setSSLParameters(params); } catch (final Exception e) { log.error("Eror configuring SSL socket with SNI cipher extension:", e); //$NON-NLS-1$ } }
From source file:org.alfresco.repo.security.authentication.ldap.AlfrescoLdapSSLSocketFactory.java
private void addHostNameVerification(SSLSocket sslSocket) { if (useJava6CodeBase == null || useJava6CodeBase) { //Try to use SSLSocketImpl.trySetHostnameVerification method that is supported by java6 and lower try {/* w ww .j a v a 2 s . c o m*/ Method m = sslSocket.getClass().getMethod("trySetHostnameVerification", String.class); m.invoke(sslSocket, "LDAP"); useJava6CodeBase = true; useJava7CodeBase = false; } catch (Throwable e) { useJava6CodeBase = false; } } if (useJava7CodeBase == null || useJava7CodeBase) { //Try to use sslParams.setEndpointIdentificationAlgorithm method that is supported by java 7 and higher try { SSLParameters sslParams = new SSLParameters(); Method m = sslParams.getClass().getMethod("setEndpointIdentificationAlgorithm", String.class); m.invoke(sslParams, "LDAPS"); sslSocket.setSSLParameters(sslParams); useJava6CodeBase = false; useJava7CodeBase = true; } catch (Throwable ee) { useJava7CodeBase = false; if (useJava6CodeBase == false && logger.isWarnEnabled()) { logger.warn("AlfrescoLdapSSLSocketFactory: Unable to turn on Hostname Verification"); } } } }