mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 01:45:55 +08:00
GenerateSSHKey: Allow the comment to be customized
This commit is contained in:
@ -27,6 +27,8 @@ public class GenerateSSHKeysTask extends AsyncTask<String, Void, Void> {
|
||||
keysDir.mkdir();
|
||||
}
|
||||
|
||||
String comment = params[1];
|
||||
|
||||
final String privateKeyPath = keysDir + "/id_rsa";
|
||||
final String publicKeyPath = keysDir + "/id_rsa.pub";
|
||||
|
||||
@ -43,7 +45,7 @@ public class GenerateSSHKeysTask extends AsyncTask<String, Void, Void> {
|
||||
KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, 1024 * 4);
|
||||
|
||||
kpair.writePrivateKey(privateKeyPath);
|
||||
kpair.writePublicKey(publicKeyPath, "Auto generated Key");
|
||||
kpair.writePublicKey(publicKeyPath, comment);
|
||||
kpair.dispose();
|
||||
} catch (JSchException ex) {
|
||||
Log.d("GenerateSSHKeys", ex.toString());
|
||||
|
@ -118,7 +118,12 @@ public class MainActivity extends FlutterActivity {
|
||||
new GitCommitTask(result).execute(cloneLocation, authorName, authorEmail, message);
|
||||
return;
|
||||
} else if (call.method.equals("generateSSHKeys")) {
|
||||
new GenerateSSHKeysTask(result).execute(sshKeysLocation);
|
||||
String comment = call.argument("comment");
|
||||
if (comment == null || comment.isEmpty()) {
|
||||
comment = "Generated on Android";
|
||||
}
|
||||
|
||||
new GenerateSSHKeysTask(result).execute(sshKeysLocation, comment);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user