changeset 5320:0be71a3ae825

8003703: Update RMI connection dialog box Reviewed-by: skoivu, ahgross, mchung, jbachorik
author sla
date Mon, 18 Mar 2013 15:22:51 +0100
parents 84621182e69f
children 299a33335080
files src/share/classes/sun/tools/jconsole/ProxyClient.java src/share/classes/sun/tools/jconsole/VMPanel.java src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java
diffstat 3 files changed, 24 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/tools/jconsole/ProxyClient.java	Fri Apr 05 08:33:25 2013 -0400
+++ b/src/share/classes/sun/tools/jconsole/ProxyClient.java	Mon Mar 18 15:22:51 2013 +0100
@@ -308,10 +308,10 @@
         }
     }
 
-    void connect() {
+    void connect(boolean requireSSL) {
         setConnectionState(ConnectionState.CONNECTING);
         try {
-            tryConnect();
+            tryConnect(requireSSL);
             setConnectionState(ConnectionState.CONNECTED);
         } catch (Exception e) {
             if (JConsole.isDebug()) {
@@ -321,7 +321,7 @@
         }
     }
 
-    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;
@@ -341,6 +341,10 @@
                     this.jmxUrl = new JMXServiceURL(lvm.connectorAddress());
                 }
             }
+            Map<String, Object> env = new HashMap<String, Object>();
+            if (requireRemoteSSL) {
+                env.put("jmx.remote.x.check.stub", "true");
+            }
             // Need to pass in credentials ?
             if (userName == null && password == null) {
                 if (isVmConnector()) {
@@ -349,12 +353,11 @@
                         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<String, String[]> env = new HashMap<String, String[]>();
                 env.put(JMXConnector.CREDENTIALS,
                         new String[] {userName, password});
                 if (isVmConnector()) {
--- a/src/share/classes/sun/tools/jconsole/VMPanel.java	Fri Apr 05 08:33:25 2013 -0400
+++ b/src/share/classes/sun/tools/jconsole/VMPanel.java	Mon Mar 18 15:22:51 2013 +0100
@@ -60,6 +60,7 @@
             "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
     private static ArrayList<TabInfo> tabInfos = new ArrayList<TabInfo>();
     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.
@@ -292,7 +293,7 @@
             new Thread("VMPanel.connect") {
 
                 public void run() {
-                    proxyClient.connect();
+                    proxyClient.connect(shouldUseSSL);
                 }
             }.start();
         }
@@ -464,6 +465,7 @@
 
         final String connectStr = getText("Connect");
         final String reconnectStr = getText("Reconnect");
+        final String insecureStr = getText("Insecure");
         final String cancelStr = getText("Cancel");
 
         String msgTitle, msgExplanation, buttonStr;
@@ -473,6 +475,10 @@
             msgTitle = getText("connectionLost1");
             msgExplanation = getText("connectionLost2", getConnectionName());
             buttonStr = reconnectStr;
+        } else if (shouldUseSSL) {
+            msgTitle = getText("connectionFailedSSL1");
+            msgExplanation = getText("connectionFailedSSL2", getConnectionName());
+            buttonStr = insecureStr;
         } else {
             msgTitle = getText("connectionFailed1");
             msgExplanation = getText("connectionFailed2", getConnectionName());
@@ -496,6 +502,9 @@
 
                     if (value == reconnectStr || value == connectStr) {
                         connect();
+                    } else if (value == insecureStr) {
+                        shouldUseSSL = false;
+                        connect();
                     } else if (!everConnected) {
                         try {
                             getFrame().setClosed(true);
--- a/src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java	Fri Apr 05 08:33:25 2013 -0400
+++ b/src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java	Mon Mar 18 15:22:51 2013 +0100
@@ -210,6 +210,7 @@
         {"Impact","Impact"},
         {"Info","Info"},
         {"INFO","INFO"},
+        {"Insecure", "Insecure connection"},
         {"Invalid plugin path", "Warning: Invalid plugin path: {0}"},
         {"Invalid URL", "Invalid URL: {0}"},
         {"Is","Is"},
@@ -415,6 +416,10 @@
         {"connectionFailed1","Connection Failed: Retry?"},
         {"connectionFailed2","The connection to {0} did not succeed.<br>" +
                              "Would you like to try again?"},
+        {"connectionFailedSSL1","Secure connection failed. Retry insecurely?"},
+        {"connectionFailedSSL2","The connection to {0} could not be made using SSL.<br>" +
+                             "Would you like to try without SSL?<br>" +
+                             "(Username and password will be sent in plain text.)"},
         {"connectionLost1","Connection Lost: Reconnect?"},
         {"connectionLost2","The connection to {0} has been lost " +
                            "because the remote process has been terminated.<br>" +