Apache HTTP: support proxy authentication

Add a credentials provider that forwards to the java.net.Authenticator.
Needed to support proxies requiring authentication.

Bug: 549832
Change-Id: I181ee27a6c9f1b3fa402ce58affdd5ff3f7c96c9
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
Thomas Wolf 2019-08-11 22:46:44 +02:00
parent 7192d9aecd
commit 2abd3c43bd
1 changed files with 3 additions and 0 deletions

View File

@ -92,6 +92,7 @@
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.SystemDefaultCredentialsProvider;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.transport.http.HttpConnection;
@ -165,6 +166,8 @@ private HttpClient getClient() {
new BasicHttpClientConnectionManager(registry));
}
clientBuilder.setDefaultRequestConfig(configBuilder.build());
clientBuilder.setDefaultCredentialsProvider(
new SystemDefaultCredentialsProvider());
client = clientBuilder.build();
}