Commit aca49f2f authored by petter's avatar petter

Now also generates Certificates with passphrase

git-svn-id: https://www2.in.tum.de/repos/ttt/trunk@123 0463f305-d864-43cb-8a47-61cf597d4139
parent 7ad6685c
......@@ -41,7 +41,7 @@ public class KeyGen {
public static void generateKeys() {
JFileChooser chooser = new JFileChooser();
chooser.setSelectedFile(new File("id_dsa"));
chooser.setSelectedFile(new File("id_rsa"));
chooser.setDialogTitle("Choose name for key files");
chooser.setFileHidingEnabled(false);
int returnVal = chooser.showSaveDialog(TTT.getInstance());
......@@ -59,19 +59,18 @@ public class KeyGen {
comment += "@" + localhost;
} catch (Exception e) {}
int type = KeyPair.DSA;
int type = KeyPair.RSA;
JSch jsch = new JSch();
// TODO: with or without passprhase??
String passphrase = "";
// JTextField passphraseField = (JTextField) new JPasswordField(20);
// Object[] ob = { passphraseField };
// int result = JOptionPane.showConfirmDialog(null, ob, "Enter passphrase (empty for no passphrase)",
// JOptionPane.OK_CANCEL_OPTION);
// if (result == JOptionPane.OK_OPTION) {
// passphrase = passphraseField.getText();
// }
JTextField passphraseField = (JTextField) new JPasswordField(20);
Object[] ob = { passphraseField };
int result = JOptionPane.showConfirmDialog(null, ob, "Enter passphrase (empty for no passphrase)",
JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.OK_OPTION) {
passphrase = passphraseField.getText();
}
try {
KeyPair kpair = KeyPair.genKeyPair(jsch, type);
......@@ -87,6 +86,9 @@ public class KeyGen {
TTT.userPrefs.put("ssh_private_key", chooser.getSelectedFile().getAbsolutePath());
System.out.println("Private ssh key file set to '" + chooser.getSelectedFile().getAbsolutePath() + "'");
System.out.println("Public ssh key file set to '" + chooser.getSelectedFile().getAbsolutePath() + ".pub'");
JOptionPane.showMessageDialog(null, "Public ssh key file '"+chooser.getSelectedFile().getAbsolutePath() + ".pub' saved.\n Don't forget to install it on the TTT-Website.");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment