- Timestamp:
- 2017-08-31T17:52:05+02:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java
r12620 r12703 172 172 ActionListener remoteControlEnabled = e -> { 173 173 GuiHelper.setEnabledRec(wrapper, enableRemoteControl.isSelected()); 174 enableHttpsSupport.setEnabled(RemoteControl.supportsHttps()); 174 175 // 'setEnabled(false)' does not work for JLabel with html text, so do it manually 175 176 // FIXME: use QuadStateCheckBox to make checkboxes unset when disabled 176 177 if (installCertificate != null && uninstallCertificate != null) { 177 178 // Install certificate button is enabled if HTTPS is also enabled 178 installCertificate.setEnabled(enableRemoteControl.isSelected() && enableHttpsSupport.isSelected() );179 installCertificate.setEnabled(enableRemoteControl.isSelected() && enableHttpsSupport.isSelected() && RemoteControl.supportsHttps()); 179 180 // Uninstall certificate button is always enabled 180 uninstallCertificate.setEnabled( true);181 uninstallCertificate.setEnabled(RemoteControl.supportsHttps()); 181 182 } 182 183 }; -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java
r8510 r12703 11 11 import org.openstreetmap.josm.data.preferences.BooleanProperty; 12 12 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler; 13 import org.openstreetmap.josm.tools.Logging; 13 14 14 15 /** … … 47 48 public static void start() { 48 49 RemoteControlHttpServer.restartRemoteControlHttpServer(); 49 RemoteControlHttpsServer.restartRemoteControlHttpsServer(); 50 if (supportsHttps()) { 51 RemoteControlHttpsServer.restartRemoteControlHttpsServer(); 52 } 50 53 } 51 54 … … 56 59 public static void stop() { 57 60 RemoteControlHttpServer.stopRemoteControlHttpServer(); 58 RemoteControlHttpsServer.stopRemoteControlHttpsServer(); 61 if (supportsHttps()) { 62 RemoteControlHttpsServer.stopRemoteControlHttpsServer(); 63 } 64 } 65 66 /** 67 * Determines if the current JVM support HTTPS remote control. 68 * @return {@code true} if the JVM provides {@code sun.security.x509} classes 69 * @since 12703 70 */ 71 public static boolean supportsHttps() { 72 try { 73 return Class.forName("sun.security.x509.GeneralName") != null; 74 } catch (ClassNotFoundException e) { 75 Logging.trace(e); 76 return false; 77 } 59 78 } 60 79 -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r12620 r12703 1632 1632 int firstDotPos = version.indexOf('.'); 1633 1633 int lastDotPos = version.lastIndexOf('.'); 1634 if (firstDotPos == lastDotPos) { 1635 return 0; 1636 } 1634 1637 return firstDotPos > - 1 ? Integer.parseInt(version.substring(firstDotPos + 1, 1635 1638 lastDotPos > -1 ? lastDotPos : version.length())) : 0; … … 1645 1648 int bPos = version.indexOf('b'); 1646 1649 int pPos = version.indexOf('+'); 1647 return Integer.parseInt(version.substring(bPos > -1 ? bPos + 1 : pPos + 1, version.length())); 1650 try { 1651 return Integer.parseInt(version.substring(bPos > -1 ? bPos + 1 : pPos + 1, version.length())); 1652 } catch (NumberFormatException e) { 1653 Logging.trace(e); 1654 return 0; 1655 } 1648 1656 } 1649 1657 -
trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
r12217 r12703 225 225 String javaVersion = System.getProperty("java.version"); 226 226 try { 227 System.setProperty("java.version", "1.8.0"); 228 assertEquals(0, Utils.getJavaUpdate()); 229 227 230 System.setProperty("java.version", "1.8.0_131"); 228 231 assertEquals(131, Utils.getJavaUpdate()); … … 265 268 System.setProperty("java.runtime.version", "9.1.2+62"); 266 269 assertEquals(62, Utils.getJavaBuild()); 270 271 // IBM version example 272 System.setProperty("java.runtime.version", "pwa6480sr4fp7-20170627_02 (SR4 FP7)"); 273 assertEquals(0, Utils.getJavaBuild()); 274 267 275 } finally { 268 276 System.setProperty("java.runtime.version", javaVersion);
Note:
See TracChangeset
for help on using the changeset viewer.