You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by Rick Kellogg <rm...@comcast.net> on 2017/09/22 18:58:27 UTC

Java Client Examples

Greetings,

 

When using Knox against SOLR for any operation that requires a POST HTTP
action, the standard authentication mechanism in SOLRJ does not function.
The default challenge/response mechanism specifically prevents the replay of
operations.  As such I have had to construct a HttpSolrClient that uses
preauthentication.

 

Question: How to we provide this to our intended Knox users?  Do we want to
create another Knox project with sample clients showing authentication
bootstrap? Or potentially individual projects for different services?

 

Thoughts?

Rick Kellogg

 


Re: Java Client Examples

Posted by larry mccay <lm...@apache.org>.
I see...

The attachment didn't come through - maybe you need to file a JIRA and
attach it there.
We will need one anyway.

I think as long as we have KnoxShell client classes to go along with this
it would be great.
The question that I would have is whether we should consider revamping the
general programming model to use a builder pattern and just make this one
of the options.

It seems to me that that would be best but I will need to see more.

Thanks for the clarification!

--larry


On Fri, Sep 22, 2017 at 4:23 PM, Rick Kellogg <rm...@comcast.net> wrote:

> Larry,
>
> The recommended way to construct an SOLRJ HttpSolrClient is via the
> HttpSolrClient.Builder class.  The Builder shields the client from any and
> all access to the Apache HttpClient.  So I have created a new replacement
> for the HttpSolrClient.Builder class which basically bootstraps the header
> information to include basic authentication information.
>
> For normal GET operations the normal challenge response mechanism would
> work.  If we do a POST operation, the SOLRJ API will refuse to retry the
> operation since it could cause duplicate records to be created, etc.  Hence
> the need for the preemptive authentication to prevent the failure.
>
> Usage would be as follows:
>
> SolrClient client = new PreemptiveHttpSolrClient.Builder()
>                                          .withBaseSolrURL("https://
> host:8443/gateway/solr/core1")
>                                          .withPreemptiveBasicAuthCredent
> ials("user","pwd")
>                                          .build();
>
> Yes it should be a replacement for HttpClient within KnoxShell with
> appropriate credentials.
>
> I have attached the Builder class.
>
> Hope that helps clarify the matter.
> Rick
>
> -----Original Message-----
> From: larry mccay [mailto:lmccay@apache.org]
> Sent: Friday, September 22, 2017 3:38 PM
> To: dev@knox.apache.org
> Subject: Re: Java Client Examples
>
> Hi Rick -
>
> This is an interesting question.
> Unfortunately, I think that I need more information here.
>
> I may need to see the client you are talking about and a sample of its use
> to understand properly.
>
> Is this a drop-in replacement for the HttpClient being used in KnoxShell?
>
> thanks,
>
> --larry
>
> On Fri, Sep 22, 2017 at 2:58 PM, Rick Kellogg <rm...@comcast.net>
> wrote:
>
> > Greetings,
> >
> >
> >
> > When using Knox against SOLR for any operation that requires a POST
> > HTTP action, the standard authentication mechanism in SOLRJ does not
> function.
> > The default challenge/response mechanism specifically prevents the
> > replay of operations.  As such I have had to construct a
> > HttpSolrClient that uses preauthentication.
> >
> >
> >
> > Question: How to we provide this to our intended Knox users?  Do we
> > want to create another Knox project with sample clients showing
> > authentication bootstrap? Or potentially individual projects for
> different services?
> >
> >
> >
> > Thoughts?
> >
> > Rick Kellogg
> >
> >
> >
> >
>

RE: Java Client Examples

Posted by Rick Kellogg <rm...@comcast.net>.
Larry,

The recommended way to construct an SOLRJ HttpSolrClient is via the HttpSolrClient.Builder class.  The Builder shields the client from any and all access to the Apache HttpClient.  So I have created a new replacement for the HttpSolrClient.Builder class which basically bootstraps the header information to include basic authentication information.   

For normal GET operations the normal challenge response mechanism would work.  If we do a POST operation, the SOLRJ API will refuse to retry the operation since it could cause duplicate records to be created, etc.  Hence the need for the preemptive authentication to prevent the failure.

Usage would be as follows:

SolrClient client = new PreemptiveHttpSolrClient.Builder()
                                         .withBaseSolrURL("https://host:8443/gateway/solr/core1")
                                         .withPreemptiveBasicAuthCredentials("user","pwd")
                                         .build();

Yes it should be a replacement for HttpClient within KnoxShell with appropriate credentials.

I have attached the Builder class.  

Hope that helps clarify the matter.
Rick

-----Original Message-----
From: larry mccay [mailto:lmccay@apache.org] 
Sent: Friday, September 22, 2017 3:38 PM
To: dev@knox.apache.org
Subject: Re: Java Client Examples

Hi Rick -

This is an interesting question.
Unfortunately, I think that I need more information here.

I may need to see the client you are talking about and a sample of its use to understand properly.

Is this a drop-in replacement for the HttpClient being used in KnoxShell?

thanks,

--larry

On Fri, Sep 22, 2017 at 2:58 PM, Rick Kellogg <rm...@comcast.net> wrote:

> Greetings,
>
>
>
> When using Knox against SOLR for any operation that requires a POST 
> HTTP action, the standard authentication mechanism in SOLRJ does not function.
> The default challenge/response mechanism specifically prevents the 
> replay of operations.  As such I have had to construct a 
> HttpSolrClient that uses preauthentication.
>
>
>
> Question: How to we provide this to our intended Knox users?  Do we 
> want to create another Knox project with sample clients showing 
> authentication bootstrap? Or potentially individual projects for different services?
>
>
>
> Thoughts?
>
> Rick Kellogg
>
>
>
>

Re: Java Client Examples

Posted by larry mccay <lm...@apache.org>.
Hi Rick -

This is an interesting question.
Unfortunately, I think that I need more information here.

I may need to see the client you are talking about and a sample of its use
to understand properly.

Is this a drop-in replacement for the HttpClient being used in KnoxShell?

thanks,

--larry

On Fri, Sep 22, 2017 at 2:58 PM, Rick Kellogg <rm...@comcast.net> wrote:

> Greetings,
>
>
>
> When using Knox against SOLR for any operation that requires a POST HTTP
> action, the standard authentication mechanism in SOLRJ does not function.
> The default challenge/response mechanism specifically prevents the replay
> of
> operations.  As such I have had to construct a HttpSolrClient that uses
> preauthentication.
>
>
>
> Question: How to we provide this to our intended Knox users?  Do we want to
> create another Knox project with sample clients showing authentication
> bootstrap? Or potentially individual projects for different services?
>
>
>
> Thoughts?
>
> Rick Kellogg
>
>
>
>