18
18
import java .io .IOException ;
19
19
import java .io .UncheckedIOException ;
20
20
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 ;
21
23
import org .apache .hc .client5 .http .auth .CredentialsProvider ;
24
+ import org .apache .hc .client5 .http .auth .NTCredentials ;
22
25
import org .apache .hc .client5 .http .config .RequestConfig ;
23
26
import org .apache .hc .client5 .http .impl .auth .BasicAuthCache ;
24
27
import org .apache .hc .client5 .http .impl .auth .BasicCredentialsProvider ;
@@ -37,8 +40,7 @@ private Apache5Utils() {
37
40
}
38
41
39
42
/**
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.
42
44
*
43
45
* @param entity The HTTP entity to wrap with a buffered HTTP entity.
44
46
* @return A new BufferedHttpEntity wrapping the specified entity.
@@ -69,27 +71,29 @@ public static HttpClientContext newClientContext(ProxyConfiguration proxyConfigu
69
71
*/
70
72
public static CredentialsProvider newProxyCredentialsProvider (ProxyConfiguration proxyConfiguration ) {
71
73
BasicCredentialsProvider provider = new BasicCredentialsProvider ();
72
- // TODO : NTCredentials is deprecated.
73
- // provider.setCredentials(newAuthScope(proxyConfiguration), newNtCredentials(proxyConfiguration));
74
+ provider .setCredentials (newAuthScope (proxyConfiguration ), newNtCredentials (proxyConfiguration ));
74
75
return provider ;
75
76
}
76
77
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
+ }
86
96
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
- // }
93
97
94
98
private static void addPreemptiveAuthenticationProxy (HttpClientContext clientContext ,
95
99
ProxyConfiguration proxyConfiguration ) {
@@ -107,5 +111,4 @@ private static void addPreemptiveAuthenticationProxy(HttpClientContext clientCon
107
111
clientContext .setAuthCache (authCache );
108
112
}
109
113
}
110
-
111
114
}
0 commit comments