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
logFields inherited from interface org.apache.sshd.client.simple.SimpleClientConfigurator
DEFAULT_AUTHENTICATION_TIMEOUT, DEFAULT_CONNECT_TIMEOUT, DEFAULT_PORT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected ClientSessionauthenticateClientSession(ClientSession session, long timeout) protected ClientSessionconfigureClientSessionProperties(ClientSession session, Properties props) protected ClientSessionprotected ClientSessioncreateClientSession(String hostname, String username, int port, long timeout) protected SshClientvoiddestroy()longlongprotected longgetEffectiveTimeoutValue(long timeoutSeconds) org.apache.sshd.common.config.keys.FilePasswordProvidergetHost()intgetPort()org.springframework.core.io.Resourceorg.springframework.integration.file.remote.session.Session<SftpClient.DirEntry>protected ClientSessionbooleanprotected KeyPairloadPrivateKey(ClientSession session, org.springframework.core.io.Resource keyResource, String keyPassword) voidprotected ClientSessionresolveClientSession(boolean sharedInstance) protected org.apache.sshd.common.config.keys.FilePasswordProviderresolveFilePasswordProvider(ClientSession session, org.springframework.core.io.Resource keyResource, String keyPassword) protected KeyPairresolveKeyIdentity(ClientSession session) voidsetAuthenticationTimeout(long timeout) voidsetConnectTimeout(long timeout) voidsetFilePasswordProvider(org.apache.sshd.common.config.keys.FilePasswordProvider provider) voidvoidsetPassword(String password) The password to authenticate against the remote host.voidsetPort(int port) The port over which the SFTP connection shall be established.voidsetPrivateKeyLocation(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.voidsetPrivateKeyPair(KeyPair privateKeyPair) voidsetPrivateKeyPassphrase(String privateKeyPassphrase) voidsetSessionConfig(Properties sessionConfig) voidsetSftpVersion(String version) voidsetSftpVersionSelector(SftpVersionSelector selector) voidsetSshClient(SshClient sshClient) voidsetUsername(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:
getUsernamein interfaceUsernameHolder
-
setUsername
The remote user to use. This is a mandatory property.- Specified by:
setUsernamein interfaceMutableUserHolder- Parameters:
user- The (nevernull/empty) username
-
getPassword
- Specified by:
getPasswordin interfacePasswordHolder
-
setPassword
The password to authenticate against the remote host. If a password is not provided, then asetPrivateKeyLocation(Resource)call is mandatory.- Specified by:
setPasswordin interfaceMutablePassword- Parameters:
password- The password to use - ifnullthen 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:
getFilePasswordProviderin interfaceorg.apache.sshd.common.config.keys.FilePasswordProviderHolder
-
setFilePasswordProvider
public void setFilePasswordProvider(org.apache.sshd.common.config.keys.FilePasswordProvider provider) - Specified by:
setFilePasswordProviderin interfaceorg.apache.sshd.common.config.keys.FilePasswordProviderManager
-
getPrivateKeyPair
-
setPrivateKeyPair
-
getConnectTimeout
public long getConnectTimeout()- Specified by:
getConnectTimeoutin interfaceSimpleClientConfigurator
-
setConnectTimeout
public void setConnectTimeout(long timeout) - Specified by:
setConnectTimeoutin interfaceSimpleClientConfigurator
-
getAuthenticationTimeout
public long getAuthenticationTimeout()- Specified by:
getAuthenticationTimeoutin interfaceSimpleClientConfigurator
-
setAuthenticationTimeout
public void setAuthenticationTimeout(long timeout) - Specified by:
setAuthenticationTimeoutin interfaceSimpleClientConfigurator
-
getSessionConfig
-
setSessionConfig
- Parameters:
sessionConfig- ExtraPropertiesthat can be used to set specific SSHD session properties
-
getSshClient
-
setSshClient
-
getSftpVersionSelector
-
setSftpVersion
-
setSftpVersionSelector
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
createSshClientInstance
- Throws:
Exception
-
destroy
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception
-
resolveKeyIdentity
protected KeyPair resolveKeyIdentity(ClientSession session) throws IOException, GeneralSecurityException - Throws:
IOExceptionGeneralSecurityException
-
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:
IOExceptionGeneralSecurityException
-
getSession
public org.springframework.integration.file.remote.session.Session<SftpClient.DirEntry> getSession()- Specified by:
getSessionin 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:
IOExceptionGeneralSecurityException
-
getEffectiveTimeoutValue
protected long getEffectiveTimeoutValue(long timeoutSeconds)
-