├── README.md ├── examples └── sftp_test │ └── sftp_test.pde ├── library.properties ├── library ├── jsch-0.1.32.jar └── sftp.jar └── src └── sftp ├── CVS ├── Entries ├── Repository └── Root ├── Progress.class ├── Progress.java ├── PromptUser.class ├── PromptUser.java ├── Sftp.class └── Sftp.java /README.md: -------------------------------------------------------------------------------- 1 | # SFTP Library for Processing 2 | 3 | The library uses JSch (Java Secure Channel). 4 | 5 | Copyright (c) 2002,2003,2004,2005,2006,2007 Atsuhiko Yamanaka, JCraft, Inc. 6 | 7 | ```java 8 | import sftp.*; 9 | 10 | Sftp sftp; 11 | 12 | void setup() { 13 | size(200,200); 14 | background(0); 15 | // Create the SFTP object 16 | // if 3rd arg = false, you must set the password in your code 17 | // if 3rd arg = true, you will be prompted to enter your password 18 | sftp = new Sftp("www.hostname.com","login", true); 19 | // sftp.setPassword("XXXXXX"); 20 | sftp.start(); // start the thread 21 | noLoop(); 22 | } 23 | 24 | void mousePressed() { 25 | // At any point you can execute an SFTP command 26 | // Not all commands are currently implemented 27 | // but you do have "ls" and "get" 28 | // Gosh, I should implement "put", sorry! 29 | sftp.executeCommand("ls"); 30 | sftp.executeCommand("get file.txt"); 31 | } 32 | ``` 33 | -------------------------------------------------------------------------------- /examples/sftp_test/sftp_test.pde: -------------------------------------------------------------------------------- 1 | import sftp.*; 2 | 3 | Sftp sftp; 4 | 5 | void setup() { 6 | size(200,200); 7 | background(0); 8 | 9 | // Create the SFTP object 10 | // if 3rd argument is false, you must set the password in your code 11 | // if 3rd argument is true, you will be prompted to enter your password 12 | sftp = new Sftp("www.hostname.com","login", true); 13 | // sftp.setPassword("XXXXXX"); 14 | sftp.start(); // start the thread 15 | 16 | noLoop(); 17 | } 18 | 19 | void draw() { 20 | 21 | } 22 | 23 | void mousePressed() { 24 | // At any point you can execute an SFTP command 25 | // Not all commands are currently implemented, but you do have "ls" and "get" 26 | // Gosh, I should implement "put", sorry! 27 | sftp.executeCommand("ls"); 28 | sftp.executeCommand("get file.txt"); 29 | } 30 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | # The name of your library as you want it formatted 2 | name = SFTP 3 | 4 | # List of authors. Links can be provided using the syntax [author name](url) 5 | authorList = [Daniel Shiffman](http://www.shiffman.net) 6 | 7 | # A website for your library 8 | url = https://github.com/shiffman/SFTP-Processing/ 9 | 10 | # The category of your library, must be one of the following: 11 | # "Sound" "Import / Export" "Simulation / Math" 12 | # "Tools" "Hardware Interface" "Typography / Geometry" 13 | # "Animation" "Graphic Interface" "Computer Vision / Video" 14 | # "3D" "Compilation" "Data / Protocols" 15 | # 16 | # If a value other than those listed is used, your library will listed as "Other." 17 | category = Data / Protocols 18 | 19 | # A short sentence (fragment) to summarize the library's function. This will be 20 | # shown from inside the PDE when the library is being installed. Avoid repeating 21 | # the name of your library here. Also, avoid saying anything redundant like 22 | # mentioning that its a library. 23 | sentence = SFTP direct from Processing (using JSch) 24 | 25 | # Additional information suitable for the Processing website. The value of 26 | # 'sentence' always will be prepended, so you should start by writing the 27 | # second sentence here. If your library only works on certain operating systems, 28 | # mention it here. 29 | paragraph = Includes ls and get, needs to be updated with put 30 | 31 | # Links in the 'sentence' and 'paragraph' attributes can be inserted using the 32 | # same syntax as for authors. That is, [here is a link to Processing](http://processing.org/) 33 | 34 | # A version number that increments once with each release. This 35 | # is used to compare different versions of the same library, and 36 | # check if an update is available. 37 | version = 1 38 | 39 | # The version as the user will see it. If blank, the version attribute will be used here 40 | prettyVersion = 0.1a 41 | -------------------------------------------------------------------------------- /library/jsch-0.1.32.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiffman/SFTP-Processing/653303ca1610ee6a95a0aeaced4355d6236865fd/library/jsch-0.1.32.jar -------------------------------------------------------------------------------- /library/sftp.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiffman/SFTP-Processing/653303ca1610ee6a95a0aeaced4355d6236865fd/library/sftp.jar -------------------------------------------------------------------------------- /src/sftp/CVS/Entries: -------------------------------------------------------------------------------- 1 | /Progress.java/1.1/Mon Jun 4 20:20:43 2007// 2 | /PromptUser.java/1.1/Mon Jun 4 20:21:33 2007// 3 | /Sftp.java/1.2/Tue Jun 5 16:24:02 2007// 4 | -------------------------------------------------------------------------------- /src/sftp/CVS/Repository: -------------------------------------------------------------------------------- 1 | SFTPLibrary/sftp 2 | -------------------------------------------------------------------------------- /src/sftp/CVS/Root: -------------------------------------------------------------------------------- 1 | :extssh:shiffman@www.shiffman.net:/home/shiffman/CVSshiffman/ 2 | -------------------------------------------------------------------------------- /src/sftp/Progress.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiffman/SFTP-Processing/653303ca1610ee6a95a0aeaced4355d6236865fd/src/sftp/Progress.class -------------------------------------------------------------------------------- /src/sftp/Progress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Code for JAVA SFTP library 3 | * For use with Processing.org 4 | * Heavily based off of examples from JSCH: http://www.jcraft.com/jsch/ 5 | * Oh, and doesn't work at all without JSCH: http://www.jcraft.com/jsch/ 6 | * 7 | * Daniel Shiffman, June 2007 8 | * http://www.shiffman.net 9 | * 10 | * JSCH: 11 | * Copyright (c) 2002,2003,2004,2005,2006,2007 Atsuhiko Yamanaka, JCraft,Inc. 12 | * All rights reserved 13 | * 14 | */ 15 | package sftp; 16 | 17 | import com.jcraft.jsch.SftpProgressMonitor; 18 | 19 | public class Progress implements SftpProgressMonitor{ 20 | 21 | long count=0; 22 | long max=0; 23 | 24 | public void init(int op, String src, String dest, long max){ 25 | this.max=max; 26 | count=0; 27 | percent=-1; 28 | } 29 | 30 | private long percent=-1; 31 | 32 | public boolean count(long count){ 33 | this.count+=count; 34 | if(percent>=this.count*100/max){ return true; } 35 | percent=this.count*100/max; 36 | System.out.println("Completed "+this.count+"("+percent+"%) out of "+max+"."); 37 | //monitor.setProgress((int)this.count); 38 | return true; // it can never be canceled; 39 | //return !(monitor.isCanceled()); 40 | } 41 | 42 | public void end(){ 43 | //monitor.close(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/sftp/PromptUser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiffman/SFTP-Processing/653303ca1610ee6a95a0aeaced4355d6236865fd/src/sftp/PromptUser.class -------------------------------------------------------------------------------- /src/sftp/PromptUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Code for JAVA SFTP library 3 | * For use with Processing.org 4 | * Heavily based off of examples from JSCH: http://www.jcraft.com/jsch/ 5 | * Oh, and doesn't work at all without JSCH: http://www.jcraft.com/jsch/ 6 | * 7 | * Daniel Shiffman, June 2007 8 | * http://www.shiffman.net 9 | * 10 | * JSCH: 11 | * Copyright (c) 2002,2003,2004,2005,2006,2007 Atsuhiko Yamanaka, JCraft,Inc. 12 | * All rights reserved 13 | * 14 | */ 15 | 16 | package sftp; 17 | 18 | import java.awt.Container; 19 | import java.awt.GridBagConstraints; 20 | import java.awt.GridBagLayout; 21 | import java.awt.Insets; 22 | 23 | import javax.swing.JLabel; 24 | import javax.swing.JOptionPane; 25 | import javax.swing.JPanel; 26 | import javax.swing.JPasswordField; 27 | import javax.swing.JTextField; 28 | 29 | import com.jcraft.jsch.UserInfo; 30 | 31 | public class PromptUser implements UserInfo { 32 | boolean prompt; 33 | 34 | public PromptUser(boolean p, String pss) { 35 | super(); 36 | passwd = pss; 37 | prompt = p; 38 | } 39 | 40 | 41 | public String getPassword(){ return passwd; } 42 | 43 | public boolean promptYesNo(String str){ 44 | if (!prompt) { 45 | return true; 46 | } else { 47 | 48 | Object[] options={ "yes", "no" }; 49 | int foo=JOptionPane.showOptionDialog(null, 50 | str, 51 | "Warning", 52 | JOptionPane.DEFAULT_OPTION, 53 | JOptionPane.WARNING_MESSAGE, 54 | null, options, options[0]); 55 | return foo==0; 56 | } 57 | } 58 | 59 | String passwd; 60 | 61 | JTextField passwordField=(JTextField)new JPasswordField(20); 62 | 63 | public String getPassphrase(){ return null; } 64 | public boolean promptPassphrase(String message){ return true; } 65 | 66 | public boolean promptPassword(String message){ 67 | if (!prompt) { 68 | // password should have been set in constructor 69 | return true; 70 | } else { 71 | Object[] ob={passwordField}; 72 | int result= 73 | JOptionPane.showConfirmDialog(null, ob, message, 74 | JOptionPane.OK_CANCEL_OPTION); 75 | if(result==JOptionPane.OK_OPTION){ 76 | passwd=passwordField.getText(); 77 | return true; 78 | } 79 | else{ return false; } 80 | } 81 | } 82 | 83 | public void showMessage(String message){ 84 | JOptionPane.showMessageDialog(null, message); 85 | } 86 | 87 | final GridBagConstraints gbc = 88 | new GridBagConstraints(0,0,1,1,1,1, 89 | GridBagConstraints.NORTHWEST, 90 | GridBagConstraints.NONE, 91 | new Insets(0,0,0,0),0,0); 92 | private Container panel; 93 | public String[] promptKeyboardInteractive(String destination, 94 | String name, 95 | String instruction, 96 | String[] prompt, 97 | boolean[] echo){ 98 | panel = new JPanel(); 99 | panel.setLayout(new GridBagLayout()); 100 | 101 | gbc.weightx = 1.0; 102 | gbc.gridwidth = GridBagConstraints.REMAINDER; 103 | gbc.gridx = 0; 104 | panel.add(new JLabel(instruction), gbc); 105 | gbc.gridy++; 106 | 107 | gbc.gridwidth = GridBagConstraints.RELATIVE; 108 | 109 | JTextField[] texts=new JTextField[prompt.length]; 110 | for(int i=0; i