mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 13:47:41 +00:00
Upgraded sshd to 0.9
We can't upgrade it to 1.0 or 1.1 because these need java.nio.file, which is standard java 7 but not present in Android.
This commit is contained in:
@@ -65,7 +65,7 @@ dependencies {
|
|||||||
compile 'com.android.support:appcompat-v7:23.2.0'
|
compile 'com.android.support:appcompat-v7:23.2.0'
|
||||||
compile 'com.android.support:design:23.2.0'
|
compile 'com.android.support:design:23.2.0'
|
||||||
|
|
||||||
compile 'org.apache.sshd:sshd-core:0.8.0'
|
compile 'org.apache.sshd:sshd-core:0.9.0' //1.+ requires java.nio.file, which doesn't exist in Android
|
||||||
//compile 'org.bouncycastle:bcprov-jdk15on:1.54'
|
//compile 'org.bouncycastle:bcprov-jdk15on:1.54'
|
||||||
|
|
||||||
compile 'com.madgag.spongycastle:pkix:1.54.0.0'
|
compile 'com.madgag.spongycastle:pkix:1.54.0.0'
|
||||||
|
@@ -26,15 +26,16 @@ import android.util.Log;
|
|||||||
import org.apache.sshd.SshServer;
|
import org.apache.sshd.SshServer;
|
||||||
import org.apache.sshd.common.NamedFactory;
|
import org.apache.sshd.common.NamedFactory;
|
||||||
import org.apache.sshd.common.Session;
|
import org.apache.sshd.common.Session;
|
||||||
|
import org.apache.sshd.common.file.FileSystemFactory;
|
||||||
|
import org.apache.sshd.common.file.FileSystemView;
|
||||||
|
import org.apache.sshd.common.file.SshFile;
|
||||||
|
import org.apache.sshd.common.file.nativefs.NativeFileSystemView;
|
||||||
|
import org.apache.sshd.common.file.nativefs.NativeSshFile;
|
||||||
|
import org.apache.sshd.common.util.SecurityUtils;
|
||||||
import org.apache.sshd.server.Command;
|
import org.apache.sshd.server.Command;
|
||||||
import org.apache.sshd.server.FileSystemFactory;
|
|
||||||
import org.apache.sshd.server.FileSystemView;
|
|
||||||
import org.apache.sshd.server.PasswordAuthenticator;
|
import org.apache.sshd.server.PasswordAuthenticator;
|
||||||
import org.apache.sshd.server.PublickeyAuthenticator;
|
import org.apache.sshd.server.PublickeyAuthenticator;
|
||||||
import org.apache.sshd.server.SshFile;
|
|
||||||
import org.apache.sshd.server.command.ScpCommandFactory;
|
import org.apache.sshd.server.command.ScpCommandFactory;
|
||||||
import org.apache.sshd.server.filesystem.NativeFileSystemView;
|
|
||||||
import org.apache.sshd.server.filesystem.NativeSshFile;
|
|
||||||
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
|
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
|
||||||
import org.apache.sshd.server.session.ServerSession;
|
import org.apache.sshd.server.session.ServerSession;
|
||||||
import org.apache.sshd.server.sftp.SftpSubsystem;
|
import org.apache.sshd.server.sftp.SftpSubsystem;
|
||||||
@@ -108,9 +109,7 @@ class SimpleSftpServer {
|
|||||||
passwordAuth.setUser(USER);
|
passwordAuth.setUser(USER);
|
||||||
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(ctx.getFilesDir() + "/sftpd.ser"));
|
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(ctx.getFilesDir() + "/sftpd.ser"));
|
||||||
|
|
||||||
//sshd.setFileSystemFactory(new NativeFileSystemFactory());
|
|
||||||
sshd.setFileSystemFactory(new SecureFileSystemFactory());
|
sshd.setFileSystemFactory(new SecureFileSystemFactory());
|
||||||
//sshd.setShellFactory(new ProcessShellFactory(new String[] { "/bin/sh", "-i", "-l" }));
|
|
||||||
sshd.setCommandFactory(new ScpCommandFactory());
|
sshd.setCommandFactory(new ScpCommandFactory());
|
||||||
sshd.setSubsystemFactories(Collections.singletonList((NamedFactory<Command>)new SftpSubsystem.Factory()));
|
sshd.setSubsystemFactories(Collections.singletonList((NamedFactory<Command>)new SftpSubsystem.Factory()));
|
||||||
|
|
||||||
@@ -152,8 +151,8 @@ class SimpleSftpServer {
|
|||||||
try {
|
try {
|
||||||
started = false;
|
started = false;
|
||||||
sshd.stop();
|
sshd.stop();
|
||||||
} catch (InterruptedException e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,12 +223,12 @@ class SimpleSftpServer {
|
|||||||
|
|
||||||
// strip the root directory and return
|
// strip the root directory and return
|
||||||
String userFileName = physicalName.substring("/".length() - 1);
|
String userFileName = physicalName.substring("/".length() - 1);
|
||||||
return new SecureSshFile(userFileName, fileObj, userName);
|
return new SecureSshFile(this, userFileName, fileObj, userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SecureSshFile extends NativeSshFile {
|
class SecureSshFile extends NativeSshFile {
|
||||||
public SecureSshFile(final String fileName, final File file, final String userName) {
|
public SecureSshFile(NativeFileSystemView view, String fileName, File file, String userName) {
|
||||||
super(fileName, file, userName);
|
super(view, fileName, file, userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user