2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 21:55:10 +00:00

moved to updated gradle and Android Studio

This commit is contained in:
Samoilenko Yuri
2014-01-13 00:15:17 +04:00
committed by Albert Vaca
parent a57dc71ad1
commit 52c7581f42
4 changed files with 68 additions and 79 deletions

View File

@@ -1,4 +1,4 @@
#Fri Jan 10 16:57:53 CET 2014 #Sun Jan 12 12:44:14 MSK 2014
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@@ -73,16 +73,11 @@
</content> </content>
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="sshd-core-0.8.0" level="project" />
<orderEntry type="library" exported="" name="slf4j-api-1.6.6" level="project" /> <orderEntry type="library" exported="" name="slf4j-api-1.6.6" level="project" />
<orderEntry type="library" exported="" name="mina-core-2.0.7" level="project" /> <orderEntry type="library" exported="" name="mina-core-2.0.7" level="project" />
<orderEntry type="library" exported="" name="support-v4-19.0.1" level="project" /> <orderEntry type="library" exported="" name="support-v4-19.0.1" level="project" />
<orderEntry type="library" exported="" name="ComAndroidSupportAppcompatV71901.aar" level="project" /> <orderEntry type="library" exported="" name="ComAndroidSupportAppcompatV71901.aar" level="project" />
<orderEntry type="library" name="bcprov-jdk16-145" level="project" />
<orderEntry type="library" name="tomcat-apr-5.5.23" level="project" />
<orderEntry type="library" name="sshd-core-0.7.0" level="project" />
<orderEntry type="library" exported="" name="mina-core-2.0.7" level="project" />
<orderEntry type="library" exported="" name="support-v4-19.0.1" level="project" />
<orderEntry type="library" exported="" name="ComAndroidSupportAppcompatV71901.aar" level="project" />
<orderEntry type="library" exported="" name="bcprov-jdk16-1.45" level="project" /> <orderEntry type="library" exported="" name="bcprov-jdk16-1.45" level="project" />
<orderEntry type="library" exported="" name="sshd-core-0.7.0" level="project" /> <orderEntry type="library" exported="" name="sshd-core-0.7.0" level="project" />
<orderEntry type="library" exported="" name="tomcat-apr-5.5.15" level="project" /> <orderEntry type="library" exported="" name="tomcat-apr-5.5.15" level="project" />

View File

