summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-12-05 17:36:16 -0500
committerJames Moger <james.moger@gitblit.com>2012-12-05 17:36:16 -0500
commitd63157b22bb8a7294080be29ca0fca8ecda96db9 (patch)
tree46b2b6f4d6b7e96580eda78a248fd52e2c0085f8
parentacb63a082e9497e3a1e2541f5e44587eada7c60b (diff)
downloadgitblit-d63157b22bb8a7294080be29ca0fca8ecda96db9.tar.gz
gitblit-d63157b22bb8a7294080be29ca0fca8ecda96db9.zip
Checkbox to automatically set the new ssl certificate alias
-rw-r--r--src/com/gitblit/authority/GitblitAuthority.java21
-rw-r--r--src/com/gitblit/authority/NewSSLCertificateDialog.java12
-rw-r--r--src/com/gitblit/wicket/GitBlitWebApp.properties4
3 files changed, 32 insertions, 5 deletions
diff --git a/src/com/gitblit/authority/GitblitAuthority.java b/src/com/gitblit/authority/GitblitAuthority.java
index d97a8e39..59cd22e3 100644
--- a/src/com/gitblit/authority/GitblitAuthority.java
+++ b/src/com/gitblit/authority/GitblitAuthority.java
@@ -607,7 +607,8 @@ public class GitblitAuthority extends JFrame implements X509Log {
}
final Date expires = dialog.getExpiration();
final String hostname = dialog.getHostname();
-
+ final boolean serveCertificate = dialog.isServeCertificate();
+
AuthorityWorker worker = new AuthorityWorker(GitblitAuthority.this) {
@Override
@@ -623,17 +624,31 @@ public class GitblitAuthority extends JFrame implements X509Log {
// generate new SSL certificate
X509Metadata metadata = new X509Metadata(hostname, caKeystorePassword);
+ setMetadataDefaults(metadata);
metadata.notAfter = expires;
File serverKeystoreFile = new File(folder, X509Utils.SERVER_KEY_STORE);
X509Certificate cert = X509Utils.newSSLCertificate(metadata, caPrivateKey, caCert, serverKeystoreFile, GitblitAuthority.this);
- return cert != null;
+ boolean hasCert = cert != null;
+ if (hasCert && serveCertificate) {
+ // update Gitblit https connector alias
+ Map<String, String> updates = new HashMap<String, String>();
+ updates.put(Keys.server.certificateAlias, metadata.commonName);
+ gitblitSettings.saveSettings(updates);
+ }
+ return hasCert;
}
@Override
protected void onSuccess() {
- JOptionPane.showMessageDialog(GitblitAuthority.this,
+ if (serveCertificate) {
+ JOptionPane.showMessageDialog(GitblitAuthority.this,
+ MessageFormat.format(Translation.get("gb.sslCertificateGeneratedRestart"), hostname),
+ Translation.get("gb.newSSLCertificate"), JOptionPane.INFORMATION_MESSAGE);
+ } else {
+ JOptionPane.showMessageDialog(GitblitAuthority.this,
MessageFormat.format(Translation.get("gb.sslCertificateGenerated"), hostname),
Translation.get("gb.newSSLCertificate"), JOptionPane.INFORMATION_MESSAGE);
+ }
}
};
diff --git a/src/com/gitblit/authority/NewSSLCertificateDialog.java b/src/com/gitblit/authority/NewSSLCertificateDialog.java
index 1ff542a2..821e9e9f 100644
--- a/src/com/gitblit/authority/NewSSLCertificateDialog.java
+++ b/src/com/gitblit/authority/NewSSLCertificateDialog.java
@@ -24,6 +24,7 @@ import java.awt.event.ActionListener;
import java.util.Date;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
@@ -41,6 +42,7 @@ public class NewSSLCertificateDialog extends JDialog {
JDateChooser expirationDate;
JTextField hostname;
+ JCheckBox serveCertificate;
boolean isCanceled = true;
public NewSSLCertificateDialog(Frame owner, Date defaultExpiration) {
@@ -60,6 +62,7 @@ public class NewSSLCertificateDialog extends JDialog {
expirationDate = new JDateChooser(defaultExpiration);
hostname = new JTextField(20);
+ serveCertificate = new JCheckBox(Translation.get("gb.serveCertificate"), true);
JPanel panel = new JPanel(new GridLayout(0, 2, Utils.MARGIN, Utils.MARGIN));
@@ -69,6 +72,9 @@ public class NewSSLCertificateDialog extends JDialog {
panel.add(new JLabel(Translation.get("gb.expires")));
panel.add(expirationDate);
+ panel.add(new JLabel(""));
+ panel.add(serveCertificate);
+
JButton ok = new JButton(Translation.get("gb.ok"));
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -123,7 +129,11 @@ public class NewSSLCertificateDialog extends JDialog {
public Date getExpiration() {
return expirationDate.getDate();
}
-
+
+ public boolean isServeCertificate() {
+ return serveCertificate.isSelected();
+ }
+
public boolean isCanceled() {
return isCanceled;
}
diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties
index 7ce75262..4f4d60e0 100644
--- a/src/com/gitblit/wicket/GitBlitWebApp.properties
+++ b/src/com/gitblit/wicket/GitBlitWebApp.properties
@@ -434,4 +434,6 @@ gb.jceWarning = Your Java Runtime Environment does not have the \"JCE Unlimited
gb.maxActivityCommits = max activity commits
gb.maxActivityCommitsDescription = maximum number of commits to contribute to the Activity page
gb.noMaximum = no maximum
-gb.attributes = attributes \ No newline at end of file
+gb.attributes = attributes
+gb.serveCertificate = serve https with this certificate
+gb.sslCertificateGeneratedRestart = Successfully generated new server SSL certificate for {0}.\nYou must restart Gitblit to use the new certificate.\n\nIf you are launching with the '--alias' parameter you will have to set that to ''--alias {0}''. \ No newline at end of file