summaryrefslogtreecommitdiffstats
path: root/Dozentenmodul/src/downloader/jschtest.java
diff options
context:
space:
mode:
authorunknown2014-01-31 15:34:22 +0100
committerunknown2014-01-31 15:34:22 +0100
commitf1fdca5246cce4c4c86a7fbb1418f1c758ed6175 (patch)
tree4ffef5a757397d3766e9c41cd953c7c4110f8e98 /Dozentenmodul/src/downloader/jschtest.java
parentUp - und Download der Images funktionieren nun, wichtig im Dozentenmodul muss... (diff)
downloadtutor-module-f1fdca5246cce4c4c86a7fbb1418f1c758ed6175.tar.gz
tutor-module-f1fdca5246cce4c4c86a7fbb1418f1c758ed6175.tar.xz
tutor-module-f1fdca5246cce4c4c86a7fbb1418f1c758ed6175.zip
Up - und Download funktionieren nun, wichtig im Dozentenmodul muss der volle Serverpfad angegeben sein.
Diffstat (limited to 'Dozentenmodul/src/downloader/jschtest.java')
-rw-r--r--Dozentenmodul/src/downloader/jschtest.java84
1 files changed, 0 insertions, 84 deletions
diff --git a/Dozentenmodul/src/downloader/jschtest.java b/Dozentenmodul/src/downloader/jschtest.java
deleted file mode 100644
index 83be7e03..00000000
--- a/Dozentenmodul/src/downloader/jschtest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package downloader;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.Properties;
-
-import com.jcraft.jsch.ChannelSftp;
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Session;
-import com.jcraft.jsch.SftpException;
-import com.jcraft.jsch.UserInfo;
-
-public class jschtest {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- File testfile=new File("C:\\Users\\tspitzer\\Documents\\201301_ws_win7_OPT_Apps_NC_Off2010.zip");
- try {
- sftpFile(testfile, "fr-bwlehrpool-rw-admin" , "fefobu36", "bwsonas.lsdf.kit.edu", "/.mounts/bwlehrpool");
- } catch (FileNotFoundException | JSchException | SftpException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- System.out.println("Fertig");
-
- }
-
- private static void sftpFile(File localFile, String username, String password, String hostname, String remoteDirectory)
- throws JSchException, SftpException, FileNotFoundException {
-
- JSch jsch = new JSch();
- String filename = localFile.getName();
- Session session = jsch.getSession(username, hostname, 22);
- session.setUserInfo(new HardcodedUserInfo(password));
- Properties config = new Properties();
- config.setProperty("StrictHostKeyChecking", "no");
- session.setConfig(config);
- session.connect();
- ChannelSftp channel = (ChannelSftp)session.openChannel("sftp");
- channel.connect();
- channel.cd(remoteDirectory);
- channel.put(new FileInputStream(localFile), filename);
- channel.disconnect();
- session.disconnect();
- }
-
- private static class HardcodedUserInfo implements UserInfo {
-
- private final String password;
-
- private HardcodedUserInfo(String password) {
- this.password = password;
- }
-
- public String getPassphrase() {
- return null;
- }
-
- public String getPassword() {
- return password;
- }
-
- public boolean promptPassword(String s) {
- return true;
- }
-
- public boolean promptPassphrase(String s) {
- return true;
- }
-
- public boolean promptYesNo(String s) {
- return true;
- }
-
- public void showMessage(String s) {
- System.out.println("message = " + s);
- }
- }
-
-}