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 theorg.springframework.integration.sftp.session.DefaultSftpSessionFactory- Author:
- Apache MINA SSHD Project
-
-
Field Summary
-
Fields inherited from interface org.apache.sshd.client.simple.SimpleClientConfigurator
DEFAULT_AUTHENTICATION_TIMEOUT, DEFAULT_CONNECT_TIMEOUT, DEFAULT_PORT
-
-
Constructor Summary
Constructors Constructor Description ApacheSshdSftpSessionFactory()ApacheSshdSftpSessionFactory(boolean sharedSession)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()protected ClientSessionauthenticateClientSession(ClientSession session, long timeout)protected ClientSessionconfigureClientSessionProperties(ClientSession session, Properties props)protected ClientSessioncreateClientSession()protected ClientSessioncreateClientSession(String hostname, String username, int port, long timeout)protected SshClientcreateSshClientInstance()voiddestroy()longgetAuthenticationTimeout()longgetConnectTimeout()protected longgetEffectiveTimeoutValue(long timeoutSeconds)org.apache.sshd.common.config.keys.FilePasswordProvidergetFilePasswordProvider()StringgetHost()StringgetPassword()intgetPort()org.springframework.core.io.ResourcegetPrivateKeyLocation()KeyPairgetPrivateKeyPair()StringgetPrivateKeyPassphrase()org.springframework.integration.file.remote.session.Session<SftpClient.DirEntry>getSession()PropertiesgetSessionConfig()SftpVersionSelectorgetSftpVersionSelector()protected ClientSessiongetSharedClientSession()SshClientgetSshClient()StringgetUsername()booleanisSharedSession()protected KeyPairloadPrivateKey(ClientSession session, org.springframework.core.io.Resource keyResource, String keyPassword)voidresetSharedSession()protected 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)voidsetHost(String host)voidsetPassword(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.
-
-
-
Method Detail
-
getHost
public String getHost()
-
setHost
public void setHost(String host)
- 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
public String getUsername()
- Specified by:
getUsernamein interfaceUsernameHolder
-
setUsername
public void setUsername(String user)
The remote user to use. This is a mandatory property.- Specified by:
setUsernamein interfaceMutableUserHolder- Parameters:
user- The (nevernull/empty) username
-
getPassword
public String getPassword()
- Specified by:
getPasswordin interfacePasswordHolder
-
setPassword
public void setPassword(String password)
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
public String getPrivateKeyPassphrase()
-
setPrivateKeyPassphrase
public void setPrivateKeyPassphrase(String privateKeyPassphrase)
- 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
public KeyPair getPrivateKeyPair()
-
setPrivateKeyPair
public void setPrivateKeyPair(KeyPair privateKeyPair)
-
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
public Properties getSessionConfig()
-
setSessionConfig
public void setSessionConfig(Properties sessionConfig)
- Parameters:
sessionConfig- ExtraPropertiesthat can be used to set specific SSHD session properties
-
getSshClient
public SshClient getSshClient()
-
setSshClient
public void setSshClient(SshClient sshClient)
-
isSharedSession
public boolean isSharedSession()
- Specified by:
isSharedSessionin interfaceorg.springframework.integration.file.remote.session.SharedSessionCapable
-
getSftpVersionSelector
public SftpVersionSelector getSftpVersionSelector()
-
setSftpVersion
public void setSftpVersion(String version)
-
setSftpVersionSelector
public void setSftpVersionSelector(SftpVersionSelector selector)
-
getSharedClientSession
protected ClientSession getSharedClientSession()
-
resetSharedSession
public void resetSharedSession()
- Specified by:
resetSharedSessionin interfaceorg.springframework.integration.file.remote.session.SharedSessionCapable
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
createSshClientInstance
protected SshClient createSshClientInstance() throws Exception
- Throws:
Exception
-
destroy
public void destroy() throws Exception- 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
protected ClientSession resolveClientSession(boolean sharedInstance) throws Exception
- Throws:
Exception
-
createClientSession
protected ClientSession createClientSession() throws Exception
- 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)
-
-