Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Authentication capabilities for Proxy Settings #299

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,21 @@ private static Proxy proxyManager() {
Proxy proxy = new Proxy(getProxyScheme(proxyScheme), new InetSocketAddress(proxyHost, proxyPort));

if (proxyUser != null && proxyPass != null) {
// This Sets the authenticator that will be used by
// the networking code when a proxy or an HTTP server asks for authentication.
// This can lead to potential leak of authentication info by the application itself.
// Authenticator.setDefault(new Authenticator() {
// @Override
// protected PasswordAuthentication getPasswordAuthentication() {
// return new PasswordAuthentication(proxyUser, proxyPass.toCharArray());
// }
// });
// logger.log(LogLevel.FINER, "Authenticated proxy using username and password", WSClient.class.getName());
/**
* This Sets the authenticator that will be used by
* the networking code when a proxy or an HTTP server asks for authentication.
* This can lead to potential leak of authentication info by the application itself.
*/
// Requires System.setProperty("jdk.http.auth.tunneling.disabledSchemes", ""); reference https://github.com/TooTallNate/Java-WebSocket/issues/1179#issuecomment-2184917604
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
System.setProperty("jdk.http.auth.proxying.disabledSchemes", "");
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(proxyUser, proxyPass.toCharArray());
}
});
logger.log(LogLevel.FINER, "Authenticated proxy using username and password", WSClient.class.getName());
}
logger.log(LogLevel.FINER, String.format("Proxy being used to connect with WSS %s", proxy), WSClient.class.getName());
return proxy;
Expand Down
Loading