Search in sources :

Example 1 with CredentialsProviderProvider

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;
}
Also used : BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProviderProvider(org.apache.solr.client.solrj.impl.SolrHttpClientBuilder.CredentialsProviderProvider) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Aggregations

UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)1 CredentialsProvider (org.apache.http.client.CredentialsProvider)1 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)1 CredentialsProviderProvider (org.apache.solr.client.solrj.impl.SolrHttpClientBuilder.CredentialsProviderProvider)1