@@ -1,17 +1,24 @@
package org.kde.kdeconnect.Plugins.SftpPlugin; package org.kde.kdeconnect.Plugins.SftpPlugin;
import android.content.Context;
import android.util.Log; 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.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.SshFile;
import org.apache.sshd.server.command.ScpCommandFactory; import org.apache.sshd.server.command.ScpCommandFactory;
import org.apache.sshd.server.filesystem.NativeFileSystemFactory; 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;
import java.io.File;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.NetworkInterface; import java.net.NetworkInterface;
import java.net.SocketException; import java.net.SocketException;
@@ -48,11 +55,12 @@ class SimpleSftpServer {
private final SshServer sshd = SshServer.setUpDefaultServer(); private final SshServer sshd = SshServer.setUpDefaultServer();
public void init() { public void init(Context ctx) {
passwordAuth.setUser(USER); passwordAuth.setUser(USER);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("key.ser")); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(ctx.getFilesDir() + "/sftpd.ser"));
sshd.setFileSystemFactory(new NativeFileSystemFactory()); //sshd.setFileSystemFactory(new NativeFileSystemFactory());
sshd.setFileSystemFactory(new SecureFileSystemFactory());
//sshd.setShellFactory(new ProcessShellFactory(new String[] { "/bin/sh", "-i", "-l" })); //sshd.setShellFactory(new ProcessShellFactory(new String[] { "/bin/sh", "-i", "-l" }));
sshd.setCommandFactory(new ScpCommandFactory()); sshd.setCommandFactory(new ScpCommandFactory());
sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory())); sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
@@ -112,72 +120,58 @@ class SimpleSftpServer {
} }
// ======================================= class SecureFileSystemFactory implements FileSystemFactory {
// Comented to be example of customization od SSHD
// =======================================
// static class SecureFileSystemFactory implements FileSystemFactory { public SecureFileSystemFactory() {}
// //
// public SecureFileSystemFactory() {
// }
// //
// @Override
// public FileSystemView createFileSystemView(final Session username) {
// final String userName = username.getUsername();
// final String home = "/mnt/sdcard/";
// return new SecureFileSystemView(home, userName, false);
// }
// }
// static class SecureFileSystemView extends NativeFileSystemView { @Override
// // the first and the last character will always be '/' public FileSystemView createFileSystemView(final Session username) {
// // It is always with respect to the root directory. final String base = "/";
// private String currDir = "/"; return new SecureFileSystemView(base, username.getUsername());
// private String rootDir = "/"; }
// private String userName; }
// private boolean isReadOnly = true;
// private boolean caseInsensitive = false; class SecureFileSystemView extends NativeFileSystemView {
// // // the first and the last character will always be '/'
// public SecureFileSystemView(final String rootDir, final String userName, final boolean isReadOnly) { // It is always with respect to the root directory.
// super(userName); private String currDir = "/";
// this.rootDir = NativeSshFile.normalizeSeparateChar(rootDir); private String rootDir = "/";
// this.userName = userName; private String userName;
// this.isReadOnly = isReadOnly; private boolean caseInsensitive = false;
// } //
// // public SecureFileSystemView(final String rootDir, final String userName) {
// @Override super(userName);
// public SshFile getFile(final String file) { this.rootDir = NativeSshFile.normalizeSeparateChar(rootDir);
// return getFile(currDir, file); this.userName = userName;
// } }
// //
// @Override @Override
// public SshFile getFile(final SshFile baseDir, final String file) { public SshFile getFile(final String file) {
// return getFile(baseDir.getAbsolutePath(), file); Log.e("getFile:", file);
// } return getFile(currDir, file);
// }
// //
// protected SshFile getFile(final String dir, final String file) { @Override
// // get actual file object public SshFile getFile(final SshFile baseDir, final String file) {
// String physicalName = NativeSshFile.getPhysicalName("/", dir, file, caseInsensitive); Log.e("getFile2:", baseDir.getAbsolutePath() + " -- " + file);
// File fileObj = new File(rootDir, physicalName); // chroot return getFile(baseDir.getAbsolutePath(), file);
// }
// // strip the root directory and return
// String userFileName = physicalName.substring("/".length() - 1); //
// return new SecureSshFile(userFileName, fileObj, userName, isReadOnly); protected SshFile getFile(final String dir, final String file) {
// } // get actual file object
// } String physicalName = NativeSshFile.getPhysicalName("/", dir, file, caseInsensitive);
// File fileObj = new File(rootDir, physicalName); // chroot
// static class SecureSshFile extends NativeSshFile {
// final boolean isReadOnly; // strip the root directory and return
// // String userFileName = physicalName.substring("/".length() - 1);
// public SecureSshFile(final String fileName, final File file, final String userName, final boolean isReadOnly) { return new SecureSshFile(this, userFileName, fileObj, userName);
// super(fileName, file, userName); }
// this.isReadOnly = isReadOnly; }
// }
// // class SecureSshFile extends NativeSshFile {
// public boolean isWritable() { //
// if (isReadOnly) public SecureSshFile(final SecureFileSystemView view, final String fileName, final File file, final String userName) {
// return false; super(fileName, file, userName);
// return super.isWritable(); }
// } }
// }

View File

@@ -42,7 +42,7 @@ public class SftpPlugin extends Plugin {
@Override @Override
public boolean onCreate() { public boolean onCreate() {
server.init(); server.init(context);
return true; return true;
} }