Skip to content

Commit

Permalink
Added SFTP support in wotaskd, in preparation of a Jenkins plugin
Browse files Browse the repository at this point in the history
The SFTP server will run on port 6022. Only password authentication will work, you need to provide the password of your wotaskd installation.
  • Loading branch information
Pascal Robert committed Aug 10, 2012
1 parent d517dde commit c7ad865
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Applications/wotaskd/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="WOFramework/ERRest"/>
<classpathentry kind="con" path="WOFramework/JavaWOExtensions"/>
<classpathentry kind="lib" path="Libraries/bcprov-jdk15-140.jar"/>
<classpathentry kind="lib" path="Libraries/mina-core-2.0.4.jar"/>
<classpathentry kind="lib" path="Libraries/sshd-core-0.7.0.jar"/>
<classpathentry kind="lib" path="Libraries/sshd-pam-0.7.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Applications/wotaskd/Libraries/sshd-pam-0.7.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.HashMap;

import javax.management.InstanceAlreadyExistsException;
Expand All @@ -30,6 +31,15 @@
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;

import org.apache.sshd.SshServer;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.command.ScpCommandFactory;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.session.ServerSession;
import org.apache.sshd.server.sftp.SftpSubsystem;

import com.webobjects.appserver.WOApplication;
import com.webobjects.appserver.WORequest;
import com.webobjects.appserver.WORequestHandler;
Expand Down Expand Up @@ -222,6 +232,28 @@ public Application() {
restHandler.insertRoute(new ERXRoute("MSiteConfig","/mSiteConfig", ERXRoute.Method.Put, MSiteConfigController.class, "update"));

ERXRouteRequestHandler.register(restHandler);

SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(6022);
sshd.setPasswordAuthenticator(new SshPasswordAuthenticator());
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));
sshd.setCommandFactory(new ScpCommandFactory());
sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
try {
sshd.start();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public class SshPasswordAuthenticator implements PasswordAuthenticator {

public boolean authenticate(String username, String password, ServerSession serversession) {
return (siteConfig().compareStringWithPassword(password)) ? true: false;
}

}

/**
Expand Down

0 comments on commit c7ad865

Please sign in to comment.