Example usage for org.apache.commons.net.ftp FTPSClient setSocketFactory

List of usage examples for org.apache.commons.net.ftp FTPSClient setSocketFactory

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPSClient setSocketFactory.

Prototype

public void setSocketFactory(SocketFactory factory) 

Source Link

Document

Sets the SocketFactory used by the SocketClient to open socket connections.

Usage

From source file:org.apache.ftpserver.ssl.MinaImplicitDataChannelTest.java

private void secureClientDataConnection() throws NoSuchAlgorithmException, KeyManagementException {

    // FTPSClient does not support implicit data connections, so we hack it ourselves
    FTPSClient sclient = (FTPSClient) client;
    SSLContext context = SSLContext.getInstance("TLS");

    // these are the same key and trust managers that we initialize the client with
    context.init(new KeyManager[] { clientKeyManager }, new TrustManager[] { clientTrustManager }, null);
    sclient.setSocketFactory(new FTPSSocketFactory(context));
    SSLServerSocketFactory ssf = context.getServerSocketFactory();
    sclient.setServerSocketFactory(ssf);

    // FTPClient should not use SSL secured sockets for the data connection 
}