Android: Remove the jgit dependency

Finally! We now only rely on libgit2. Unfortunately, we still rely on a
java library for the public key generation.
This commit is contained in:
Vishesh Handa
2019-05-16 12:27:15 +02:00
parent 64c8ddd7b0
commit 2fa6f9338b
2 changed files with 0 additions and 61 deletions

View File

@ -98,10 +98,6 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation('org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r')
{
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
implementation 'com.jcraft:jsch:0.1.54'
// For reading a file to string

View File

@ -1,57 +0,0 @@
package io.gitjournal.gitjournal;
import android.util.Log;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import org.eclipse.jgit.transport.JschConfigSessionFactory;
import org.eclipse.jgit.transport.OpenSshConfig;
import org.eclipse.jgit.util.FS;
public class CustomSshSessionFactory extends JschConfigSessionFactory {
private String privateKeyPath;
public CustomSshSessionFactory(String privateKeyPath_) {
privateKeyPath = privateKeyPath_;
}
protected void configure(OpenSshConfig.Host host, Session session) {
session.setConfig("StrictHostKeyChecking", "no");
}
protected JSch createDefaultJSch(FS fs) throws JSchException {
class MyLogger implements com.jcraft.jsch.Logger {
java.util.Hashtable name;
MyLogger() {
name = new java.util.Hashtable();
name.put(new Integer(DEBUG), "DEBUG: ");
name.put(new Integer(INFO), "INFO: ");
name.put(new Integer(WARN), "WARN: ");
name.put(new Integer(ERROR), "ERROR: ");
name.put(new Integer(FATAL), "FATAL: ");
}
public boolean isEnabled(int level) {
return false;
}
public void log(int level, String message) {
System.err.print(name.get(new Integer(level)));
System.err.println(message);
}
}
JSch.setLogger(new MyLogger());
JSch defaultJSch = super.createDefaultJSch(fs);
defaultJSch.addIdentity(privateKeyPath);
JSch.setConfig("PreferredAuthentications", "publickey");
Log.d("identityNames", defaultJSch.getIdentityNames().toString());
return defaultJSch;
}
}