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 FileTransferConnection
SFTP 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 boolean
acceptProtocol(java.lang.String s)
Validate the URL Protocol when a URL is used.protected FileTransferClient
create(java.lang.String remoteHost, int port, FileTransferConnection.UserInfo ui)
Create an instance of theFileTransferClient
for use with the producer or consumer.protected FileTransferConnection.UserInfo
createUserInfo()
int
defaultControlPort()
SftpAuthenticationProvider
getAuthentication()
ConfigBuilder
getConfiguration()
java.lang.String
getKnownHostsFile()
TimeInterval
getSocketTimeout()
protected void
initConnection()
Initialise the underlying connection.void
setAuthentication(SftpAuthenticationProvider p)
void
setConfiguration(ConfigBuilder repo)
Set the config repository.void
setKnownHostsFile(java.lang.String k)
void
setSocketTimeout(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:FileTransferConnection
Validate the URL Protocol when a URL is used.- Specified by:
acceptProtocol
in 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:FileTransferConnection
Create an instance of theFileTransferClient
for use with the producer or consumer.- Specified by:
create
in classFileTransferConnection
- Parameters:
remoteHost
- the remote host.port
- the port to connect toui
- a local UserInfo containing username and password- Returns:
- a
FileTransferClient
object - Throws:
java.io.IOException
- wrapping a general comms error.FileTransferException
- if a protocol specific exception occurred.PasswordException
-
initConnection
protected void initConnection() throws CoreException
Description copied from class:AdaptrisConnectionImp
Initialise the underlying connection.- Overrides:
initConnection
in 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:
createUserInfo
in classFileTransferConnection
- Throws:
FileTransferException
-
getKnownHostsFile
public java.lang.String getKnownHostsFile()
-
setKnownHostsFile
public void setKnownHostsFile(java.lang.String k)
-
defaultControlPort
public int defaultControlPort()
- Specified by:
defaultControlPort
in 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
PreferredAuthentications
orServerAliveInterval
.- 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
-
-