Package com.adaptris.core.ftp
Class StandardSftpConnection
- java.lang.Object
-
- com.adaptris.core.AdaptrisConnectionImp
-
- com.adaptris.core.NoOpConnection
-
- com.adaptris.core.ftp.FileTransferConnection
-
- com.adaptris.core.ftp.StandardSftpConnection
-
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisConnection,ComponentLifecycle,ComponentLifecycleExtension,StateManagedComponent
@ComponentProfile(summary="Connect to a server using the SSH File Transfer Protocol; authentication via a configured authentication provider", tag="connections,sftp") public class StandardSftpConnection extends FileTransferConnectionSFTP Connection class that connects via a configurableSftpAuthenticationProvider.- Since:
- 3.6.0
In the adapter configuration file this class is aliased as standard-sftp-connection which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.ftp.FileTransferConnection
FileTransferConnection.UserInfo
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ftp.FileTransferConnection
DEFAULT_EXPIRATION, DEFAULT_MAX_CACHE_SIZE
-
Fields inherited from class com.adaptris.core.AdaptrisConnectionImp
log
-
-
Constructor Summary
Constructors Constructor Description StandardSftpConnection()StandardSftpConnection(ConfigBuilder config, SftpAuthenticationProvider prov)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanacceptProtocol(java.lang.String s)Validate the URL Protocol when a URL is used.protected FileTransferClientcreate(java.lang.String remoteHost, int port, FileTransferConnection.UserInfo ui)Create an instance of theFileTransferClientfor use with the producer or consumer.protected FileTransferConnection.UserInfocreateUserInfo()intdefaultControlPort()SftpAuthenticationProvidergetAuthentication()ConfigBuildergetConfiguration()java.lang.StringgetKnownHostsFile()TimeIntervalgetSocketTimeout()protected voidinitConnection()Initialise the underlying connection.voidsetAuthentication(SftpAuthenticationProvider p)voidsetConfiguration(ConfigBuilder repo)Set the config repository.voidsetKnownHostsFile(java.lang.String k)voidsetSocketTimeout(TimeInterval t)The socket timeout in milliseconds for connect / read /write operations.-
Methods inherited from class com.adaptris.core.ftp.FileTransferConnection
additionalDebug, cacheConnection, closeConnection, connect, disconnect, expirationMillis, forceRelativePath, getAdditionalDebug, getCacheConnection, getCacheExpiration, getDefaultControlPort, getDefaultUserName, getDirectoryRoot, getForceRelativePath, getMaxClientCacheSize, getWindowsWorkAround, maxClientCacheSize, setAdditionalDebug, setCacheConnection, setCacheExpiration, setDefaultControlPort, setDefaultUserName, setForceRelativePath, setMaxClientCache, setWindowsWorkAround, windowsWorkaround, withCacheExpiration
-
Methods inherited from class com.adaptris.core.NoOpConnection
prepareConnection, startConnection, stopConnection
-
Methods inherited from class com.adaptris.core.AdaptrisConnectionImp
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, cloneForTesting, close, connectionErrorHandler, getConnectionErrorHandler, getUniqueId, getWorkersFirstOnShutdown, init, prepare, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setUniqueId, setWorkersFirstOnShutdown, start, stop, workersFirstOnShutdown
-
-
-
-
Constructor Detail
-
StandardSftpConnection
public StandardSftpConnection()
-
StandardSftpConnection
public StandardSftpConnection(ConfigBuilder config, SftpAuthenticationProvider prov)
-
-
Method Detail
-
acceptProtocol
protected boolean acceptProtocol(java.lang.String s)
Description copied from class:FileTransferConnectionValidate the URL Protocol when a URL is used.- Specified by:
acceptProtocolin classFileTransferConnection- Parameters:
s- the URL Protocol- Returns:
- true if the URL protocol is acceptable to the concrete imp.
-
create
protected FileTransferClient create(java.lang.String remoteHost, int port, FileTransferConnection.UserInfo ui) throws java.io.IOException, FileTransferException, PasswordException
Description copied from class:FileTransferConnectionCreate an instance of theFileTransferClientfor use with the producer or consumer.- Specified by:
createin classFileTransferConnection- Parameters:
remoteHost- the remote host.port- the port to connect toui- a local UserInfo containing username and password- Returns:
- a
FileTransferClientobject - Throws:
java.io.IOException- wrapping a general comms error.FileTransferException- if a protocol specific exception occurred.PasswordException
-
initConnection
protected void initConnection() throws CoreExceptionDescription copied from class:AdaptrisConnectionImpInitialise the underlying connection.- Overrides:
initConnectionin classFileTransferConnection- Throws:
CoreException- wrapping any exception.- See Also:
NoOpConnection.initConnection()
-
getSocketTimeout
public TimeInterval getSocketTimeout()
-
setSocketTimeout
public void setSocketTimeout(TimeInterval t)
The socket timeout in milliseconds for connect / read /write operations.- Parameters:
t- The socketTimeout to set, default is 60000
-
createUserInfo
protected FileTransferConnection.UserInfo createUserInfo() throws FileTransferException
- Specified by:
createUserInfoin classFileTransferConnection- Throws:
FileTransferException
-
getKnownHostsFile
public java.lang.String getKnownHostsFile()
-
setKnownHostsFile
public void setKnownHostsFile(java.lang.String k)
-
defaultControlPort
public int defaultControlPort()
- Specified by:
defaultControlPortin classFileTransferConnection
-
getConfiguration
public ConfigBuilder getConfiguration()
- Returns:
- the configRepository
-
setConfiguration
public void setConfiguration(ConfigBuilder repo)
Set the config repository.Use a config repository to set various SSH based settings (such as
PreferredAuthenticationsorServerAliveInterval.- Parameters:
repo- the configRepository to set
-
getAuthentication
public SftpAuthenticationProvider getAuthentication()
- Returns:
- the authProvider
-
setAuthentication
public void setAuthentication(SftpAuthenticationProvider p)
- Parameters:
p- the authProvider to set
-
-