Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AC3B9F3FD for ; Fri, 5 Jul 2013 14:11:53 +0000 (UTC) Received: (qmail 42663 invoked by uid 500); 5 Jul 2013 14:11:53 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 42503 invoked by uid 500); 5 Jul 2013 14:11:49 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 42373 invoked by uid 99); 5 Jul 2013 14:11:48 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Jul 2013 14:11:48 +0000 Date: Fri, 5 Jul 2013 14:11:48 +0000 (UTC) From: "Joerg Kessler (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (CAMEL-6514) SFTP: NPE if no private key file is supplied MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Joerg Kessler created CAMEL-6514: ------------------------------------ Summary: SFTP: NPE if no private key file is supplied Key: CAMEL-6514 URL: https://issues.apache.org/jira/browse/CAMEL-6514 Project: Camel Issue Type: Bug Components: camel-ftp Affects Versions: 2.10.4 Reporter: Joerg Kessler Priority: Minor Hi, a NPE is thrown if no private key file is supplied in the configuration for= SFTP. The error is Caused by: java.lang.NullPointerException: while trying to get the length o= f an array loaded from local variable 'foo' at com.jcraft.jsch.Buffer.putString(Buffer.java:59) I have analysed the code a bit and found that the problem is caused by the class SftpOperations. The method createSession sets the userInfo for= the seesion by an inline class. Here the method promptKeyboardInteractive = does not work correctly if no private key file is supplied. In that case JS= CH switches to user/pw authorization and this method is called. But since t= here is no password maintained the configation object returns NULL. The pre= sent implementation adds it to the string array causing the error in JSCH. = JSCH either wants a NULL string array or an empty string array (I have test= ed both). So the code should look e.g. as follows: public String[] promptKeyboardInteractive(String destination, S= tring name, String instruction, String[] prompt, boolean[] echo) { String password =3D configuration.getPassword(); if (password =3D=3D null) { return new String[0]; } else { return new String[] { password }; } } With that change JSCH returns Caused by: java.io.FileNotFoundException: ./data/ssh/id_rsa (No such file o= r directory) =09at java.io.FileInputStream.open(Native Method) and that is the real cause of the error=20 Best Regards, J=C3=B6rg=20 -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs For more information on JIRA, see: http://www.atlassian.com/software/jira