From d56471edba382637bfe543aa661f7891bf6f1d8f Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Mon, 23 May 2011 15:48:32 -0400 Subject: [PATCH] INT-1909 added support for injecting JschSession with Properties configuration (e.g., session.setConfig(Properties) ) --- .../sftp/session/DefaultSftpSessionFactory.java | 13 ++++++++++++- ...oundChannelAdapterParserCachingTests-context.xml | 4 ++++ .../InboundChannelAdapterParserCachingTests.java | 8 +++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java index 94c278e264..61a132d1dd 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java @@ -16,6 +16,8 @@ package org.springframework.integration.sftp.session; +import java.util.Properties; + import org.springframework.core.io.Resource; import org.springframework.integration.file.remote.session.Session; import org.springframework.integration.file.remote.session.SessionFactory; @@ -48,11 +50,13 @@ public class DefaultSftpSessionFactory implements SessionFactory { private volatile Resource privateKey; private volatile String privateKeyPassphrase; + + private volatile Properties sessionConfig; private final JSch jsch = new JSch(); - public void setHost(String host) { + public void setHost(String host) { this.host = host; } @@ -79,6 +83,10 @@ public class DefaultSftpSessionFactory implements SessionFactory { public void setPrivateKeyPassphrase(String privateKeyPassphrase) { this.privateKeyPassphrase = privateKeyPassphrase; } + + public void setSessionConfig(Properties sessionConfig) { + this.sessionConfig = sessionConfig; + } public Session getSession() { Assert.hasText(this.host, "host must not be empty"); @@ -118,6 +126,9 @@ public class DefaultSftpSessionFactory implements SessionFactory { } } com.jcraft.jsch.Session jschSession = this.jsch.getSession(this.user, this.host, this.port); + if (this.sessionConfig != null){ + jschSession.setConfig(this.sessionConfig); + } if (StringUtils.hasText(this.password)) { jschSession.setPassword(this.password); } diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml index 8492d66259..fa3bbaa51e 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml @@ -29,8 +29,12 @@ + + + no +