List of usage examples for org.apache.http.impl.client HttpClientBuilder setDefaultCredentialsProvider
public final HttpClientBuilder setDefaultCredentialsProvider(final CredentialsProvider credentialsProvider)
From source file:org.xwiki.extension.repository.http.internal.DefaultHttpClientFactory.java
@Override public HttpClientBuilder createHttpClientBuilder(String user, String password) { HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); // Pre-configure with everything configured at JVM level httpClientBuilder.useSystemProperties(); // Setup user agent httpClientBuilder.setUserAgent(this.configuration.getUserAgent()); // Setup authentication if (user != null) { CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(user, password)); httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); }/*from ww w . j av a 2s. c o m*/ return httpClientBuilder; }