mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +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();
|
keysDir.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String comment = params[1];
|
||||||
|
|
||||||
final String privateKeyPath = keysDir + "/id_rsa";
|
final String privateKeyPath = keysDir + "/id_rsa";
|
||||||
final String publicKeyPath = keysDir + "/id_rsa.pub";
|
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);
|
KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, 1024 * 4);
|
||||||
|
|
||||||
kpair.writePrivateKey(privateKeyPath);
|
kpair.writePrivateKey(privateKeyPath);
|
||||||
kpair.writePublicKey(publicKeyPath, "Auto generated Key");
|
kpair.writePublicKey(publicKeyPath, comment);
|
||||||
kpair.dispose();
|
kpair.dispose();
|
||||||
} catch (JSchException ex) {
|
} catch (JSchException ex) {
|
||||||
Log.d("GenerateSSHKeys", ex.toString());
|
Log.d("GenerateSSHKeys", ex.toString());
|
||||||
|
@ -118,7 +118,12 @@ public class MainActivity extends FlutterActivity {
|
|||||||
new GitCommitTask(result).execute(cloneLocation, authorName, authorEmail, message);
|
new GitCommitTask(result).execute(cloneLocation, authorName, authorEmail, message);
|
||||||
return;
|
return;
|
||||||
} else if (call.method.equals("generateSSHKeys")) {
|
} 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user