Skip to content

Commit de4ab85

Browse files
committed
remove authentication from url
1 parent 335c14c commit de4ab85

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

java/src/org/openqa/selenium/remote/http/jdk/JdkHttpClient.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public class JdkHttpClient implements HttpClient {
108108

109109
Credentials credentials = config.credentials();
110110
String info = config.baseUri().getUserInfo();
111+
URI baseUri = config.baseUri();
112+
111113
if (info != null && !info.trim().isEmpty()) {
112114
String[] parts = info.split(":", 2);
113115
String username = parts[0];
@@ -121,6 +123,20 @@ protected PasswordAuthentication getPasswordAuthentication() {
121123
}
122124
};
123125
builder = builder.authenticator(authenticator);
126+
127+
// Remove credentials from URL
128+
try {
129+
config = ClientConfig.defaultConfig().baseUri(new URI(
130+
config.baseUri().getScheme(),
131+
null,
132+
config.baseUri().getHost(),
133+
config.baseUri().getPort(),
134+
config.baseUri().getPath(),
135+
config.baseUri().getQuery(),
136+
config.baseUri().getFragment()));
137+
} catch (URISyntaxException e) {
138+
LOG.log(Level.WARNING, "Could not strip credentials from URI", e);
139+
}
124140
} else if (credentials != null) {
125141
if (!(credentials instanceof UsernameAndPassword)) {
126142
throw new IllegalArgumentException(

0 commit comments

Comments
 (0)