You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2011/10/01 09:09:34 UTC
Re: The SFTP component: the keyboard-interactive auth method support
On Fri, Sep 30, 2011 at 6:35 PM, Hadrian Zbarcea <hz...@gmail.com> wrote:
> One more aspect Claus should have mentioned is that we cannot accept
> contributions with dependencies on non-approved licenses [1]. From what I
> see jzlib is licensed under LGPL [2].
>
Ah yeah.
See step 2 at the components developer guide.
http://camel.apache.org/add-new-component-guide.html
> Regards,
> Hadrian
> VP, Apache Camel
>
> [1] http://www.apache.org/legal/resolved.html#category-x
> [2] http://www.jcraft.com/jzlib/LICENSE.txt
>
>
> On 09/30/2011 04:03 AM, Claus Ibsen wrote:
>>
>> Hi
>>
>> Thanks for sharing this.
>>
>> Do you mind creating a JIRA ticket and attach your code as a file to
>> the JIRA, and mark [x] in grant license to Apache.
>> That's the procedure for us to accept patches from the community.
>>
>> You can read more here
>> http://camel.apache.org/contributing.html
>>
>> And a link to JIRA is herre
>> http://camel.apache.org/support.html
>>
>>
>> On Thu, Sep 29, 2011 at 5:18 PM, Ujeen<uj...@ujeen.com> wrote:
>>>
>>> Hi Camel gurus.
>>>
>>> I've got some small improvement for the SFTP component which probably
>>> might
>>> be handy.
>>>
>>> It appeared that our sftp share we get files from doesn't support the ssh
>>> password auth method and we're not allowed to put the public key to
>>> there.
>>> So the only ssh auth method we can use is the keyboard-interactive.
>>> Unfortunately the SFTP camel component doesn't support this.
>>> However this can be easily fixed simply by providing the Jsch session
>>> with
>>> both the com.jcraft.jsch.UserInfo and
>>> com.jcraft.jsch.UIKeyboardInteractive
>>> interfaces. The UIKeyboardInteractive has the only one
>>> promptKeyboardInteractive method which returns String[] containing the
>>> password entered by user interactively. In our case I simply return a
>>> password.
>>> Here is how I implemented this:
>>>
>>> SftpOperations operations = new SftpOperations() {
>>> protected Session createSession(final RemoteFileConfiguration
>>> configuration) throws JSchException {
>>> final Session result = super.createSession(configuration);
>>> if(compression> 0&& compression< 10) {
>>> result.setConfig("compression.s2c",
>>> "zlib@openssh.com,zlib,none");
>>> result.setConfig("compression.c2s",
>>> "zlib@openssh.com,zlib,none");
>>> result.setConfig("compression_level",
>>> Integer.toString(compression));
>>> }
>>> final UserInfo userInfo = result.getUserInfo();
>>> result.setUserInfo(new ExtendedUserInfo() {
>>> public String getPassphrase() {return
>>> userInfo.getPassphrase();}
>>> public String getPassword() {return
>>> userInfo.getPassword();}
>>> public boolean promptPassword(String s) {return
>>> userInfo.promptPassword(s);}
>>> public boolean promptPassphrase(String s) {return
>>> userInfo.promptPassphrase(s);}
>>> public boolean promptYesNo(String s) {return
>>> userInfo.promptYesNo(s); }
>>> public void showMessage(String s)
>>> {userInfo.showMessage(s);}
>>> public String[] promptKeyboardInteractive(
>>> String destination, String name,
>>> String instruction, String[] prompt,
>>> boolean[] echo) {
>>> return new String[] { this.getPassword() };
>>> }
>>> });
>>> return result;
>>> }};
>>>
>>>
>>> Also as you could note I set the compression level there. Since we're
>>> moving
>>> really huge files (2G and longer) via sftp I thought that setting the ssh
>>> compression might be a good idea. It really helps. I pass them via
>>> endpoint's uri. This requires the zlib kib to be in the classpath
>>> <dependency>
>>> <groupId>com.jcraft</groupId>
>>> <artifactId>jzlib</artifactId>
>>> <version>1.0.7</version>
>>> </dependency>
>>>
>>> That's it. I hope this is useful for you. Sorry if it's not.
>>>
>>> Thanks for the Camel.
>>>
>>>
>>> --
>>> View this message in context:
>>> http://camel.465427.n5.nabble.com/The-SFTP-component-the-keyboard-interactive-auth-method-support-tp4853523p4853523.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/