Class ApacheSshdSftpSessionFactory
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.sftp.spring.integration.ApacheSshdSftpSessionFactory
- All Implemented Interfaces:
SimpleClientConfigurator
,BasicCredentialsProvider
,MutableBasicCredentials
,MutablePassword
,MutableUserHolder
,PasswordHolder
,UsernameHolder
,org.apache.sshd.common.config.keys.FilePasswordProviderHolder
,org.apache.sshd.common.config.keys.FilePasswordProviderManager
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
,org.springframework.integration.file.remote.session.SessionFactory<SftpClient.DirEntry>
,org.springframework.integration.file.remote.session.SharedSessionCapable
public class ApacheSshdSftpSessionFactory
extends org.apache.sshd.common.util.logging.AbstractLoggingBean
implements org.springframework.integration.file.remote.session.SessionFactory<SftpClient.DirEntry>, org.springframework.integration.file.remote.session.SharedSessionCapable, MutableBasicCredentials, org.apache.sshd.common.config.keys.FilePasswordProviderManager, SimpleClientConfigurator, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
A proper replacement for the
org.springframework.integration.sftp.session.DefaultSftpSessionFactory
- Author:
- Apache MINA SSHD Project
-
Field Summary
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
Fields inherited from interface org.apache.sshd.client.simple.SimpleClientConfigurator
DEFAULT_AUTHENTICATION_TIMEOUT, DEFAULT_CONNECT_TIMEOUT, DEFAULT_PORT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected ClientSession
authenticateClientSession
(ClientSession session, long timeout) protected ClientSession
configureClientSessionProperties
(ClientSession session, Properties props) protected ClientSession
protected ClientSession
createClientSession
(String hostname, String username, int port, long timeout) protected SshClient
void
destroy()
long
long
protected long
getEffectiveTimeoutValue
(long timeoutSeconds) org.apache.sshd.common.config.keys.FilePasswordProvider
getHost()
int
getPort()
org.springframework.core.io.Resource
org.springframework.integration.file.remote.session.Session
<SftpClient.DirEntry> protected ClientSession
boolean
protected KeyPair
loadPrivateKey
(ClientSession session, org.springframework.core.io.Resource keyResource, String keyPassword) void
protected ClientSession
resolveClientSession
(boolean sharedInstance) protected org.apache.sshd.common.config.keys.FilePasswordProvider
resolveFilePasswordProvider
(ClientSession session, org.springframework.core.io.Resource keyResource, String keyPassword) protected KeyPair
resolveKeyIdentity
(ClientSession session) void
setAuthenticationTimeout
(long timeout) void
setConnectTimeout
(long timeout) void
setFilePasswordProvider
(org.apache.sshd.common.config.keys.FilePasswordProvider provider) void
void
setPassword
(String password) The password to authenticate against the remote host.void
setPort
(int port) The port over which the SFTP connection shall be established.void
setPrivateKeyLocation
(org.springframework.core.io.Resource privateKey) Allows you to set aResource
, which represents the location of the private key used for authenticating against the remote host.void
setPrivateKeyPair
(KeyPair privateKeyPair) void
setPrivateKeyPassphrase
(String privateKeyPassphrase) void
setSessionConfig
(Properties sessionConfig) void
setSftpVersion
(String version) void
setSftpVersionSelector
(SftpVersionSelector selector) void
setSshClient
(SshClient sshClient) void
setUsername
(String user) The remote user to use.Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Constructor Details
-
ApacheSshdSftpSessionFactory
public ApacheSshdSftpSessionFactory() -
ApacheSshdSftpSessionFactory
public ApacheSshdSftpSessionFactory(boolean sharedSession)
-
-
Method Details
-
getHost
-
setHost
- Parameters:
host
- The host to connect to - this is a mandatory property.
-
getPort
public int getPort() -
setPort
public void setPort(int port) The port over which the SFTP connection shall be established. If not specified, this value defaults to22
. If specified, this property must be a positive number.- Parameters:
port
- The port value
-
getUsername
- Specified by:
getUsername
in interfaceUsernameHolder
-
setUsername
The remote user to use. This is a mandatory property.- Specified by:
setUsername
in interfaceMutableUserHolder
- Parameters:
user
- The (nevernull
/empty) username
-
getPassword
- Specified by:
getPassword
in interfacePasswordHolder
-
setPassword
The password to authenticate against the remote host. If a password is not provided, then asetPrivateKeyLocation(Resource)
call is mandatory.- Specified by:
setPassword
in interfaceMutablePassword
- Parameters:
password
- The password to use - ifnull
then no password is set - in which case thegetPrivateKeyLocation()
resource is used
-
getPrivateKeyLocation
public org.springframework.core.io.Resource getPrivateKeyLocation() -
setPrivateKeyLocation
public void setPrivateKeyLocation(org.springframework.core.io.Resource privateKey) Allows you to set aResource
, which represents the location of the private key used for authenticating against the remote host. If the privateKey is not provided, then thesetPassword(String)
call is mandatory- Parameters:
privateKey
- The private keyResource
-
getPrivateKeyPassphrase
-
setPrivateKeyPassphrase
- Parameters:
privateKeyPassphrase
- The password for the private key - required if the private key resource is encrypted
-
getFilePasswordProvider
public org.apache.sshd.common.config.keys.FilePasswordProvider getFilePasswordProvider()- Specified by:
getFilePasswordProvider
in interfaceorg.apache.sshd.common.config.keys.FilePasswordProviderHolder
-
setFilePasswordProvider
public void setFilePasswordProvider(org.apache.sshd.common.config.keys.FilePasswordProvider provider) - Specified by:
setFilePasswordProvider
in interfaceorg.apache.sshd.common.config.keys.FilePasswordProviderManager
-
getPrivateKeyPair
-
setPrivateKeyPair
-
getConnectTimeout
public long getConnectTimeout()- Specified by:
getConnectTimeout
in interfaceSimpleClientConfigurator
-
setConnectTimeout
public void setConnectTimeout(long timeout) - Specified by:
setConnectTimeout
in interfaceSimpleClientConfigurator
-
getAuthenticationTimeout
public long getAuthenticationTimeout()- Specified by:
getAuthenticationTimeout
in interfaceSimpleClientConfigurator
-
setAuthenticationTimeout
public void setAuthenticationTimeout(long timeout) - Specified by:
setAuthenticationTimeout
in interfaceSimpleClientConfigurator
-
getSessionConfig
-
setSessionConfig
- Parameters:
sessionConfig
- ExtraProperties
that can be used to set specific SSHD session properties
-
getSshClient
-
setSshClient
-
getSftpVersionSelector
-
setSftpVersion
-
setSftpVersionSelector
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
createSshClientInstance
- Throws:
Exception
-
destroy
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
-
resolveKeyIdentity
protected KeyPair resolveKeyIdentity(ClientSession session) throws IOException, GeneralSecurityException - Throws:
IOException
GeneralSecurityException
-
resolveFilePasswordProvider
protected org.apache.sshd.common.config.keys.FilePasswordProvider resolveFilePasswordProvider(ClientSession session, org.springframework.core.io.Resource keyResource, String keyPassword) -
loadPrivateKey
protected KeyPair loadPrivateKey(ClientSession session, org.springframework.core.io.Resource keyResource, String keyPassword) throws IOException, GeneralSecurityException - Throws:
IOException
GeneralSecurityException
-
getSession
public org.springframework.integration.file.remote.session.Session<SftpClient.DirEntry> getSession()- Specified by:
getSession
in interfaceorg.springframework.integration.file.remote.session.SessionFactory<SftpClient.DirEntry>
-
resolveClientSession
- Throws:
Exception
-
createClientSession
- Throws:
Exception
-
createClientSession
protected ClientSession createClientSession(String hostname, String username, int port, long timeout) throws IOException - Throws:
IOException
-
configureClientSessionProperties
protected ClientSession configureClientSessionProperties(ClientSession session, Properties props) throws IOException - Throws:
IOException
-
authenticateClientSession
protected ClientSession authenticateClientSession(ClientSession session, long timeout) throws IOException, GeneralSecurityException - Throws:
IOException
GeneralSecurityException
-
getEffectiveTimeoutValue
protected long getEffectiveTimeoutValue(long timeoutSeconds)
-