Skip to content

Commit db59e91

Browse files
committed
Fix socks5 user password settings for Azure repo
Signed-off-by: Andrey Pleskach <[email protected]>
1 parent a9b6d7a commit db59e91

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureStorageService.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
import org.opensearch.core.common.unit.ByteSizeValue;
6060

6161
import java.io.IOException;
62-
import java.net.Authenticator;
63-
import java.net.PasswordAuthentication;
6462
import java.net.URISyntaxException;
6563
import java.security.AccessController;
6664
import java.security.InvalidKeyException;
@@ -209,15 +207,11 @@ private ClientState buildClient(AzureStorageSettings azureStorageSettings, BiCon
209207
SocketAccess.doPrivilegedVoidException(() -> {
210208
final ProxySettings proxySettings = azureStorageSettings.getProxySettings();
211209
if (proxySettings != ProxySettings.NO_PROXY_SETTINGS) {
210+
final ProxyOptions proxyOptions = new ProxyOptions(proxySettings.getType().toProxyType(), proxySettings.getAddress());
212211
if (proxySettings.isAuthenticated()) {
213-
Authenticator.setDefault(new Authenticator() {
214-
@Override
215-
protected PasswordAuthentication getPasswordAuthentication() {
216-
return new PasswordAuthentication(proxySettings.getUsername(), proxySettings.getPassword().toCharArray());
217-
}
218-
});
212+
proxyOptions.setCredentials(proxySettings.getUsername(), proxySettings.getPassword());
219213
}
220-
clientBuilder.proxy(new ProxyOptions(proxySettings.getType().toProxyType(), proxySettings.getAddress()));
214+
clientBuilder.proxy(proxyOptions);
221215
}
222216
});
223217

0 commit comments

Comments
 (0)