Search in sources :

Example 1 with HttpClientBuilderPlugin

use of org.apache.solr.security.HttpClientBuilderPlugin in project lucene-solr by apache.

the class CloserThread method setupHttpClientForAuthPlugin.

private void setupHttpClientForAuthPlugin(Object authcPlugin) {
    if (authcPlugin instanceof HttpClientBuilderPlugin) {
        // Setup HttpClient for internode communication
        SolrHttpClientBuilder builder = ((HttpClientBuilderPlugin) authcPlugin).getHttpClientBuilder(HttpClientUtil.getHttpClientBuilder());
        // The default http client of the core container's shardHandlerFactory has already been created and
        // configured using the default httpclient configurer. We need to reconfigure it using the plugin's
        // http client configurer to set it up for internode communication.
        log.debug("Reconfiguring HttpClient settings.");
        SolrHttpClientContextBuilder httpClientBuilder = new SolrHttpClientContextBuilder();
        if (builder.getCredentialsProviderProvider() != null) {
            httpClientBuilder.setDefaultCredentialsProvider(new CredentialsProviderProvider() {

                @Override
                public CredentialsProvider getCredentialsProvider() {
                    return builder.getCredentialsProviderProvider().getCredentialsProvider();
                }
            });
        }
        if (builder.getAuthSchemeRegistryProvider() != null) {
            httpClientBuilder.setAuthSchemeRegistryProvider(new AuthSchemeRegistryProvider() {

                @Override
                public Lookup<AuthSchemeProvider> getAuthSchemeRegistry() {
                    return builder.getAuthSchemeRegistryProvider().getAuthSchemeRegistry();
                }
            });
        }
        HttpClientUtil.setHttpClientRequestContextBuilder(httpClientBuilder);
    } else {
        if (pkiAuthenticationPlugin != null) {
            //this happened due to an authc plugin reload. no need to register the pkiAuthc plugin again
            if (pkiAuthenticationPlugin.isInterceptorRegistered())
                return;
            log.info("PKIAuthenticationPlugin is managing internode requests");
            setupHttpClientForAuthPlugin(pkiAuthenticationPlugin);
            pkiAuthenticationPlugin.setInterceptorRegistered();
        }
    }
}
Also used : SolrHttpClientBuilder(org.apache.solr.client.solrj.impl.SolrHttpClientBuilder) CredentialsProviderProvider(org.apache.solr.client.solrj.impl.SolrHttpClientContextBuilder.CredentialsProviderProvider) HttpClientBuilderPlugin(org.apache.solr.security.HttpClientBuilderPlugin) Lookup(org.apache.http.config.Lookup) CredentialsProvider(org.apache.http.client.CredentialsProvider) AuthSchemeRegistryProvider(org.apache.solr.client.solrj.impl.SolrHttpClientContextBuilder.AuthSchemeRegistryProvider) SolrHttpClientContextBuilder(org.apache.solr.client.solrj.impl.SolrHttpClientContextBuilder)

Aggregations

CredentialsProvider (org.apache.http.client.CredentialsProvider)1 Lookup (org.apache.http.config.Lookup)1 SolrHttpClientBuilder (org.apache.solr.client.solrj.impl.SolrHttpClientBuilder)1 SolrHttpClientContextBuilder (org.apache.solr.client.solrj.impl.SolrHttpClientContextBuilder)1 AuthSchemeRegistryProvider (org.apache.solr.client.solrj.impl.SolrHttpClientContextBuilder.AuthSchemeRegistryProvider)1 CredentialsProviderProvider (org.apache.solr.client.solrj.impl.SolrHttpClientContextBuilder.CredentialsProviderProvider)1 HttpClientBuilderPlugin (org.apache.solr.security.HttpClientBuilderPlugin)1