You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Steven White <sw...@gmail.com> on 2015/09/28 23:15:03 UTC

Passing Basic Auth info to HttpSolrClient

Hi,

I'm using HttpSolrClient to connect to Solr.  Everything works until when I
enabled basic authentication in Jetty.  My question is, how do I pass to
SolrJ the basic auth info. so that I don't get a 401 error?

Thanks in advance

Steve

Re: Passing Basic Auth info to HttpSolrClient

Posted by Ishan Chattopadhyaya <ic...@gmail.com>.
In latest Solr release, you can use the basic auth plugins for
authentication instead of doing something at the Jetty level.
https://cwiki.apache.org/confluence/display/solr/Basic+Authentication+Plugin
Right at the end, there's a note on how to use SolrJ with this.

Also, there exists: https://issues.apache.org/jira/browse/SOLR-8053 which
is due in Solr 5.4 release.

On Wed, Sep 30, 2015 at 7:28 PM, Davis, Daniel (NIH/NLM) [C] <
daniel.davis@nih.gov> wrote:

> HttpSolrClient can accept the Apache Commons HttpClient in its constructor:
>
> https://lucene.apache.org/solr/5_3_1/solr-solrj/org/apache/solr/client/solrj/impl/HttpSolrClient.html
>
> You can use the HttpClientBuilder (
> http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/HttpClientBuilder.html),
> to build an HttpClient that does Basic Authentication, and then pass client
> to the SolrHttpClient constructor.
>
> A search on "HttpClientBuilder Basic Authentication" returned many hits,
> but here's one of them:
>
> http://www.baeldung.com/httpclient-4-basic-authentication
>
> Hope this helps,
>
> Dan Davis, Systems/Applications Architect (Contractor),
> Office of Computer and Communications Systems,
> National Library of Medicine, NIH
>
>
> -----Original Message-----
> From: Steven White [mailto:swhite4141@gmail.com]
> Sent: Tuesday, September 29, 2015 8:13 PM
> To: solr-user@lucene.apache.org
> Subject: Re: Passing Basic Auth info to HttpSolrClient
>
> Hi,
>
> Re-posting to see if anyone can help.  If my question is not clear, let me
> know.
>
> Thanks!
>
> Steve
>
> On Mon, Sep 28, 2015 at 5:15 PM, Steven White <sw...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I'm using HttpSolrClient to connect to Solr.  Everything works until
> > when I enabled basic authentication in Jetty.  My question is, how do
> > I pass to SolrJ the basic auth info. so that I don't get a 401 error?
> >
> > Thanks in advance
> >
> > Steve
> >
>

RE: Passing Basic Auth info to HttpSolrClient

Posted by "Davis, Daniel (NIH/NLM) [C]" <da...@nih.gov>.
HttpSolrClient can accept the Apache Commons HttpClient in its constructor:
	https://lucene.apache.org/solr/5_3_1/solr-solrj/org/apache/solr/client/solrj/impl/HttpSolrClient.html

You can use the HttpClientBuilder (http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/HttpClientBuilder.html),  to build an HttpClient that does Basic Authentication, and then pass client to the SolrHttpClient constructor.

A search on "HttpClientBuilder Basic Authentication" returned many hits, but here's one of them:

http://www.baeldung.com/httpclient-4-basic-authentication

Hope this helps,

Dan Davis, Systems/Applications Architect (Contractor),
Office of Computer and Communications Systems,
National Library of Medicine, NIH


-----Original Message-----
From: Steven White [mailto:swhite4141@gmail.com] 
Sent: Tuesday, September 29, 2015 8:13 PM
To: solr-user@lucene.apache.org
Subject: Re: Passing Basic Auth info to HttpSolrClient

Hi,

Re-posting to see if anyone can help.  If my question is not clear, let me know.

Thanks!

Steve

On Mon, Sep 28, 2015 at 5:15 PM, Steven White <sw...@gmail.com> wrote:

> Hi,
>
> I'm using HttpSolrClient to connect to Solr.  Everything works until 
> when I enabled basic authentication in Jetty.  My question is, how do 
> I pass to SolrJ the basic auth info. so that I don't get a 401 error?
>
> Thanks in advance
>
> Steve
>

Re: Passing Basic Auth info to HttpSolrClient

Posted by Steven White <sw...@gmail.com>.
Hi,

Re-posting to see if anyone can help.  If my question is not clear, let me
know.

Thanks!

Steve

On Mon, Sep 28, 2015 at 5:15 PM, Steven White <sw...@gmail.com> wrote:

> Hi,
>
> I'm using HttpSolrClient to connect to Solr.  Everything works until when
> I enabled basic authentication in Jetty.  My question is, how do I pass to
> SolrJ the basic auth info. so that I don't get a 401 error?
>
> Thanks in advance
>
> Steve
>