use of org.apache.solr.client.solrj.impl.SolrHttpClientBuilder.CredentialsProviderProvider in project lucene-solr by apache.
the class PreemptiveBasicAuthClientBuilderFactory method initHttpClientBuilder.
private SolrHttpClientBuilder initHttpClientBuilder(SolrHttpClientBuilder builder) {
final String basicAuthUser = defaultParams.get(HttpClientUtil.PROP_BASIC_AUTH_USER);
final String basicAuthPass = defaultParams.get(HttpClientUtil.PROP_BASIC_AUTH_PASS);
if (basicAuthUser == null || basicAuthPass == null) {
throw new IllegalArgumentException("username & password must be specified with " + getClass().getName());
}
builder.setDefaultCredentialsProvider(new CredentialsProviderProvider() {
@Override
public CredentialsProvider getCredentialsProvider() {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(basicAuthUser, basicAuthPass));
return credsProvider;
}
});
HttpClientUtil.addRequestInterceptor(requestInterceptor);
return builder;
}
Aggregations