Skip to content

Commit 247378a

Browse files
jisedlacthurka
authored andcommitted
CredentialsConfigurator, JmxModelImpl - use char[] for handling passwords - Fortify
1 parent 26c7213 commit 247378a

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

visualvm/jmx/src/com/sun/tools/visualvm/jmx/impl/CredentialsConfigurator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public String getUsername() {
7474
return usernameField.getText().trim();
7575
}
7676

77-
public String getPassword() {
78-
return new String(passwordField.getPassword());
77+
public char[] getPassword() {
78+
return passwordField.getPassword();
7979
}
8080

8181
private CredentialsConfigurator() {
@@ -94,8 +94,8 @@ private void update() {
9494
SwingUtilities.invokeLater(new Runnable() {
9595
public void run() {
9696
String username = getUsername();
97-
String password = getPassword();
98-
okButton.setEnabled(username.length() > 0 && password.length() > 0);
97+
char[] password = getPassword();
98+
okButton.setEnabled(username.length() > 0 && password.length > 0);
9999
}
100100
});
101101
}

visualvm/jmx/src/com/sun/tools/visualvm/jmx/impl/JmxModelImpl.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ private static class ProxyClient implements NotificationListener {
415415

416416
private ConnectionState connectionState = ConnectionState.DISCONNECTED;
417417
private volatile boolean isDead = true;
418-
private String userName = null;
419-
private String password = null;
418+
private String user = null;
419+
private char[] pword = null;
420420
private LocalVirtualMachine lvm;
421421
private JMXServiceURL jmxUrl = null;
422422
private Application app;
@@ -469,9 +469,9 @@ private ProxyClient(JmxModelImpl model, JMXServiceURL url, Application app,
469469
this.envProvider = envProvider;
470470
}
471471

472-
public void setCredentials(String userName, String password) {
473-
this.userName = userName;
474-
this.password = password;
472+
public void setCredentials(String user, char[] pword) {
473+
this.user = user;
474+
this.pword = pword;
475475
}
476476

477477
boolean hasSSLStubCheck() {
@@ -551,9 +551,8 @@ private void tryConnect() throws IOException {
551551
Map<String, Object> env = new HashMap();
552552
if (envProvider != null)
553553
env.putAll(envProvider.getEnvironment(app, app.getStorage()));
554-
if (userName != null || password != null)
555-
env.put(JMXConnector.CREDENTIALS,
556-
new String[] { userName, password });
554+
if (user != null || pword != null)
555+
env.put(JMXConnector.CREDENTIALS, new String[] { user, new String(pword) });
557556

558557
if (!insecure && mode != MODE_LOCAL && env.get(JMXConnector.CREDENTIALS) != null) {
559558
env.put("jmx.remote.x.check.stub", "true"); // NOI18N

0 commit comments

Comments
 (0)