Changeset 12703 in josm for trunk/src/org


Ignore:
Timestamp:
2017-08-31T17:52:05+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #15210 - Fix support of IBM JVM

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java

    r12620 r12703  
    172172        ActionListener remoteControlEnabled = e -> {
    173173            GuiHelper.setEnabledRec(wrapper, enableRemoteControl.isSelected());
     174            enableHttpsSupport.setEnabled(RemoteControl.supportsHttps());
    174175            // 'setEnabled(false)' does not work for JLabel with html text, so do it manually
    175176            // FIXME: use QuadStateCheckBox to make checkboxes unset when disabled
    176177            if (installCertificate != null && uninstallCertificate != null) {
    177178                // 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());
    179180                // Uninstall certificate button is always enabled
    180                 uninstallCertificate.setEnabled(true);
     181                uninstallCertificate.setEnabled(RemoteControl.supportsHttps());
    181182            }
    182183        };
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java

    r8510 r12703  
    1111import org.openstreetmap.josm.data.preferences.BooleanProperty;
    1212import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler;
     13import org.openstreetmap.josm.tools.Logging;
    1314
    1415/**
     
    4748    public static void start() {
    4849        RemoteControlHttpServer.restartRemoteControlHttpServer();
    49         RemoteControlHttpsServer.restartRemoteControlHttpsServer();
     50        if (supportsHttps()) {
     51            RemoteControlHttpsServer.restartRemoteControlHttpsServer();
     52        }
    5053    }
    5154
     
    5659    public static void stop() {
    5760        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        }
    5978    }
    6079
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r12620 r12703  
    16321632        int firstDotPos = version.indexOf('.');
    16331633        int lastDotPos = version.lastIndexOf('.');
     1634        if (firstDotPos == lastDotPos) {
     1635            return 0;
     1636        }
    16341637        return firstDotPos > - 1 ? Integer.parseInt(version.substring(firstDotPos + 1,
    16351638                lastDotPos > -1 ? lastDotPos : version.length())) : 0;
     
    16451648        int bPos = version.indexOf('b');
    16461649        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        }
    16481656    }
    16491657
Note: See TracChangeset for help on using the changeset viewer.