Changeset 7343 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2014-07-28T16:40:19+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r7335 r7343 445 445 // Check for insecure certificates to remove. 446 446 // This is Windows-dependant code but it can't go to preStartupHook (need i18n) neither startupHook (need to be called before remote control) 447 ((PlatformHookWindows)Main.platform).removeInsecureCertificates();447 PlatformHookWindows.removeInsecureCertificates(); 448 448 } catch (NoSuchAlgorithmException | CertificateException | KeyStoreException | IOException e) { 449 449 error(e); -
trunk/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java
r7335 r7343 9 9 import java.awt.event.ActionEvent; 10 10 import java.awt.event.ActionListener; 11 import java.io.IOException; 12 import java.security.GeneralSecurityException; 13 import java.security.KeyStore; 14 import java.security.KeyStoreException; 15 import java.security.NoSuchAlgorithmException; 16 import java.security.cert.CertificateException; 11 17 import java.util.LinkedHashMap; 12 18 import java.util.Map; … … 15 21 import javax.swing.BorderFactory; 16 22 import javax.swing.Box; 23 import javax.swing.JButton; 17 24 import javax.swing.JCheckBox; 18 25 import javax.swing.JLabel; 26 import javax.swing.JOptionPane; 19 27 import javax.swing.JPanel; 20 28 import javax.swing.JSeparator; … … 31 39 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler; 32 40 import org.openstreetmap.josm.tools.GBC; 41 import org.openstreetmap.josm.tools.PlatformHookWindows; 33 42 34 43 /** … … 61 70 private JCheckBox enableRemoteControl; 62 71 private JCheckBox enableHttpsSupport; 63 private JCheckBox loadInNewLayer = new JCheckBox(tr("Download objects to new layer")); 64 private JCheckBox alwaysAskUserConfirm = new JCheckBox(tr("Confirm all Remote Control actions manually")); 72 73 private JButton installCertificate; 74 private JButton uninstallCertificate; 75 76 private final JCheckBox loadInNewLayer = new JCheckBox(tr("Download objects to new layer")); 77 private final JCheckBox alwaysAskUserConfirm = new JCheckBox(tr("Confirm all Remote Control actions manually")); 65 78 66 79 @Override … … 91 104 remote.add(wrapper, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 5, 5)); 92 105 93 enableHttpsSupport = new JCheckBox(tr("Enable HTTPS support"), RemoteControl.PROP_REMOTECONTROL_HTTPS_ENABLED.get()); 106 boolean https = RemoteControl.PROP_REMOTECONTROL_HTTPS_ENABLED.get(); 107 108 enableHttpsSupport = new JCheckBox(tr("Enable HTTPS support"), https); 94 109 wrapper.add(enableHttpsSupport, GBC.eol().fill(GBC.HORIZONTAL)); 110 111 // Certificate installation only available on Windows for now, see #10033 112 if (Main.isPlatformWindows()) { 113 installCertificate = new JButton(tr("Install...")); 114 uninstallCertificate = new JButton(tr("Uninstall...")); 115 installCertificate.setToolTipText(tr("Install JOSM localhost certificate to system/browser root keystores")); 116 uninstallCertificate.setToolTipText(tr("Uninstall JOSM localhost certificate from system/browser root keystores")); 117 wrapper.add(new JLabel(tr("Certificate:")), GBC.std().insets(15, 5, 0, 0)); 118 wrapper.add(installCertificate, GBC.std().insets(5, 5, 0, 0)); 119 wrapper.add(uninstallCertificate, GBC.eol().insets(5, 5, 0, 0)); 120 enableHttpsSupport.addActionListener(new ActionListener() { 121 @Override 122 public void actionPerformed(ActionEvent e) { 123 installCertificate.setEnabled(enableHttpsSupport.isSelected()); 124 } 125 }); 126 installCertificate.addActionListener(new ActionListener() { 127 @Override 128 public void actionPerformed(ActionEvent e) { 129 try { 130 boolean changed = RemoteControlHttpsServer.setupPlatform( 131 RemoteControlHttpsServer.loadJosmKeystore()); 132 String msg = changed ? 133 tr("Certificate has been successfully installed.") : 134 tr("Certificate is already installed. Nothing to do."); 135 Main.info(msg); 136 JOptionPane.showMessageDialog(wrapper, msg); 137 } catch (IOException | GeneralSecurityException ex) { 138 Main.error(ex); 139 } 140 } 141 }); 142 uninstallCertificate.addActionListener(new ActionListener() { 143 @Override 144 public void actionPerformed(ActionEvent e) { 145 try { 146 String msg; 147 KeyStore ks = PlatformHookWindows.getRootKeystore(); 148 if (ks.containsAlias(RemoteControlHttpsServer.ENTRY_ALIAS)) { 149 Main.info(tr("Removing certificate {0} from root keystore.", RemoteControlHttpsServer.ENTRY_ALIAS)); 150 ks.deleteEntry(RemoteControlHttpsServer.ENTRY_ALIAS); 151 msg = tr("Certificate has been successfully uninstalled."); 152 } else { 153 msg = tr("Certificate is not installed. Nothing to do."); 154 } 155 Main.info(msg); 156 JOptionPane.showMessageDialog(wrapper, msg); 157 } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException ex) { 158 Main.error(ex); 159 } 160 } 161 }); 162 installCertificate.setEnabled(https); 163 } 164 95 165 wrapper.add(new JSeparator(), GBC.eop().fill(GBC.HORIZONTAL).insets(15, 5, 15, 5)); 96 166 … … 116 186 // 'setEnabled(false)' does not work for JLabel with html text, so do it manually 117 187 // FIXME: use QuadStateCheckBox to make checkboxes unset when disabled 188 if (installCertificate != null && uninstallCertificate != null) { 189 // Install certificate button is enabled if HTTPS is also enabled 190 installCertificate.setEnabled(enableRemoteControl.isSelected() && enableHttpsSupport.isSelected()); 191 // Uninstall certificate button is always enabled 192 uninstallCertificate.setEnabled(true); 193 } 118 194 } 119 195 };
Note:
See TracChangeset
for help on using the changeset viewer.