GenerateSSHKey: Allow the comment to be customized

This commit is contained in:
Vishesh Handa
2019-01-09 10:53:03 +01:00
parent 5a8217105e
commit 03645c298a
2 changed files with 9 additions and 2 deletions

View File

@ -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());

View File

@ -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;
}