skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

▼
 
  • RSS
  • Twitter
Thursday, September 20, 2012

Secure File Upload and download with FTPS

Posted by Admin at 12:03 PM – 0 comments
 

When a client and server computer want to exchange secrets, they need to negotiate too, public keys, encryption methods, ports and more needed.



import com.jscape.inet.ftp.*;
import com.jscape.inet.ftps.*;
import java.io.*;
import java.util.Enumeration;

public class SecureUpload extends FtpAdapter {
    private String hostname;
    private String username;
    private String password;
    
    // perform multiple file upload
    public void doUpload(String hostname, String username, String password) throws FtpException {
        Ftps ftp = new Ftps(hostname,username,password);
        
        //capture Ftps related events
        ftp.addFtpListener(this);
  
  // Set the connection type. Explicit is Ftps.AUTH_TLS. 
  // Implicit (which is deprecated) is Ftps.IMPLICIT_SSL
  ftp.setConnectionType(Ftps.AUTH_TLS);
  
        ftp.connect();
        ftp.setBinary();
        ftp.mupload(".*\\.gif");
        ftp.disconnect();
    }
    
    public static void main(String[] args) {
        String hostname = "ftp.somewebsite.com";
        String username = "IFeelSecure";
        String password = "zip1a2dee3doo4dah";
        try {
            SecureUpload theUploader = new SecureUpload();
            theUploader.doUpload(hostname,username,password);
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}



Leave a Reply

Newer Post Older Post
Subscribe to: Post Comments ( Atom )
  • Popular
  • Recent
  • Archives
Powered by Blogger.
 
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger