Package nl.nn.adapterframework.ftp
Class FtpSession
- java.lang.Object
-
- nl.nn.adapterframework.ftp.FtpSession
-
- All Implemented Interfaces:
IConfigurable
,IConfigurationAware
,INamedObject
,IScopeProvider
,HasKeystore
,HasTruststore
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
FtpFileSystem
public abstract class FtpSession extends Object implements IConfigurable, HasKeystore, HasTruststore
Base class for FTP(s) connections- Author:
- John Dekker
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FtpSession.FileType
static class
FtpSession.FtpType
static class
FtpSession.Prot
static class
FtpSession.TransportType
-
Constructor Summary
Constructors Constructor Description FtpSession()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
static void
close(org.apache.commons.net.ftp.FTPClient ftpClient)
void
configure()
org.springframework.context.ApplicationContext
getApplicationContext()
String
getAuthAlias()
ClassLoader
getConfigurationClassLoader()
This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.FtpSession.FileType
getFileType()
FtpSession.FtpType
getFtpType()
String
getHost()
String
getKeyManagerAlgorithm()
String
getKeystore()
String
getKeystoreAlias()
String
getKeystoreAliasAuthAlias()
String
getKeystoreAliasPassword()
String
getKeystoreAuthAlias()
String
getKeystorePassword()
KeystoreType
getKeystoreType()
String
getName()
String
getPassword()
int
getPort()
FtpSession.Prot
getProt()
String
getProxyHost()
int
getProxyPort()
String
getTrustManagerAlgorithm()
String
getTruststore()
String
getTruststoreAuthAlias()
String
getTruststorePassword()
KeystoreType
getTruststoreType()
String
getUsername()
boolean
isAllowSelfSignedCertificates()
boolean
isIgnoreCertificateExpiredException()
boolean
isPassive()
boolean
isVerifyHostname()
org.apache.commons.net.ftp.FTPClient
openClient(String remoteDirectory)
void
setAllowSelfSignedCertificates(boolean b)
(ftps) Iftrue
, self signed certificates are acceptedvoid
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
void
setAuthAlias(String string)
Name of the alias to obtain credentials to authenticatie on remote servervoid
setFileType(FtpSession.FileType value)
void
setFtpType(FtpSession.FtpType value)
FTP protocol to usevoid
setHost(String string)
Name or ip address of remote hostvoid
setIgnoreCertificateExpiredException(boolean b)
(ftps) Iftrue
, CertificateExpiredExceptions are ignoredvoid
setKeyManagerAlgorithm(String keyManagerAlgorithm)
(ftps) Key manager algorithm.void
setKeystore(String string)
(ftps) Resource url to keystore or certificate to be used for authentication.void
setKeystoreAlias(String string)
(ftps) Alias to obtain specific certificate or key in keystorevoid
setKeystoreAliasAuthAlias(String string)
(ftps) Authentication alias to authenticate access to certificate or key indicated bykeystoreAlias
void
setKeystoreAliasPassword(String string)
(ftps) Default password to authenticate access to certificate or key indicated bykeystoreAlias
void
setKeystoreAuthAlias(String string)
(ftps) Authentication alias used to obtain keystore passwordvoid
setKeystorePassword(String string)
(ftps) Default password to access keystorevoid
setKeystoreType(KeystoreType value)
(ftps) Type of keystorevoid
setName(String name)
void
setPassive(boolean b)
Iftrue
, passive ftp is used: before data is sent, a pasv command is issued, and the connection is set up by the servervoid
setPassword(String string)
Password to authenticatie on remote servervoid
setPort(int i)
Port number of remote hostvoid
setProt(FtpSession.Prot prot)
Sets theData Channel Protection Level
.void
setProxyHost(String string)
Proxy hostnamevoid
setProxyPort(int i)
Proxy portvoid
setProxyTransportType(FtpSession.TransportType type)
(ftps) Transport type in case of sftpvoid
setTrustManagerAlgorithm(String trustManagerAlgorithm)
(ftps) Trust manager algorithm.void
setTruststore(String string)
(ftps) Resource url to truststore to be used for authenticating peer.void
setTruststoreAuthAlias(String string)
(ftps) Authentication alias used to obtain truststore passwordvoid
setTruststorePassword(String string)
(ftps) Default password to access truststorevoid
setTruststoreType(KeystoreType value)
(ftps) Type of truststorevoid
setUsername(String string)
Name of the user to authenticatie on remote servervoid
setVerifyHostname(boolean b)
(ftps) Iftrue
, the hostname in the certificate will be checked against the actual hostname of the peer
-
-
-
Method Detail
-
configure
public void configure() throws ConfigurationException
- Specified by:
configure
in interfaceIConfigurable
- Throws:
ConfigurationException
-
openClient
public org.apache.commons.net.ftp.FTPClient openClient(String remoteDirectory) throws FileSystemException
- Throws:
FileSystemException
-
close
public static void close(org.apache.commons.net.ftp.FTPClient ftpClient)
-
close
public void close()
-
setHost
public void setHost(String string)
Name or ip address of remote host
-
setPort
public void setPort(int i)
Port number of remote host- Default value
- 21
-
setAuthAlias
public void setAuthAlias(String string)
Name of the alias to obtain credentials to authenticatie on remote server
-
setUsername
public void setUsername(String string)
Name of the user to authenticatie on remote server
-
setPassword
public void setPassword(String string)
Password to authenticatie on remote server
-
setProxyHost
public void setProxyHost(String string)
Proxy hostname
-
setProxyPort
public void setProxyPort(int i)
Proxy port- Default value
- 1080
-
setFtpType
public void setFtpType(FtpSession.FtpType value)
FTP protocol to use- Default value
- FTP
-
setFileType
public void setFileType(FtpSession.FileType value)
-
setPassive
public void setPassive(boolean b)
Iftrue
, passive ftp is used: before data is sent, a pasv command is issued, and the connection is set up by the server- Default value
- true
-
setProxyTransportType
public void setProxyTransportType(FtpSession.TransportType type)
(ftps) Transport type in case of sftp- Default value
- SOCKS5
-
setKeystore
public void setKeystore(String string)
(ftps) Resource url to keystore or certificate to be used for authentication. If none specified, the JVMs default keystore will be used.- Specified by:
setKeystore
in interfaceHasKeystore
-
setKeystoreType
public void setKeystoreType(KeystoreType value)
(ftps) Type of keystore- Specified by:
setKeystoreType
in interfaceHasKeystore
- Default value
- pkcs12
-
setKeystoreAuthAlias
public void setKeystoreAuthAlias(String string)
(ftps) Authentication alias used to obtain keystore password- Specified by:
setKeystoreAuthAlias
in interfaceHasKeystore
-
setKeystorePassword
public void setKeystorePassword(String string)
(ftps) Default password to access keystore- Specified by:
setKeystorePassword
in interfaceHasKeystore
-
setKeyManagerAlgorithm
public void setKeyManagerAlgorithm(String keyManagerAlgorithm)
(ftps) Key manager algorithm. Can be left empty to use the servers default algorithm- Specified by:
setKeyManagerAlgorithm
in interfaceHasKeystore
-
setKeystoreAlias
public void setKeystoreAlias(String string)
(ftps) Alias to obtain specific certificate or key in keystore- Specified by:
setKeystoreAlias
in interfaceHasKeystore
-
setKeystoreAliasAuthAlias
public void setKeystoreAliasAuthAlias(String string)
(ftps) Authentication alias to authenticate access to certificate or key indicated bykeystoreAlias
- Specified by:
setKeystoreAliasAuthAlias
in interfaceHasKeystore
-
setKeystoreAliasPassword
public void setKeystoreAliasPassword(String string)
(ftps) Default password to authenticate access to certificate or key indicated bykeystoreAlias
- Specified by:
setKeystoreAliasPassword
in interfaceHasKeystore
-
setTruststore
public void setTruststore(String string)
(ftps) Resource url to truststore to be used for authenticating peer. If none specified, the JVMs default truststore will be used.- Specified by:
setTruststore
in interfaceHasTruststore
-
setTruststoreType
public void setTruststoreType(KeystoreType value)
(ftps) Type of truststore- Specified by:
setTruststoreType
in interfaceHasTruststore
- Default value
- jks
-
setTruststoreAuthAlias
public void setTruststoreAuthAlias(String string)
(ftps) Authentication alias used to obtain truststore password- Specified by:
setTruststoreAuthAlias
in interfaceHasTruststore
-
setTruststorePassword
public void setTruststorePassword(String string)
(ftps) Default password to access truststore- Specified by:
setTruststorePassword
in interfaceHasTruststore
-
setTrustManagerAlgorithm
public void setTrustManagerAlgorithm(String trustManagerAlgorithm)
(ftps) Trust manager algorithm. Can be left empty to use the servers default algorithm- Specified by:
setTrustManagerAlgorithm
in interfaceHasTruststore
-
setVerifyHostname
public void setVerifyHostname(boolean b)
(ftps) Iftrue
, the hostname in the certificate will be checked against the actual hostname of the peer- Specified by:
setVerifyHostname
in interfaceHasTruststore
-
setAllowSelfSignedCertificates
public void setAllowSelfSignedCertificates(boolean b)
(ftps) Iftrue
, self signed certificates are accepted- Specified by:
setAllowSelfSignedCertificates
in interfaceHasTruststore
- Default value
- false
-
setIgnoreCertificateExpiredException
public void setIgnoreCertificateExpiredException(boolean b)
(ftps) Iftrue
, CertificateExpiredExceptions are ignored- Specified by:
setIgnoreCertificateExpiredException
in interfaceHasTruststore
- Default value
- false
-
setProt
public void setProt(FtpSession.Prot prot)
Sets theData Channel Protection Level
.- Default value
- C
-
setName
public void setName(String name)
- Specified by:
setName
in interfaceINamedObject
-
getConfigurationClassLoader
public ClassLoader getConfigurationClassLoader()
Description copied from interface:IScopeProvider
This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.- Specified by:
getConfigurationClassLoader
in interfaceIScopeProvider
- Returns:
- returns the ClassLoader created by the
ClassLoaderManager
.
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext()
- Specified by:
getApplicationContext
in interfaceIConfigurationAware
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
getFtpType
public FtpSession.FtpType getFtpType()
-
getProt
public FtpSession.Prot getProt()
-
getName
public String getName()
- Specified by:
getName
in interfaceIConfigurationAware
- Specified by:
getName
in interfaceINamedObject
-
getHost
public String getHost()
-
getPort
public int getPort()
-
getAuthAlias
public String getAuthAlias()
-
getUsername
public String getUsername()
-
getPassword
public String getPassword()
-
getProxyHost
public String getProxyHost()
-
getProxyPort
public int getProxyPort()
-
getFileType
public FtpSession.FileType getFileType()
-
isPassive
public boolean isPassive()
-
getKeystore
public String getKeystore()
- Specified by:
getKeystore
in interfaceHasKeystore
-
getKeystoreAuthAlias
public String getKeystoreAuthAlias()
- Specified by:
getKeystoreAuthAlias
in interfaceHasKeystore
-
getKeystorePassword
public String getKeystorePassword()
- Specified by:
getKeystorePassword
in interfaceHasKeystore
-
getKeystoreType
public KeystoreType getKeystoreType()
- Specified by:
getKeystoreType
in interfaceHasKeystore
-
getKeystoreAlias
public String getKeystoreAlias()
- Specified by:
getKeystoreAlias
in interfaceHasKeystore
-
getKeystoreAliasAuthAlias
public String getKeystoreAliasAuthAlias()
- Specified by:
getKeystoreAliasAuthAlias
in interfaceHasKeystore
-
getKeystoreAliasPassword
public String getKeystoreAliasPassword()
- Specified by:
getKeystoreAliasPassword
in interfaceHasKeystore
-
getKeyManagerAlgorithm
public String getKeyManagerAlgorithm()
- Specified by:
getKeyManagerAlgorithm
in interfaceHasKeystore
-
getTruststore
public String getTruststore()
- Specified by:
getTruststore
in interfaceHasTruststore
-
getTruststoreType
public KeystoreType getTruststoreType()
- Specified by:
getTruststoreType
in interfaceHasTruststore
-
getTruststoreAuthAlias
public String getTruststoreAuthAlias()
- Specified by:
getTruststoreAuthAlias
in interfaceHasTruststore
-
getTruststorePassword
public String getTruststorePassword()
- Specified by:
getTruststorePassword
in interfaceHasTruststore
-
getTrustManagerAlgorithm
public String getTrustManagerAlgorithm()
- Specified by:
getTrustManagerAlgorithm
in interfaceHasTruststore
-
isVerifyHostname
public boolean isVerifyHostname()
- Specified by:
isVerifyHostname
in interfaceHasTruststore
-
isAllowSelfSignedCertificates
public boolean isAllowSelfSignedCertificates()
- Specified by:
isAllowSelfSignedCertificates
in interfaceHasTruststore
-
isIgnoreCertificateExpiredException
public boolean isIgnoreCertificateExpiredException()
- Specified by:
isIgnoreCertificateExpiredException
in interfaceHasTruststore
-
-