Skip to content

Commit

Permalink
initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
vwiencek committed Mar 6, 2014
1 parent 83ae708 commit 265708d
Show file tree
Hide file tree
Showing 12 changed files with 954 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.jar
*.war
*.ear
/bin
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "core"]
path = core
url = http://github.com/vwiencek/syncany.git
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
syncany-plugin-sftp
===================
Syncany SFTP Plugin

SFTP Syncany plugin
#1 Steps to make it work

git clone http://github.com/vwiencek/syncany-plugin-sftp.git
cd syncany-plugin-hazelcast
git submodule init
git submodule update
gradle eclipse

Then you have a fully 'eclipse-prepared' environment to start improving the plugin

16 changes: 16 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apply plugin: 'java'
apply plugin: 'eclipse'

dependencies {
compile project(':syncany-lib')
compile "com.jcraft:jsch:0.1.50"
compile "org.apache.sshd:sshd-core:0.9.0"
compile "org.apache.commons:commons-vfs2:2.0"

testCompile "junit:junit:4.3"
testCompile project(path : ':syncany-lib', configuration: 'tests')
}

repositories {
mavenCentral()
}
1 change: 1 addition & 0 deletions core
Submodule core added at 024023
5 changes: 5 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include 'syncany-lib'
include 'syncany-util'

project(':syncany-lib').projectDir = new File('core/syncany-lib')
project(':syncany-util').projectDir = new File('core/syncany-util')
114 changes: 114 additions & 0 deletions src/main/java/org/syncany/connection/plugins/sftp/SftpConnection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* Syncany, www.syncany.org
* Copyright (C) 2011-2014 Philipp C. Heckel <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.syncany.connection.plugins.sftp;

import java.util.Map;

import org.syncany.connection.plugins.Connection;
import org.syncany.connection.plugins.PluginOptionSpec;
import org.syncany.connection.plugins.PluginOptionSpec.ValueType;
import org.syncany.connection.plugins.PluginOptionSpecs;
import org.syncany.connection.plugins.StorageException;
import org.syncany.connection.plugins.TransferManager;

/**
* The SFTP connection represents the settings required to connect to an
* SFTP-based storage backend. It can be used to initialize/create an
* {@link SftpTransferManager} and is part of the {@link SftpPlugin}.
*
* @author Vincent Wiencek <[email protected]>
*/
public class SftpConnection implements Connection {
private String hostname;
private String username;
private String password;
private String path;
private int port;

@Override
public TransferManager createTransferManager() {
return new SftpTransferManager(this);
}

public String getHostname() {
return hostname;
}

public void setHostname(String hostname) {
this.hostname = hostname;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

@Override
public void init(Map<String, String> optionValues) throws StorageException {
getOptionSpecs().validate(optionValues);
this.hostname = optionValues.get("hostname");
this.username = optionValues.get("username");
this.password = optionValues.get("password");
this.path = optionValues.get("path");
this.port = Integer.parseInt(optionValues.get("port"));
}

@Override
public PluginOptionSpecs getOptionSpecs() {
return new PluginOptionSpecs(
new PluginOptionSpec("hostname", "Hostname", ValueType.STRING, true, false, null),
new PluginOptionSpec("username", "Username", ValueType.STRING, true, false, null),
new PluginOptionSpec("password", "Password", ValueType.STRING, true, true, null),
new PluginOptionSpec("path", "Path", ValueType.STRING, true, false, null),
new PluginOptionSpec("port", "Port", ValueType.INT, false, false, "22")
);
}

@Override
public String toString() {
return SftpConnection.class.getSimpleName()
+ "[hostname=" + hostname + ":" + port + ", username=" + username + ", path=" + path + "]";
}
}
54 changes: 54 additions & 0 deletions src/main/java/org/syncany/connection/plugins/sftp/SftpPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Syncany, www.syncany.org
* Copyright (C) 2011-2014 Philipp C. Heckel <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.syncany.connection.plugins.sftp;

import org.syncany.connection.plugins.Connection;
import org.syncany.connection.plugins.Plugin;

/**
* Identifies the SFTP-based storage {@link Plugin} for Syncany.
*
* <p>This class defines the identifier, name and
* version of the plugin. It furthermore allows the instantiation
* of a plugin-specific {@link SftpConnection}.
*
* @author Vincent Wiencek <[email protected]>
*/
public class SftpPlugin extends Plugin {
public static final String ID = "sftp";

@Override
public String getId() {
return ID;
}

@Override
public String getName() {
return "SFTP";
}

@Override
public Integer[] getVersion() {
return new Integer[] { 0, 1 };
}

@Override
public Connection createConnection() {
return new SftpConnection();
}
}
Loading

0 comments on commit 265708d

Please sign in to comment.