List of usage examples for org.apache.commons.net.ftp FTPSClient setConnectTimeout
public void setConnectTimeout(int connectTimeout)
From source file:com.logic.test.FTPSLogic.java
public static void main(String[] args) { String serverAdress = "62.2.176.167"; String username = "RLSFTPRead"; String password = "ftp4rls"; int port = 990; FTPSClient ftpsClient = new FTPSClient("TLS", true); String remoteFile = "REM - Persons Extract.csv"; File localFile = new File("Persons Extract.csv"); try {//w w w . j a v a 2s. co m TrustManager[] trustManager = new TrustManager[] { new X509TrustManager() { @Override public X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted(X509Certificate[] certs, String authType) { } @Override public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; ftpsClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); //ftpsClient.setTrustManager(trustManager[0]); //KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); //kmf.init(null, null); //KeyManager km = kmf.getKeyManagers()[0]; //ftpsClient.setKeyManager(km); ftpsClient.setBufferSize(1024 * 1024); ftpsClient.setConnectTimeout(100000); ftpsClient.connect(InetAddress.getByName(serverAdress), port); ftpsClient.setSoTimeout(100000); if (ftpsClient.login(username, password)) { ftpsClient.execPBSZ(0); ftpsClient.execPROT("P"); ftpsClient.changeWorkingDirectory("/"); ftpsClient.setFileType(FTP.BINARY_FILE_TYPE); ftpsClient.enterLocalPassiveMode(); //ftpsClient.retrieveFile(remoteFile, new FileOutputStream(localFile)); for (FTPFile file : ftpsClient.listFiles()) { System.out.println("Nom " + file.getName()); } } } catch (SocketException e) { ; } catch (UnknownHostException e) { ; } catch (IOException e) { ; } catch (Exception e) { ; } finally { try { ftpsClient.logout(); } catch (Exception e2) { } try { ftpsClient.disconnect(); } catch (Exception e2) { } } }
From source file:org.apache.camel.component.file.remote.FtpsEndpoint.java
@Override public RemoteFileOperations<FTPFile> createRemoteFileOperations() throws Exception { // configure ftp client FTPSClient client = getFtpsClient(); if (client == null) { // must use a new client if not explicit configured to use a custom client client = (FTPSClient) createFtpClient(); }/* ww w . ja va 2 s. c om*/ // set any endpoint configured timeouts if (getConfiguration().getConnectTimeout() > -1) { client.setConnectTimeout(getConfiguration().getConnectTimeout()); } if (getConfiguration().getSoTimeout() > -1) { soTimeout = getConfiguration().getSoTimeout(); } dataTimeout = getConfiguration().getTimeout(); if (ftpClientParameters != null) { Map<String, Object> localParameters = new HashMap<String, Object>(ftpClientParameters); // setting soTimeout has to be done later on FTPClient (after it has connected) Object timeout = localParameters.remove("soTimeout"); if (timeout != null) { soTimeout = getCamelContext().getTypeConverter().convertTo(int.class, timeout); } // and we want to keep data timeout so we can log it later timeout = localParameters.remove("dataTimeout"); if (timeout != null) { dataTimeout = getCamelContext().getTypeConverter().convertTo(int.class, dataTimeout); } setProperties(client, localParameters); } if (ftpClientConfigParameters != null) { // client config is optional so create a new one if we have parameter for it if (ftpClientConfig == null) { ftpClientConfig = new FTPClientConfig(); } Map<String, Object> localConfigParameters = new HashMap<String, Object>(ftpClientConfigParameters); setProperties(ftpClientConfig, localConfigParameters); } if (dataTimeout > 0) { client.setDataTimeout(dataTimeout); } if (log.isDebugEnabled()) { log.debug("Created FTPSClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}]: {}", new Object[] { client.getConnectTimeout(), getSoTimeout(), dataTimeout, client }); } FtpsOperations operations = new FtpsOperations(client, getFtpClientConfig()); operations.setEndpoint(this); return operations; }
From source file:org.mule.transport.ftps.FtpsConnectionFactory.java
protected FTPSClient createFTPSClient() throws NoSuchAlgorithmException { FTPSClient FTPSClient = new FTPSClient(); FTPSClient.setConnectTimeout(connectionTimeout); return FTPSClient; }