Skip to content

Commit 4ea443c

Browse files
committed
Added NTCredentials to keep backward compatibilty with Apache4.x
1 parent aa489a5 commit 4ea443c

File tree

1 file changed

+23
-20
lines changed
  • http-clients/apache5-client/src/main/java/software/amazon/awssdk/http/apache5/internal/utils

1 file changed

+23
-20
lines changed

http-clients/apache5-client/src/main/java/software/amazon/awssdk/http/apache5/internal/utils/Apache5Utils.java

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
import java.io.IOException;
1919
import java.io.UncheckedIOException;
2020
import org.apache.hc.client5.http.auth.AuthCache;
21+
import org.apache.hc.client5.http.auth.AuthScope;
22+
import org.apache.hc.client5.http.auth.Credentials;
2123
import org.apache.hc.client5.http.auth.CredentialsProvider;
24+
import org.apache.hc.client5.http.auth.NTCredentials;
2225
import org.apache.hc.client5.http.config.RequestConfig;
2326
import org.apache.hc.client5.http.impl.auth.BasicAuthCache;
2427
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
@@ -37,8 +40,7 @@ private Apache5Utils() {
3740
}
3841

3942
/**
40-
* Utility function for creating a new BufferedEntity and wrapping any errors
41-
* as a SdkClientException.
43+
* Utility function for creating a new BufferedEntity and wrapping any errors as a SdkClientException.
4244
*
4345
* @param entity The HTTP entity to wrap with a buffered HTTP entity.
4446
* @return A new BufferedHttpEntity wrapping the specified entity.
@@ -69,27 +71,29 @@ public static HttpClientContext newClientContext(ProxyConfiguration proxyConfigu
6971
*/
7072
public static CredentialsProvider newProxyCredentialsProvider(ProxyConfiguration proxyConfiguration) {
7173
BasicCredentialsProvider provider = new BasicCredentialsProvider();
72-
// TODO : NTCredentials is deprecated.
73-
// provider.setCredentials(newAuthScope(proxyConfiguration), newNtCredentials(proxyConfiguration));
74+
provider.setCredentials(newAuthScope(proxyConfiguration), newNtCredentials(proxyConfiguration));
7475
return provider;
7576
}
7677

77-
// /**
78-
// * Returns a new instance of NTCredentials used for proxy authentication.
79-
// */
80-
// private static Credentials newNtCredentials(ProxyConfiguration proxyConfiguration) {
81-
// return new NTCredentials(proxyConfiguration.username(),
82-
// proxyConfiguration.password(),
83-
// proxyConfiguration.ntlmWorkstation(),
84-
// proxyConfiguration.ntlmDomain());
85-
// }
78+
/**
79+
* Returns a new instance of NTCredentials used for proxy authentication.
80+
*/
81+
private static Credentials newNtCredentials(ProxyConfiguration proxyConfiguration) {
82+
return new NTCredentials(
83+
proxyConfiguration.username(),
84+
proxyConfiguration.password().toCharArray(),
85+
proxyConfiguration.ntlmWorkstation(),
86+
proxyConfiguration.ntlmDomain()
87+
);
88+
}
89+
90+
/**
91+
* Returns a new instance of AuthScope used for proxy authentication.
92+
*/
93+
private static AuthScope newAuthScope(ProxyConfiguration proxyConfiguration) {
94+
return new AuthScope(proxyConfiguration.host(), proxyConfiguration.port());
95+
}
8696

87-
// /**
88-
// * Returns a new instance of AuthScope used for proxy authentication.
89-
// */
90-
// private static AuthScope newAuthScope(ProxyConfiguration proxyConfiguration) {
91-
// return new AuthScope(proxyConfiguration.host(), proxyConfiguration.port());
92-
// }
9397

9498
private static void addPreemptiveAuthenticationProxy(HttpClientContext clientContext,
9599
ProxyConfiguration proxyConfiguration) {
@@ -107,5 +111,4 @@ private static void addPreemptiveAuthenticationProxy(HttpClientContext clientCon
107111
clientContext.setAuthCache(authCache);
108112
}
109113
}
110-
111114
}

0 commit comments

Comments
 (0)