diff --git a/jdk/src/share/classes/sun/tools/jconsole/Messages.java b/jdk/src/share/classes/sun/tools/jconsole/Messages.java index 27001f27ccc..c566a444749 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/Messages.java +++ b/jdk/src/share/classes/sun/tools/jconsole/Messages.java @@ -156,6 +156,7 @@ final public class Messages { public static String IMPACT; public static String INFO; public static String INFO_CAPITALIZED; + public static String INSECURE; public static String INVALID_PLUGIN_PATH; public static String INVALID_URL; public static String IS; @@ -303,6 +304,8 @@ final public class Messages { public static String WRITABLE; public static String CONNECTION_FAILED1; public static String CONNECTION_FAILED2; + public static String CONNECTION_FAILED_SSL1; + public static String CONNECTION_FAILED_SSL2; public static String CONNECTION_LOST1; public static String CONNECTING_TO1; public static String CONNECTING_TO2; diff --git a/jdk/src/share/classes/sun/tools/jconsole/ProxyClient.java b/jdk/src/share/classes/sun/tools/jconsole/ProxyClient.java index af7b4267f0b..301eae167c9 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/ProxyClient.java +++ b/jdk/src/share/classes/sun/tools/jconsole/ProxyClient.java @@ -307,10 +307,10 @@ public class ProxyClient implements JConsoleContext { } } - void connect() { + void connect(boolean requireSSL) { setConnectionState(ConnectionState.CONNECTING); try { - tryConnect(); + tryConnect(requireSSL); setConnectionState(ConnectionState.CONNECTED); } catch (Exception e) { if (JConsole.isDebug()) { @@ -320,7 +320,7 @@ public class ProxyClient implements JConsoleContext { } } - private void tryConnect() throws IOException { + private void tryConnect(boolean requireRemoteSSL) throws IOException { if (jmxUrl == null && "localhost".equals(hostName) && port == 0) { // Monitor self this.jmxc = null; @@ -340,6 +340,10 @@ public class ProxyClient implements JConsoleContext { this.jmxUrl = new JMXServiceURL(lvm.connectorAddress()); } } + Map env = new HashMap(); + if (requireRemoteSSL) { + env.put("jmx.remote.x.check.stub", "true"); + } // Need to pass in credentials ? if (userName == null && password == null) { if (isVmConnector()) { @@ -348,12 +352,11 @@ public class ProxyClient implements JConsoleContext { checkSslConfig(); } this.jmxc = new RMIConnector(stub, null); - jmxc.connect(); + jmxc.connect(env); } else { - this.jmxc = JMXConnectorFactory.connect(jmxUrl); + this.jmxc = JMXConnectorFactory.connect(jmxUrl, env); } } else { - Map env = new HashMap(); env.put(JMXConnector.CREDENTIALS, new String[] {userName, password}); if (isVmConnector()) { diff --git a/jdk/src/share/classes/sun/tools/jconsole/VMPanel.java b/jdk/src/share/classes/sun/tools/jconsole/VMPanel.java index ec403d5d3b8..94b71d9d254 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/VMPanel.java +++ b/jdk/src/share/classes/sun/tools/jconsole/VMPanel.java @@ -55,6 +55,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { private VMInternalFrame vmIF = null; private static ArrayList tabInfos = new ArrayList(); private boolean wasConnected = false; + private boolean shouldUseSSL = true; // The everConnected flag keeps track of whether the window can be // closed if the user clicks Cancel after a failed connection attempt. @@ -286,7 +287,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { new Thread("VMPanel.connect") { public void run() { - proxyClient.connect(); + proxyClient.connect(shouldUseSSL); } }.start(); } @@ -460,8 +461,12 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { msgTitle = Messages.CONNECTION_LOST1; msgExplanation = Resources.format(Messages.CONNECTING_TO2, getConnectionName()); buttonStr = Messages.RECONNECT; + } else if (shouldUseSSL) { + msgTitle = Messages.CONNECTION_FAILED_SSL1; + msgExplanation = Resources.format(Messages.CONNECTION_FAILED_SSL2, getConnectionName()); + buttonStr = Messages.INSECURE; } else { - msgTitle =Messages.CONNECTION_FAILED1; + msgTitle = Messages.CONNECTION_FAILED1; msgExplanation = Resources.format(Messages.CONNECTION_FAILED2, getConnectionName()); buttonStr = Messages.CONNECT; } @@ -483,6 +488,9 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { if (value == Messages.RECONNECT || value == Messages.CONNECT) { connect(); + } else if (value == Messages.INSECURE) { + shouldUseSSL = false; + connect(); } else if (!everConnected) { try { getFrame().setClosed(true); diff --git a/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties b/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties index b89146e9067..69d87aa1c7a 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties +++ b/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties @@ -114,6 +114,7 @@ HOTSPOT_MBEANS_DIALOG_ACCESSIBLE_DESCRIPTION=Dialog for managing Hotspot MBeans IMPACT=Impact INFO=Info INFO_CAPITALIZED=INFO +INSECURE=Insecure connection INVALID_PLUGIN_PATH=Warning: Invalid plugin path: {0} INVALID_URL=Invalid URL: {0} IS=Is @@ -261,6 +262,8 @@ WINDOWS=Windows WRITABLE=Writable CONNECTION_FAILED1=Connection Failed: Retry? CONNECTION_FAILED2=The connection to {0} did not succeed.
Would you like to try again? +CONNECTION_FAILED_SSL1=Secure connection failed. Retry insecurely? +CONNECTION_FAILED_SSL2=The connection to {0} could not be made using SSL.
Would you like to try without SSL?
(Username and password will be sent in plain text.) CONNECTION_LOST1=Connection Lost: Reconnect? CONNECTING_TO1=Connecting to {0} CONNECTING_TO2=You are currently being connected to {0}.
This will take a few moments.