Version: edtFTPjPRO-3.4.1.
JavaEE server: weblogic 10.3.4
SFTP server: tried freeFTPd and Cerberus FTP Server (both have problem)
Protocol: SFTP
Situation:
We are facing some technical problem when running SSHFTPClient to connect SFTP server with edtFTPjPRO-3.4.1. The Transport Protocol thread failed : com.enterprisedt.cryptix.provider.elgamal.BaseElGamalKeyPairGenerator java.lang.ClassCastException: com.enterprisedt.cryptix.provider.elgamal.BaseElGamalKeyPairGenerator
....
... is recorded in the DEBUG log.
We have a program using edtFTPjPRO for SFTP file transfer. Recently, we found that the program cannot transfer file to the SFTP server after several requests.
Usually, we found the problem may not occur at the very beginning. However, the problem occur after several request (actually, we are just repeating to upload the same file to same SFTP server).
Below is the code of the program:
public class EdtSFtp {
static{
License.setLicenseDetails(EDT_LICENSE_OWNER, EDT_LICENSE_KEY);
}
private SSHFTPClient sftp = new SSHFTPClient();
public void connectAndLogin(String hostname, String username, String password) throws FTPException,IOException {
sftp.setRemoteHost(hostname);
sftp.setAuthentication(username, password);
sftp.getValidator().setHostValidationEnabled(false);
sftp.connect();
// sftp.setType(FTPTransferType.BINARY);
}
public void setTimeout(int milliSec) throws FTPException {
sftp.setTimeout(milliSec);
}
public void setBinary(){
sftp.setType(FTPTransferType.BINARY);
}
public void setAscii(){
sftp.setType(FTPTransferType.ASCII);
}
public void disconnect() throws IOException, FTPException {
sftp.quit();
}
public void uploadStream(byte[] data, String path, String remoteFile) throws FTPException, IOException {
if (!(path == null || path.equals(""))){
changeDir(path);
}
sftp.put(data, remoteFile);
}
public void downloadStream(OutputStream out, String path, String remoteFile) throws IOException, FTPException {
if (!(path == null || path.equals(""))){
changeDir(path);
}
sftp.get(out, remoteFile);
}
public boolean isConnected(){
return sftp.connected();
}
private void changeDir(String path) throws IOException, FTPException {
try {
sftp.chdir(path);
} catch (FTPException e) {
sftp.mkdir(path);
sftp.chdir(path);
}
}
}
public class ReportExporter {
public void exportFile(byte[] content, String username, String outHost, String outPath, String outFileName) throws Exception{
try {
EdtSFtp sftp = new EdtSFtp();
sftp.setTimeout(sftpTimeout);
sftp.connectAndLogin(outHost, accountUsername, accountPassword);
sftp.setBinary();
sftp.uploadStream(content, outPath, outFileName);
}
catch (FTPException fe){
//...
}
catch (IOException ie){
//...
}
catch(Exception e){
}
finally{
if (sftp.isConnected()){
try{
sftp.disconnect();
} catch(IOException e){
//for server with auto disconnect
e.printStackTrace();
} catch(FTPException e){
//for server with auto disconnect
e.printStackTrace();
}
}
}
}
}
Below is the connection log of Cerberus FTP server when the problem occur:
2011/10/21 16:05:34 [10] Incoming connection request on SSH interface 2 at 160.78.18.136
2011/10/21 16:05:34 [10] SSH FTP connection request accepted from 160.84.67.95
2011/10/21 16:05:34 [10] Client Identification: SSH-2.0-edtFTPjPRO-3.4.1
2011/10/21 16:05:34 [10] Algorithm negotiation complete: Proceeding with key exchange
2011/10/21 16:05:34 [10] Kex: 'diffie-hellman-group1-sha1' Host Key: 'ssh-rsa' C2S : '3des-cbc, hmac-sha1, none' S2C : '3des-cbc, hmac-sha1, none'
2011/10/21 16:05:34 [10] The client closed the connection
2011/10/21 16:05:34 [10] Connection terminated
Here is the DEBUG log of the edtFTPjPRO-3.4.1:
INFO [LicensePropertiesBase] 21 Oct 2011 16:57:35.414 : Licence expiry date: 31 Dec 9999
INFO [LicensePropertiesBase] 21 Oct 2011 16:57:35.414 : Production licence
DEBUG [SCPClient] 21 Oct 2011 16:57:35.414 : Class: com.enterprisedt.net.ft