secureProtocol = FTPUploadTaskParameters.DEFAULT_SECURE_SOCKET_PROTOCOL; ftpClient = new FTPSClient(secureProtocol, ftpParams.implicitSecurity);
@Override protected FTPSClient createClientInstance() { try { if (StringUtils.hasText(this.protocol)) { return new FTPSClient(this.protocol, this.implicit); } return new FTPSClient(this.implicit); } catch (Exception e) { /* This catch block is technically not necessary but it allows users to use the older Commons Net 2.0 if necessary, which requires you to catch a NoSuchAlgorithmException. */ if (e instanceof RuntimeException) { //NOSONAR false positive throw (RuntimeException) e; } throw new RuntimeException("Failed to create FTPS client.", e); } }
public FTPSNetworkClient(final String host, final int port){ client = new FTPSClient(); this.host = host; this.port = port; this.username = "anonymous"; this.password = ""; }
public FTPSNetworkClient(final String host, final int port, final String userName, final String password){ client = new FTPSClient(); this.host = host; this.port = port; this.username = userName; this.password = password; }
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(null, null); KeyManager km = kmf.getKeyManagers()[0]; ftpsClient = new FTPSClient("SSL"); ftpsClient.setKeyManager(km);
private FTPClient createClientInstance() { if(this.isFtps) { if(this.getProtocol() != null) { return new FTPSClient(this.protocol, this.implicit); } return new FTPSClient(this.implicit); } return new FTPClient(); }
private FTPClient createClientInstance() { if(this.isFtps) { if(this.getProtocol() != null) { return new FTPSClient(this.protocol, this.implicit); } return new FTPSClient(this.implicit); } return new FTPClient(); }
SSLContext sslContext = SSLContext.getInstance("TLS"); TrustManager tm = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers() { return null; } }; sslContext.init(null, new TrustManager[] { tm }, null); FTPSClient ftpsClient = new FTPSClient(sslContext);
public FTPSSource(boolean securityMode, String protocolSec, boolean securityCert, String pathTokeystore, String storePass) { this.securityMode = securityMode; this.protocolSec = protocolSec; this.securityCert = securityCert; ftpsClient = new FTPSClient(protocolSec); this.pathTokesytore = pathTokeystore; this.storePass = storePass; checkIfCertificate(); }
@Override protected FTPClient createClient() { LOG.debug( "Creating secure FTP client. Protocol: [{}], implicit mode: [{}], endpoint checking: [{}].", securityProtocol, implicit, endpointChecking ); FTPSClient client = new FTPSClient( securityProtocol, implicit ); client.setEndpointCheckingEnabled( endpointChecking ); return client; } }
SSLContext sslContext = SSLContext.getInstance("SSL"); TrustManager tm = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers() { return null; } }; sslContext.init(null, new TrustManager[] { tm }, null); FTPSClient ftpClient = new FTPSClient(sslContext);
@Override protected FTPClient createClient() { LOG.debug( "Creating secure FTP client. Protocol: [{}], implicit mode: [{}], endpoint checking: [{}].", securityProtocol, implicit, endpointChecking ); FTPSClient client = new FTPSClient( securityProtocol, implicit ); client.setEndpointCheckingEnabled( endpointChecking ); return client; } }
FTPSClient mFtps = new FTPSClient(); mFtps.setTrustManager(TrustManagerUtils.getAcceptAllTrustManager());
FTPSClient ftpClient = new FTPSClient(); ftpClient.connect(host); ftpClient.login(user, password);
@Override protected FTPSClient createClient(final FileSystemOptions fileSystemOptions) throws FileSystemException { final FTPSClient client; if (builder.getFtpsMode(fileSystemOptions) == FtpsMode.IMPLICIT) { client = new FTPSClient(true); } else { client = new FTPSClient(); } final TrustManager trustManager = builder.getTrustManager(fileSystemOptions); if (trustManager != null) { client.setTrustManager(trustManager); } final KeyManager keyManager = builder.getKeyManager(fileSystemOptions); if (keyManager != null) { client.setKeyManager(keyManager); } return client; }
@Override protected FTPSClient createClient(final FileSystemOptions fileSystemOptions) throws FileSystemException { final FTPSClient client; if (builder.getFtpsMode(fileSystemOptions) == FtpsMode.IMPLICIT) { client = new FTPSClient(true); } else { client = new FTPSClient(); } final TrustManager trustManager = builder.getTrustManager(fileSystemOptions); if (trustManager != null) { client.setTrustManager(trustManager); } final KeyManager keyManager = builder.getKeyManager(fileSystemOptions); if (keyManager != null) { client.setKeyManager(keyManager); } return client; }
private FTPClient createFtpClient(FtpConfiguration configuration) { FtpConfiguration.Security security = configuration.getSecurity(); if (!security.isPresent()) { LOGGER.log(Level.FINE, "No encryption used"); ProxyInfo proxyInfo = RemoteUtils.getHttpProxy(configuration.getHost()); if (proxyInfo != null) { LOGGER.log(Level.FINE, "HTTP proxy will be used"); return new FTPHTTPClient(proxyInfo.getHost(), proxyInfo.getPort(), proxyInfo.getUsername(), proxyInfo.getPassword()); } // no proxy LOGGER.log(Level.FINE, "No proxy will be used"); return new FTPClient(); } Encryption encryption = security.getEncryption(); LOGGER.log(Level.FINE, "Used encryption {0}", encryption.name()); // can be debugged by setting -J-Djavax.net.debug=all return new FTPSClient(encryption.getProtocol(), encryption.isImplicit()); }
FTPSClient ftpClient = new FTPSClient("tls",false); ftpClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); ftpClient.connect(host, port); int reply = ftpClient.getReplyCode(); if (FTPReply.isPositiveCompletion(reply)) { ftpClient.execPBSZ(0); reply = ftpClient.getReplyCode(); // Check for PBSZ error responses... ftpClient.execPROT("P"); reply = ftpClient.getReplyCode(); // Check for PROT error responses... ftpClient.enterLocalPassiveMode();
FTPSClient l_ftp = new FTPSClient("SSL", false); l_ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); l_ftp.setAuthValue("SSL"); l_ftp.connect(l_host, l_port); if (!l_ftp.login(l_username, l_password)) { // BAD! } l_ftp.execPBSZ(0L); l_ftp.execCCC(); l_ftp.pwd(); // DO STUFF l_ftp.logout(); l_ftp.disconnect();
@Test public void testUnderlyingConnect() throws SocketException, IOException { final FTPSClient client1 = this.init(new FTPSClient(true)); final FTPSClient client2 = this.init(new FTPSClient(true)); try { final String hostname = "localhost"; client1.connect(hostname, AbstractFtpsProviderTestCase.getSocketPort()); client2.connect(hostname, AbstractFtpsProviderTestCase.getSocketPort()); } finally { if (client1 != null) { client1.disconnect(); } if (client2 != null) { client2.disconnect(); } } } }