Skip to content

Commit dcf007c

Browse files
committed
GH-512 save username and password when it was stored previously
1 parent 0045441 commit dcf007c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

visualvm/jmx/src/org/graalvm/visualvm/jmx/CredentialsProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public String getId() {
8181

8282
abstract boolean hasPassword(Storage storage);
8383

84-
abstract boolean isPersistent(Storage storage);
84+
public abstract boolean isPersistent(Storage storage);
8585

8686

8787
/**
@@ -144,7 +144,7 @@ private char[] getPassword(Storage storage) {
144144
boolean hasPassword(Storage storage) { return pword != null &&
145145
pword.length > 0; }
146146

147-
boolean isPersistent(Storage storage) { return persistent; }
147+
public boolean isPersistent(Storage storage) { return persistent; }
148148

149149
}
150150

@@ -196,7 +196,7 @@ boolean hasPassword(Storage storage) {
196196
return pword != null && pword.length>0;
197197
}
198198

199-
boolean isPersistent(Storage storage) {
199+
public boolean isPersistent(Storage storage) {
200200
return getUsername(storage) != null || hasPassword(storage);
201201
}
202202

visualvm/jmx/src/org/graalvm/visualvm/jmx/impl/ProxyClient.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.graalvm.visualvm.application.type.ApplicationType;
5252
import org.graalvm.visualvm.core.datasource.Storage;
5353
import org.graalvm.visualvm.core.datasource.descriptor.DataSourceDescriptor;
54+
import org.graalvm.visualvm.jmx.CredentialsProvider;
5455
import org.graalvm.visualvm.jmx.EnvironmentProvider;
5556
import org.graalvm.visualvm.tools.jmx.JmxModel;
5657
import org.openide.DialogDisplayer;
@@ -125,8 +126,13 @@ private ProxyClient(Application app, JMXServiceURL url, EnvironmentProvider envP
125126
}
126127

127128
void setCredentials(String user, char[] pword) {
128-
this.user = user;
129-
this.pword = pword;
129+
if (envProvider instanceof CredentialsProvider && ((CredentialsProvider)envProvider).isPersistent(app.getStorage())) {
130+
EnvironmentProvider epr = new CredentialsProvider.Custom(user, pword, true);
131+
epr.saveEnvironment(app.getStorage());
132+
} else {
133+
this.user = user;
134+
this.pword = pword;
135+
}
130136
}
131137

132138
boolean hasSSLStubCheck() {

0 commit comments

Comments
 (0)