Example usage for javax.net.ssl SSLSocket setEnableSessionCreation

List of usage examples for javax.net.ssl SSLSocket setEnableSessionCreation

Introduction

In this page you can find the example usage for javax.net.ssl SSLSocket setEnableSessionCreation.

Prototype

public abstract void setEnableSessionCreation(boolean flag);

Source Link

Document

Controls whether new SSL sessions may be established by this socket.

Usage

From source file:com.myJava.file.driver.remote.ftp.FTPSClient.java

protected Socket _openDataConnection_(int command, String arg) throws IOException {
    SSLSocket socket = (SSLSocket) super._openDataConnection_(command, arg);
    if (socket != null) {
        socket.setEnableSessionCreation(true);
        socket.setUseClientMode(true);// ww  w  . jav  a 2  s.c o  m
        socket.startHandshake();
    }
    return socket;
}

From source file:com.myJava.file.driver.remote.ftp.SecuredSocketFactory.java

private void init(SSLSocket socket) throws IOException {
    socket.setEnableSessionCreation(true);
    socket.setUseClientMode(true);/*from   w  w w  . ja v a 2  s .com*/
    socket.startHandshake();
    client.setNegociated();
}

From source file:ch.cyberduck.core.ftp.FTPClient.java

@Override
protected void sslNegotiation() throws IOException {
    if (protocol.isSecure()) {
        final SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(_socket_,
                _socket_.getInetAddress().getHostAddress(), _socket_.getPort(), false);
        socket.setEnableSessionCreation(true);
        socket.setUseClientMode(true);/*from  w w  w .  j  ava  2s .c  o m*/
        socket.startHandshake();
        _socket_ = socket;
        _controlInput_ = new BufferedReader(
                new InputStreamReader(socket.getInputStream(), getControlEncoding()));
        _controlOutput_ = new BufferedWriter(
                new OutputStreamWriter(socket.getOutputStream(), getControlEncoding()));
    }
}

From source file:org.apache.geode.internal.net.SocketCreator.java

/**
 * When a socket is accepted from a server socket, it should be passed to this method for SSL
 * configuration.//from w  ww  .ja  v  a 2  s  . c om
 */
private void configureClientSSLSocket(Socket socket, int timeout) throws IOException {
    if (socket instanceof SSLSocket) {
        SSLSocket sslSocket = (SSLSocket) socket;

        sslSocket.setUseClientMode(true);
        sslSocket.setEnableSessionCreation(true);

        String[] protocols = this.sslConfig.getProtocolsAsStringArray();

        // restrict cyphers
        if (protocols != null && !"any".equalsIgnoreCase(protocols[0])) {
            sslSocket.setEnabledProtocols(protocols);
        }
        String[] ciphers = this.sslConfig.getCiphersAsStringArray();
        if (ciphers != null && !"any".equalsIgnoreCase(ciphers[0])) {
            sslSocket.setEnabledCipherSuites(ciphers);
        }

        try {
            if (timeout > 0) {
                sslSocket.setSoTimeout(timeout);
            }
            sslSocket.startHandshake();
            SSLSession session = sslSocket.getSession();
            Certificate[] peer = session.getPeerCertificates();
            if (logger.isDebugEnabled()) {
                logger.debug(LocalizedMessage.create(LocalizedStrings.SocketCreator_SSL_CONNECTION_FROM_PEER_0,
                        ((X509Certificate) peer[0]).getSubjectDN()));
            }
        } catch (SSLHandshakeException ex) {
            logger.fatal(
                    LocalizedMessage.create(LocalizedStrings.SocketCreator_SSL_ERROR_IN_CONNECTING_TO_PEER_0_1,
                            new Object[] { socket.getInetAddress(), Integer.valueOf(socket.getPort()) }),
                    ex);
            throw ex;
        } catch (SSLPeerUnverifiedException ex) {
            if (this.sslConfig.isRequireAuth()) {
                logger.fatal(LocalizedMessage
                        .create(LocalizedStrings.SocketCreator_SSL_ERROR_IN_AUTHENTICATING_PEER), ex);
                throw ex;
            }
        } catch (SSLException ex) {
            logger.fatal(
                    LocalizedMessage.create(LocalizedStrings.SocketCreator_SSL_ERROR_IN_CONNECTING_TO_PEER_0_1,
                            new Object[] { socket.getInetAddress(), Integer.valueOf(socket.getPort()) }),
                    ex);
            throw ex;
        }

    }
}