From ee77b52fd97bd7394abeb30c71c444063a58bbd5 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Thu, 16 Feb 2012 11:22:04 -0500 Subject: [PATCH] INT-2442 SFTP Authentication - Backport Fixed DefaultSftpSessionFactory#OptimisticUserInfoImpl to additionally implement UIKeyboardInteractive, tested with both right and wrong password. Cherry pick; fix copyright. --- .../sftp/session/DefaultSftpSessionFactory.java | 10 ++++++++-- .../sftp/config/SftpOutboundTransferSample-ignored.xml | 5 +++-- 2 files changed, 11 insertions(+), 4 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 6a356d9467..60e012dea9 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 @@ -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; + } } } diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/SftpOutboundTransferSample-ignored.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/SftpOutboundTransferSample-ignored.xml index ddceff2aac..358e1aa705 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/SftpOutboundTransferSample-ignored.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/SftpOutboundTransferSample-ignored.xml @@ -10,10 +10,11 @@ - - + + +