8003703: Update RMI connection dialog box

Reviewed-by: skoivu, ahgross, mchung, jbachorik
This commit is contained in:
Staffan Larsen 2013-03-19 13:26:42 +01:00
parent 77302c24fb
commit 0244671a23
4 changed files with 25 additions and 8 deletions

View File

@ -156,6 +156,7 @@ final public class Messages {
public static String IMPACT; public static String IMPACT;
public static String INFO; public static String INFO;
public static String INFO_CAPITALIZED; public static String INFO_CAPITALIZED;
public static String INSECURE;
public static String INVALID_PLUGIN_PATH; public static String INVALID_PLUGIN_PATH;
public static String INVALID_URL; public static String INVALID_URL;
public static String IS; public static String IS;
@ -303,6 +304,8 @@ final public class Messages {
public static String WRITABLE; public static String WRITABLE;
public static String CONNECTION_FAILED1; public static String CONNECTION_FAILED1;
public static String CONNECTION_FAILED2; 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 CONNECTION_LOST1;
public static String CONNECTING_TO1; public static String CONNECTING_TO1;
public static String CONNECTING_TO2; public static String CONNECTING_TO2;

View File

@ -307,10 +307,10 @@ public class ProxyClient implements JConsoleContext {
} }
} }
void connect() { void connect(boolean requireSSL) {
setConnectionState(ConnectionState.CONNECTING); setConnectionState(ConnectionState.CONNECTING);
try { try {
tryConnect(); tryConnect(requireSSL);
setConnectionState(ConnectionState.CONNECTED); setConnectionState(ConnectionState.CONNECTED);
} catch (Exception e) { } catch (Exception e) {
if (JConsole.isDebug()) { 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) { if (jmxUrl == null && "localhost".equals(hostName) && port == 0) {
// Monitor self // Monitor self
this.jmxc = null; this.jmxc = null;
@ -340,6 +340,10 @@ public class ProxyClient implements JConsoleContext {
this.jmxUrl = new JMXServiceURL(lvm.connectorAddress()); 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 ? // Need to pass in credentials ?
if (userName == null && password == null) { if (userName == null && password == null) {
if (isVmConnector()) { if (isVmConnector()) {
@ -348,12 +352,11 @@ public class ProxyClient implements JConsoleContext {
checkSslConfig(); checkSslConfig();
} }
this.jmxc = new RMIConnector(stub, null); this.jmxc = new RMIConnector(stub, null);
jmxc.connect(); jmxc.connect(env);
} else { } else {
this.jmxc = JMXConnectorFactory.connect(jmxUrl); this.jmxc = JMXConnectorFactory.connect(jmxUrl, env);
} }
} else { } else {
Map<String, String[]> env = new HashMap<String, String[]>();
env.put(JMXConnector.CREDENTIALS, env.put(JMXConnector.CREDENTIALS,
new String[] {userName, password}); new String[] {userName, password});
if (isVmConnector()) { if (isVmConnector()) {

View File

@ -55,6 +55,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener {
private VMInternalFrame vmIF = null; private VMInternalFrame vmIF = null;
private static ArrayList<TabInfo> tabInfos = new ArrayList<TabInfo>(); private static ArrayList<TabInfo> tabInfos = new ArrayList<TabInfo>();
private boolean wasConnected = false; private boolean wasConnected = false;
private boolean shouldUseSSL = true;
// The everConnected flag keeps track of whether the window can be // The everConnected flag keeps track of whether the window can be
// closed if the user clicks Cancel after a failed connection attempt. // 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") { new Thread("VMPanel.connect") {
public void run() { public void run() {
proxyClient.connect(); proxyClient.connect(shouldUseSSL);
} }
}.start(); }.start();
} }
@ -460,6 +461,10 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener {
msgTitle = Messages.CONNECTION_LOST1; msgTitle = Messages.CONNECTION_LOST1;
msgExplanation = Resources.format(Messages.CONNECTING_TO2, getConnectionName()); msgExplanation = Resources.format(Messages.CONNECTING_TO2, getConnectionName());
buttonStr = Messages.RECONNECT; buttonStr = Messages.RECONNECT;
} else if (shouldUseSSL) {
msgTitle = Messages.CONNECTION_FAILED_SSL1;
msgExplanation = Resources.format(Messages.CONNECTION_FAILED_SSL2, getConnectionName());
buttonStr = Messages.INSECURE;
} else { } else {
msgTitle = Messages.CONNECTION_FAILED1; msgTitle = Messages.CONNECTION_FAILED1;
msgExplanation = Resources.format(Messages.CONNECTION_FAILED2, getConnectionName()); msgExplanation = Resources.format(Messages.CONNECTION_FAILED2, getConnectionName());
@ -483,6 +488,9 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener {
if (value == Messages.RECONNECT || value == Messages.CONNECT) { if (value == Messages.RECONNECT || value == Messages.CONNECT) {
connect(); connect();
} else if (value == Messages.INSECURE) {
shouldUseSSL = false;
connect();
} else if (!everConnected) { } else if (!everConnected) {
try { try {
getFrame().setClosed(true); getFrame().setClosed(true);

View File

@ -114,6 +114,7 @@ HOTSPOT_MBEANS_DIALOG_ACCESSIBLE_DESCRIPTION=Dialog for managing Hotspot MBeans
IMPACT=Impact IMPACT=Impact
INFO=Info INFO=Info
INFO_CAPITALIZED=INFO INFO_CAPITALIZED=INFO
INSECURE=Insecure connection
INVALID_PLUGIN_PATH=Warning: Invalid plugin path: {0} INVALID_PLUGIN_PATH=Warning: Invalid plugin path: {0}
INVALID_URL=Invalid URL: {0} INVALID_URL=Invalid URL: {0}
IS=Is IS=Is
@ -261,6 +262,8 @@ WINDOWS=Windows
WRITABLE=Writable WRITABLE=Writable
CONNECTION_FAILED1=Connection Failed: Retry? CONNECTION_FAILED1=Connection Failed: Retry?
CONNECTION_FAILED2=The connection to {0} did not succeed.<br>Would you like to try again? CONNECTION_FAILED2=The connection to {0} did not succeed.<br>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.<br>Would you like to try without SSL?<br>(Username and password will be sent in plain text.)
CONNECTION_LOST1=Connection Lost: Reconnect? CONNECTION_LOST1=Connection Lost: Reconnect?
CONNECTING_TO1=Connecting to {0} CONNECTING_TO1=Connecting to {0}
CONNECTING_TO2=You are currently being connected to {0}.<br>This will take a few moments. CONNECTING_TO2=You are currently being connected to {0}.<br>This will take a few moments.