Example usage for org.apache.http.impl.client AbstractHttpClient getCredentialsProvider

List of usage examples for org.apache.http.impl.client AbstractHttpClient getCredentialsProvider

Introduction

In this page you can find the example usage for org.apache.http.impl.client AbstractHttpClient getCredentialsProvider.

Prototype

public synchronized final CredentialsProvider getCredentialsProvider() 

Source Link

Usage

From source file:org.springframework.data.solr.server.support.HttpSolrClientFactory.java

private void appendAuthentication(Credentials credentials, String authPolicy, SolrClient solrClient) {
    if (isHttpSolrClient(solrClient)) {
        HttpSolrClient httpSolrClient = (HttpSolrClient) solrClient;

        if (credentials != null && StringUtils.isNotBlank(authPolicy)
                && assertHttpClientInstance(httpSolrClient.getHttpClient())) {
            AbstractHttpClient httpClient = (AbstractHttpClient) httpSolrClient.getHttpClient();
            httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY), credentials);
            httpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF,
                    Collections.singletonList(authPolicy));
        }/* w w w.  j a  v a 2s .  c o  m*/
    }
}