public DataClient(DataConnectionDialog dcd, Genoplot genoplot) throws IOException{
        Logger.getLogger("com.sshtools").setLevel(Level.WARNING);
        this.gp = genoplot;
        // Create a password authentication instance
        if (dcd.getUsername() != null){
            localDir = dcd.getLocalDirectory();
            oxFormat = dcd.isOxformat();

            pwd.setUsername(dcd.getUsername());
            pwd.setPassword(new String(dcd.getPassword()));
            ssh = new SshClient();
            try{
                ssh.connect(dcd.getHost(), dcd.getPort(), new IgnoreHostKeyVerification());
                remoteDir = dcd.getRemoteDirectory();
            }finally{
                dcd.clearPassword();
            }

            // Try the authentication
            int result = ssh.authenticate(pwd);
            // Evaluate the result
            if (result == AuthenticationProtocolState.COMPLETE) {
                Genoplot.ld.log("Successful connection to " + dcd.getHost());
                ftp = ssh.openSftpClient();
                ftp.cd(remoteDir);
                ftp.lcd(localDir);
                try{
                    String perms = ftp.stat("evoker-helper.pl").getPermissionsString();
                    if (!perms.endsWith("x")){
                        throw new IOException("must be fully executable");
                    }
                }catch (IOException ioe){
                    ssh.disconnect();
                    throw new IOException("Problem with evoker-helper.pl on remote server:\n"+ioe.getMessage());
                }
                
                // check if the localdir contains files already
                File[] localFiles = new File(localDir).listFiles();
                if (localFiles.length > 0){
                	Genoplot.ld.log("Files in the local directory");
                	// ask the user if they wants it emptied
                	int n = JOptionPane.showConfirmDialog(
                			genoplot.getContentPane(), 
                			"The local directory selected is not empty.\n Would you like to clear all files in this directory?",
                			"Clear the local directory?",
                			JOptionPane.YES_NO_OPTION,
                			JOptionPane.QUESTION_MESSAGE );
                	// n 0 = yes 1 = no
                	if (n == 0) {
                		for (File localFile : localFiles){
                			try {
                				localFile.delete();	
                			}catch (SecurityException se){
                				JOptionPane.showMessageDialog(null,se.getMessage(), "File delete error", JOptionPane.ERROR_MESSAGE);
                			}
                		}
                	}
                }
                displayName = dcd.getHost()+":"+remoteDir;
            }else{
                 throw new IOException("Authentication to host '"+dcd.getHost()+"' failed.");
            }
        }
    }