mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 21:55:10 +00:00
Reverting 6ed3a18
sshd > 0.8 seems to fail with "Could not find a valid sshd io provider"
This commit is contained in:
@@ -66,7 +66,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.9.0' //1.+ requires java.nio.file, which doesn't exist in Android
|
compile 'org.apache.sshd:sshd-core:0.8.0'
|
||||||
//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'
|
||||||
|
@@ -27,18 +27,18 @@ import org.apache.sshd.SshServer;
|
|||||||
import org.apache.sshd.common.KeyExchange;
|
import org.apache.sshd.common.KeyExchange;
|
||||||
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.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.kex.DHG1;
|
import org.apache.sshd.server.kex.DHG1;
|
||||||
import org.apache.sshd.server.kex.DHG14;
|
import org.apache.sshd.server.kex.DHG14;
|
||||||
|
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;
|
||||||
@@ -194,55 +194,55 @@ class SimpleSftpServer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SecureFileSystemFactory implements FileSystemFactory {
|
class SecureFileSystemFactory implements FileSystemFactory {
|
||||||
|
|
||||||
public SecureFileSystemFactory() {}
|
public SecureFileSystemFactory() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileSystemView createFileSystemView(final Session username) {
|
public FileSystemView createFileSystemView(final Session username) {
|
||||||
final String base = "/";
|
final String base = "/";
|
||||||
return new SecureFileSystemView(base, username.getUsername());
|
return new SecureFileSystemView(base, username.getUsername());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class SecureFileSystemView extends NativeFileSystemView {
|
|
||||||
// the first and the last character will always be '/'
|
|
||||||
// It is always with respect to the root directory.
|
|
||||||
private String currDir = "/";
|
|
||||||
private String rootDir = "/";
|
|
||||||
private String userName;
|
|
||||||
//
|
|
||||||
public SecureFileSystemView(final String rootDir, final String userName) {
|
|
||||||
super(userName);
|
|
||||||
this.rootDir = NativeSshFile.normalizeSeparateChar(rootDir);
|
|
||||||
this.userName = userName;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
@Override
|
|
||||||
public SshFile getFile(final String file) {
|
|
||||||
return getFile(currDir, file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
class SecureFileSystemView extends NativeFileSystemView {
|
||||||
public SshFile getFile(final SshFile baseDir, final String file) {
|
// the first and the last character will always be '/'
|
||||||
return getFile(baseDir.getAbsolutePath(), file);
|
// It is always with respect to the root directory.
|
||||||
|
private String currDir = "/";
|
||||||
|
private String rootDir = "/";
|
||||||
|
private String userName;
|
||||||
|
//
|
||||||
|
public SecureFileSystemView(final String rootDir, final String userName) {
|
||||||
|
super(userName);
|
||||||
|
this.rootDir = NativeSshFile.normalizeSeparateChar(rootDir);
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
@Override
|
||||||
|
public SshFile getFile(final String file) {
|
||||||
|
return getFile(currDir, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SshFile getFile(final SshFile baseDir, final String file) {
|
||||||
|
return getFile(baseDir.getAbsolutePath(), file);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
protected SshFile getFile(final String dir, final String file) {
|
||||||
|
// get actual file object
|
||||||
|
final boolean caseInsensitive = false;
|
||||||
|
String physicalName = NativeSshFile.getPhysicalName("/", dir, file, caseInsensitive);
|
||||||
|
File fileObj = new File(rootDir, physicalName); // chroot
|
||||||
|
|
||||||
|
// strip the root directory and return
|
||||||
|
String userFileName = physicalName.substring("/".length() - 1);
|
||||||
|
return new SecureSshFile(userFileName, fileObj, userName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
class SecureSshFile extends NativeSshFile {
|
||||||
protected SshFile getFile(final String dir, final String file) {
|
public SecureSshFile(final String fileName, final File file, final String userName) {
|
||||||
// get actual file object
|
super(fileName, file, userName);
|
||||||
final boolean caseInsensitive = false;
|
}
|
||||||
String physicalName = NativeSshFile.getPhysicalName("/", dir, file, caseInsensitive);
|
|
||||||
File fileObj = new File(rootDir, physicalName); // chroot
|
|
||||||
|
|
||||||
// strip the root directory and return
|
|
||||||
String userFileName = physicalName.substring("/".length() - 1);
|
|
||||||
return new SecureSshFile(this, userFileName, fileObj, userName);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class SecureSshFile extends NativeSshFile {
|
|
||||||
public SecureSshFile(NativeFileSystemView view, String fileName, File file, String userName) {
|
|
||||||
super(view, fileName, file, userName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user