INT-2442 SFTP Authentication - Backport

Fixed DefaultSftpSessionFactory#OptimisticUserInfoImpl to additionally implement UIKeyboardInteractive, tested with both right and wrong password.

Cherry pick; fix copyright.
This commit is contained in:
Oleg Zhurakousky
2012-02-16 11:22:04 -05:00
committed by Gary Russell
parent 37c7e3c2c6
commit ee77b52fd9
2 changed files with 11 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import org.springframework.util.StringUtils;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Proxy;
import com.jcraft.jsch.SocketFactory;
import com.jcraft.jsch.UIKeyboardInteractive;
import com.jcraft.jsch.UserInfo;
/**
@@ -224,7 +225,7 @@ public class DefaultSftpSessionFactory implements SessionFactory {
* It returns in the positive where possible and handles interactive authentication
* (i.e. 'Please enter your password: ' prompts are dispatched automatically).
*/
private static class OptimisticUserInfoImpl implements UserInfo {
private static class OptimisticUserInfoImpl implements UserInfo, UIKeyboardInteractive {
private final String password;
@@ -254,6 +255,11 @@ public class DefaultSftpSessionFactory implements SessionFactory {
public void showMessage(String string) {
}
public String[] promptKeyboardInteractive(String destination,
String name, String instruction, String[] prompt, boolean[] echo) {
return null;
}
}
}

View File

@@ -10,10 +10,11 @@
<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="localhost"/>
<property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftp_rsa"/>
<property name="privateKeyPassphrase" value="springintegration"/>
<!-- <property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftp_rsa"/> -->
<!-- <property name="privateKeyPassphrase" value="springintegration"/> -->
<property name="port" value="22"/>
<property name="user" value="ozhurakousky"/>
<property name="password" value="password"/>
</bean>
<int:channel id="ftpChannel"/>