Mohammad Kargar created CAMEL-5242:
--------------------------------------

             Summary: camel-jsch (a.k.a camel-scp) component doesn't support 
public-private key based authentication
                 Key: CAMEL-5242
                 URL: https://issues.apache.org/jira/browse/CAMEL-5242
             Project: Camel
          Issue Type: Improvement
          Components: camel-jsch
    Affects Versions: Future
            Reporter: Mohammad Kargar


Camel uses JSCH (http://www.jcraft.com/jsch/) library to support both SCP and 
SFTP. This library supports public-private key based authentication using 
com.jcraft.jsch.JSch.addIdentity method. However looks like Camel only supports 
this feature for SFTP component (http://camel.apache.org/ftp2.html) and there 
is no support for SCP (http://camel.apache.org/jsch.html)!

Taking into account the fact that 
org.apache.camel.component.jsch.ScpConfiguration (version 2.9.2) already has 
two attributes (privateKeyFile and privateKeyFilePassphrase) for collecting the 
related data, I think the change for this improvement should be something like :

 org.apache.camel.component.jsch.ScpOperations.createSession(ScpConfiguration 
config) {
        ObjectHelper.notNull(config, "ScpConfiguration");
        try {
            final JSch jsch = new JSch();
            // get from configuration
            if (isNotEmpty(config.getCiphers())) {
                LOG.debug("Using ciphers: {}", config.getCiphers());
                Hashtable<String, String> ciphers = new Hashtable<String, 
String>();
                ciphers.put("cipher.s2c", config.getCiphers());
                ciphers.put("cipher.c2s", config.getCiphers());
                JSch.setConfig(ciphers);
            }
            //New code to handle public-private key based authentication
            if (isNotEmpty(config.getPrivateKeyFile())) {
               LOG.debug("Using private keyfile: {}", 
config.getPrivateKeyFile());
               if (isNotEmpty(config.getPrivateKeyFilePassphrase())) {
                   jsch.addIdentity(config.getPrivateKeyFile(), 
config.getPrivateKeyFilePassphrase());
               } else {
                   jsch.addIdentity(config.getPrivateKeyFile());
               }
           }

        ...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to