Author: davsclaus Date: Wed Oct 5 06:29:55 2011 New Revision: 1179060 URL: http://svn.apache.org/viewvc?rev=1179060&view=rev Log: CAMEL-4506: sftp component supports interactive keyboard mode by returning the password. Thanks to Eugene for the patch.
Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java?rev=1179060&r1=1179059&r2=1179060&view=diff ============================================================================== --- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java (original) +++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java Wed Oct 5 06:29:55 2011 @@ -32,6 +32,7 @@ import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import com.jcraft.jsch.SftpException; +import com.jcraft.jsch.UIKeyboardInteractive; import com.jcraft.jsch.UserInfo; import org.apache.camel.Exchange; import org.apache.camel.InvalidPayloadException; @@ -58,6 +59,12 @@ public class SftpOperations implements R private ChannelSftp channel; private Session session; + /** + * Extended user info which supports interactive keyboard mode, by entering the password. + */ + public static interface ExtendedUserInfo extends UserInfo, UIKeyboardInteractive { + } + public void setEndpoint(GenericFileEndpoint endpoint) { this.endpoint = (SftpEndpoint) endpoint; } @@ -173,7 +180,7 @@ public class SftpOperations implements R session.setServerAliveCountMax(sftpConfig.getServerAliveCountMax()); // set user information - session.setUserInfo(new UserInfo() { + session.setUserInfo(new ExtendedUserInfo() { public String getPassphrase() { return null; } @@ -199,6 +206,12 @@ public class SftpOperations implements R public void showMessage(String s) { LOG.trace("Message received from Server: " + s); } + + public String[] promptKeyboardInteractive(String destination, String name, + String instruction, String[] prompt, boolean[] echo) { + return new String[]{configuration.getPassword()}; + } + }); return session; }