[ 
https://issues.apache.org/jira/browse/IVY-660?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maarten Coene updated IVY-660:
------------------------------

    Fix Version/s:     (was: 2.0.0-beta-1)

> SFTP authorization fail during publishing via sftp.
> ---------------------------------------------------
>
>                 Key: IVY-660
>                 URL: https://issues.apache.org/jira/browse/IVY-660
>             Project: Ivy
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-beta-1
>         Environment: Developer: Windows XP, jdk1.6.0_02, ant-1.7.0, 
> jsch-0.1.36
> SFTP Server: FreeBSD-6.2-RELEASE.
>            Reporter: Alexey Kiselev
>            Priority: Minor
>
> PROBLEM:
> We defined two resolvers in a settings file:
>       <resolvers>
>               <sftp name="remote1">
>                       <ivy pattern="sftp://user:[EMAIL 
> PROTECTED]:12345/repository/[module]/[module]-[revision].xml"/>
>                       <artifact pattern="sftp://user:[EMAIL 
> PROTECTED]:12345/repository/[module]/[artifact]-[revision].[ext]"/>
>               </sftp>
>               <sftp name="remote2" host="host" port="12345" user="user" 
> userPassword="password">
>                       <ivy 
> pattern="repository/[module]/[module]-[revision].xml"/>
>                       <artifact 
> pattern="repository/[module]/[artifact]-[revision].[ext]"/>
>               </sftp>
>       </resolvers>
> Then we tried to publish our artifacts 
> <ivy:publish resolver="remote1" pubrevision="1.2.3.4" overwrite="true" 
> artifactspattern="${basedir}/files/[artifact].[ext]" />
> or 
> <ivy:publish resolver="remote2" pubrevision="1.2.3.4" overwrite="true" 
> artifactspattern="${basedir}/files/[artifact].[ext]" />
> As a result we had received java.io.IOException with message "Auth fail".
> SOLUTION:
> Our solution is to implement interface com.jcraft.jsch.UIKeyboardInteractive 
> in class CfUserInfo in file SshCache.java. Patch had been attached below.
> {code}Index: SshCache.java
> ===================================================================
> --- SshCache.java     (revision 601711)
> +++ SshCache.java     (working copy)
> @@ -36,6 +36,7 @@
>  import com.jcraft.jsch.JSchException;
>  import com.jcraft.jsch.Session;
>  import com.jcraft.jsch.UserInfo;
> +import com.jcraft.jsch.UIKeyboardInteractive;
>  
>  /**
>   * a class to cache SSH Connections and Channel for the SSH Repository each 
> session is defined by
> @@ -341,7 +342,7 @@
>      /**
>       * feeds in password silently into JSch
>       */
> -    private static class CfUserInfo implements UserInfo {
> +    private static class CfUserInfo implements UserInfo, 
> UIKeyboardInteractive {
>  
>          private String userPassword;
>  
> @@ -404,5 +405,28 @@
>              }
>              return pemPassword;
>          }
> +             /**
> +             * Implementation of 
> UIKeyboardInteractive#promptKeyboardInteractive.
> +             * @param destination not used.
> +             * @param name        not used.
> +             * @param instruction not used.
> +             * @param prompt      the method checks if this is one in length.
> +             * @param echo        the method checks if the first element is 
> false.
> +              * @return the password in an size one array if there is a 
> password
> +              *         and if the prompt and echo checks pass.
> +              */
> +             public String[] promptKeyboardInteractive(String destination,
> +                                                                             
>                   String name,
> +                                                                             
>                   String instruction,
> +                                                                             
>                   String[] prompt,
> +                                                                             
>                   boolean[] echo) {
> +                     if (prompt.length != 1 || echo[0] || this.userPassword 
> == null) {
> +                             return null;
> +                     }
> +                     String[] response = new String[1];
> +                     response[0] = this.userPassword;
> +                     
> +                     return response;
> +             }
>      }
>  }{code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to