mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 09:47:35 +08:00
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:
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user