mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 19:36:25 +08:00
Android: Stop using jsch
Instead use the c-lib for the ssh keygeneration. This should reduce our APK size a little bit, but most importantly we'll be using the exact same code for osx and android.
This commit is contained in:
@ -102,8 +102,6 @@ dependencies {
|
|||||||
androidTestImplementation 'androidx.test:runner:1.1.0'
|
androidTestImplementation 'androidx.test:runner:1.1.0'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
|
||||||
|
|
||||||
implementation 'com.jcraft:jsch:0.1.54'
|
|
||||||
|
|
||||||
// For reading a file to string
|
// For reading a file to string
|
||||||
implementation 'commons-io:commons-io:2.5'
|
implementation 'commons-io:commons-io:2.5'
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ add_library(native-lib
|
|||||||
SHARED
|
SHARED
|
||||||
${CMAKE_SOURCE_DIR}/../../../../../gj_common/gitjournal.c
|
${CMAKE_SOURCE_DIR}/../../../../../gj_common/gitjournal.c
|
||||||
${CMAKE_SOURCE_DIR}/../../../../../gj_common/keygen.c
|
${CMAKE_SOURCE_DIR}/../../../../../gj_common/keygen.c
|
||||||
|
${CMAKE_SOURCE_DIR}/../../../../../gj_common/common.c
|
||||||
git.c
|
git.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,14 +3,12 @@ package io.gitjournal.gitjournal;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.jcraft.jsch.*;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import io.flutter.plugin.common.MethodChannel.Result;
|
import io.flutter.plugin.common.MethodChannel.Result;
|
||||||
|
|
||||||
public class GenerateSSHKeysTask extends AsyncTask<String, Void, Void> {
|
public class GenerateSSHKeysTask extends AsyncTask<String, Void, Void> {
|
||||||
@ -41,21 +39,10 @@ public class GenerateSSHKeysTask extends AsyncTask<String, Void, Void> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate key pair
|
io.gitjournal.gitjournal.Git git = new io.gitjournal.gitjournal.Git();
|
||||||
try {
|
String errorStr = git.generateKeys(privateKeyPath, publicKeyPath, comment);
|
||||||
JSch jsch = new JSch();
|
if (!errorStr.isEmpty()) {
|
||||||
KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, 1024 * 4);
|
result.error("FAILED", errorStr, null);
|
||||||
|
|
||||||
kpair.writePrivateKey(privateKeyPath);
|
|
||||||
kpair.writePublicKey(publicKeyPath, comment);
|
|
||||||
kpair.dispose();
|
|
||||||
} catch (JSchException ex) {
|
|
||||||
Log.d(TAG, ex.toString());
|
|
||||||
result.error("FAILED", ex.getMessage(), null);
|
|
||||||
return null;
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Log.d(TAG, ex.toString());
|
|
||||||
result.error("FAILED", ex.getMessage(), null);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user