We need to create an executable program which would send and receive files from the server of the client. The client is already preparing to purchase an SFTP facility of this.
My question is:
1. Can a java program connect to existing SFTP facilities (e.g. RSIT)
2. Is there still a need to have an SFTP facility or is there an existing or new library in java which can do this? if yes, is this a better solution than #1?
3. If #2 is recommended, is jftp still the recommended API for this?
#1 Yes, and the standard Java SFTP library is JSch (on top of which jftp is apparenlty built).
#2 - I'm not sure what you're asking. If you need SFTP -because that's what your client uses- how does something help? Or are you asking how to implement secure file transfer for a greenfield implementation where SFTP isn't set from the start?
#3 - jftp seems to be a GUI client; if you need programmatic SFTP access, then JSch is probably the way to go.
posted 4 years ago
Thanks for the input Ulf.
What I mean is, can the java api that can do sftp work on its own? or is it dependent on some sort of installation of an SFTP facility in the server ? If yes, that would save our client money because they won't be needing to purchase the SFTP facility to be stored on their server, let the API do all the work.
Andres Delrotti wrote:Would the logic to connect to the sftp server depend on the brand of the SFTP facility ? (e.g. RSIT)
SFTP is intended to be interoperable. If you are wondering about a particular implementation such as Attachmate’s RSIT, would you need to try it to be sure, but it would be pretty safe to assume it will work.
I've developed functionality using Jsch just like this. It's perfectly possible, but you need the right info from the server, you will need to contact systems admin to do all the necessary work (proxy, firewall, port) and give you the right information (which proxy to use, which user, password, etc.), and it's quite possible that you'll need to add some extra properties depending on the SFTP server (for example 'StrictHostKeyChecking').
Can jsch do that without polling? i mean can it "listen" if files are dropped off at a certain folder so that it can receive or send it?
i have googled some jsch codes and seen some but not sure if reading or sending files can be automatically triggered
You are asking too much of SSH and therefore jsch. SSH is a well defined protocol (there are something like 5 applicable RFCs which Google will find) for securely communicating between a client and a server. In it's minimal form SSH does not even have file transfer but SSH does have a standard way of adding functionality and most SSH clients and servers support the SCP and SFTP file transfer protocol extensions. Presumably you need transfer files from the server to the client as soon as they become available on the server. One could do this with jsch or any of the standard Java SSH libraries but you would need to poll the server since there is nothing build into the SSH protocol to allow ans SSH client to be notified of server side file system changes. I do foresee a problem with polling in that it could be difficult to know when a file is actually available as a whole and not currently being written.