[resolved] tFTPConnection configuration as FTP or SFTP - possible?

Eight Stars

[resolved] tFTPConnection configuration as FTP or SFTP - possible?

Hi all,
I have a job with a tFTPConnection component which uses values for which server to connect to as dynamic content read in from a parameter file. However, I now find that some connections I are port 21 and just normal FTP, others are port 22 and SFTP.
How can I configure either the tFTPConnection component to change the SFTP Support and Authentication Method as they are not text boxes to put something like a "context.SFTPSupport"? Alternatively, if I have multiple tFTPConnection components, one for each connection style ( FTP, SFTP wth password, SFTP with public key) how can I get the other FTP components, get, put list, rename, etc. to dynamically switch between the 3 connections?
Thanks
David
Regards

David

Don't forget to give Kudos when an answer is helpful or the solution.

Accepted Solutions
One Star

Re: [resolved] tFTPConnection configuration as FTP or SFTP - possible?

Genius! This helped us out greatly in getting our SFTP configured - we need this because we wanted dynamic connections but some use Password Authentication and others use Public Key and that couldn't be paramaterized. Here's the code we used in our tJava component:
if(context.use_Private_key.equals("")){
    com.jcraft.jsch.ChannelSftp c_tFTPConnection_2 = (com.jcraft.jsch.ChannelSftp)globalMap.get("conn_tFTPConnection_2");
    globalMap.put("conn_tFTPConnection_1", c_tFTPConnection_2);
}

All Replies
Sixteen Stars

Re: [resolved] tFTPConnection configuration as FTP or SFTP - possible?

Hi David,
I think you can probably use this solution for doing the same thing with DB Connections. Instead of using the following code....
if(!context.UseSID){
    java.sql.Connection conn_tOracleConnection_2 = (java.sql.Connection)globalMap.get("conn_tOracleConnection_2");
    globalMap.put("conn_tOracleConnection_1",conn_tOracleConnection_2);
}

....it would be something along the lines of this...
if(!context.UseSID){
  com.enterprisedt.net.ftp.FTPClient ftp_tFTPConnection_2 = (java.sql.Connection)globalMap.get("conn_tFTPConnection_2");
    globalMap.put("conn_tFTPConnection_1",ftp_tFTPConnection_2);
}

I'd be interested to know if this works. Looking at the code it should, but I haven't been able to test it as I don't have access to the required ftp locations.
Eight Stars

Re: [resolved] tFTPConnection configuration as FTP or SFTP - possible?

Thanks for the ideas Richard, in the end I created my own tFTPConnection component that had the tickbox for sFTP support as a piece of text that I could that assigned a context or global variable.
I couldn't create my own custom named version, as all of the other tFTPxxxxxx components only connect to a tFTPConnection component only - so it had to be called tFTPConnection.
It worked, but it wasn't pretty. Once I got that working, the client secured all environments to be sFTP so had to revert it all anyway.
Regards

David

Don't forget to give Kudos when an answer is helpful or the solution.
One Star

Re: [resolved] tFTPConnection configuration as FTP or SFTP - possible?

Genius! This helped us out greatly in getting our SFTP configured - we need this because we wanted dynamic connections but some use Password Authentication and others use Public Key and that couldn't be paramaterized. Here's the code we used in our tJava component:
if(context.use_Private_key.equals("")){
    com.jcraft.jsch.ChannelSftp c_tFTPConnection_2 = (com.jcraft.jsch.ChannelSftp)globalMap.get("conn_tFTPConnection_2");
    globalMap.put("conn_tFTPConnection_1", c_tFTPConnection_2);
}
Sixteen Stars

Re: [resolved] tFTPConnection configuration as FTP or SFTP - possible?

Glad it helped Andrew :-)