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 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;

View File

@ -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<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()) {
@ -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<String, String[]> env = new HashMap<String, String[]>();
env.put(JMXConnector.CREDENTIALS,
new String[] {userName, password});
if (isVmConnector()) {

View File

@ -55,6 +55,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener {
private VMInternalFrame vmIF = null;
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.
@ -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,6 +461,10 @@ 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;
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) {
connect();
} else if (value == Messages.INSECURE) {
shouldUseSSL = false;
connect();
} else if (!everConnected) {
try {
getFrame().setClosed(true);

View File

@ -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.<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?
CONNECTING_TO1=Connecting to {0}
CONNECTING_TO2=You are currently being connected to {0}.<br>This will take a few moments.