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 <[email protected]> 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", > "[email protected],zlib,none"); > result.setConfig("compression.c2s", > "[email protected],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: [email protected] Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
