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 "Ramirez, Paul M (388J)" <pa...@jpl.nasa.gov> on 2009/08/18 18:48:12 UTC

Passing a Cookie in SolrJ

Hi All,

The project I am working on is using Solr and OpenSSO (Sun's single sign on service). I need to write some sample code for our users that shows them how to query Solr and I would just like to point them to the SolrJ documentation but I can't see an easy way to be able to pass a cookie with the request. The cookie is needed to be able to get through the SSO layer but will just be ignored by Solr. I see that you are using Apache Commons Http Client and with that I would be able to write the cookie if I had access to the HttpMethod being used (GetMethod or PostMethod). However, I can not find an easy way to get access to this with SolrJ and thought I would ask before rewriting a simple example using only an ApacheHttpClient without the SolJ library. Thanks in advance for any pointers you may have.

Thanks,
Paul Ramirez

Re: Passing a Cookie in SolrJ

Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: Passing a Cookie in SolrJ
: In-Reply-To: <8e...@mail.gmail.com>

http://people.apache.org/~hossman/#threadhijack
Thread Hijacking on Mailing Lists

When starting a new discussion on a mailing list, please do not reply to 
an existing message, instead start a fresh email.  Even if you change the 
subject line of your email, other mail headers still track which thread 
you replied to and your question is "hidden" in that thread and gets less 
attention.   It makes following discussions in the mailing list archives 
particularly difficult.
See Also:  http://en.wikipedia.org/wiki/Thread_hijacking




-Hoss


Re: Passing a Cookie in SolrJ

Posted by Chris Hostetter <ho...@fucit.org>.
: > but I can't see an easy way to be able to pass a cookie with the request.
: > The cookie is needed to be able to get through the SSO layer but will just

Unless i'm remembering wrong, and HttpClient instance will manage cookies 
for you, so why not just document how your users can use an HttpClient 
instance to talk to a server that will set this cookie, and then reuse 
that HttpClient instance in your CommonsHttpSolrServer instance.

: > be ignored by Solr. I see that you are using Apache Commons Http Client and
: > with that I would be able to write the cookie if I had access to the
: > HttpMethod being used (GetMethod or PostMethod). However, I can not find an
: > easy way to get access to this with SolrJ and thought I would ask before

: There's no easy way I think. You can extend CommonsHttpSolrServer and
: override the request method. Copy/paste the code from
: CommonsHttpSolrServer#request and make the changes. It is not an elegant way
: but it will work.

If he really needs to hardcode the cookie value into code, wouldn't it be 
easier to extend HttpClient and modify the methods which take in an 
HttpMethod object to first set the cookie on those obejcts before 
delegating to super?



-Hoss


Re: Passing a Cookie in SolrJ

Posted by Lance Norskog <go...@gmail.com>.
SolrJ uses the Apache Commons HTTP client. This describes the authentication
system:
http://hc.apache.org/httpclient-3.x/authentication.html

<http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/auth/package-frame.html>
*This has code to use authentication*

https://issues.apache.org/jira/browse/SOLR-1238

You might be able to find an openSSO implementation for this. Or hack up a
simple one.

On Wed, Aug 19, 2009 at 5:48 AM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

>  On Tue, Aug 18, 2009 at 10:18 PM, Ramirez, Paul M (388J) <
> paul.m.ramirez@jpl.nasa.gov> wrote:
>
> > Hi All,
> >
> > The project I am working on is using Solr and OpenSSO (Sun's single sign
> on
> > service). I need to write some sample code for our users that shows them
> how
> > to query Solr and I would just like to point them to the SolrJ
> documentation
> > but I can't see an easy way to be able to pass a cookie with the request.
> > The cookie is needed to be able to get through the SSO layer but will
> just
> > be ignored by Solr. I see that you are using Apache Commons Http Client
> and
> > with that I would be able to write the cookie if I had access to the
> > HttpMethod being used (GetMethod or PostMethod). However, I can not find
> an
> > easy way to get access to this with SolrJ and thought I would ask before
> > rewriting a simple example using only an ApacheHttpClient without the
> SolJ
> > library. Thanks in advance for any pointers you may have.
> >
>
> There's no easy way I think. You can extend CommonsHttpSolrServer and
> override the request method. Copy/paste the code from
> CommonsHttpSolrServer#request and make the changes. It is not an elegant
> way
> but it will work.
>
> --
> Regards,
> Shalin Shekhar Mangar.
>



-- 
Lance Norskog
goksron@gmail.com

Re: Passing a Cookie in SolrJ

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Tue, Aug 18, 2009 at 10:18 PM, Ramirez, Paul M (388J) <
paul.m.ramirez@jpl.nasa.gov> wrote:

> Hi All,
>
> The project I am working on is using Solr and OpenSSO (Sun's single sign on
> service). I need to write some sample code for our users that shows them how
> to query Solr and I would just like to point them to the SolrJ documentation
> but I can't see an easy way to be able to pass a cookie with the request.
> The cookie is needed to be able to get through the SSO layer but will just
> be ignored by Solr. I see that you are using Apache Commons Http Client and
> with that I would be able to write the cookie if I had access to the
> HttpMethod being used (GetMethod or PostMethod). However, I can not find an
> easy way to get access to this with SolrJ and thought I would ask before
> rewriting a simple example using only an ApacheHttpClient without the SolJ
> library. Thanks in advance for any pointers you may have.
>

There's no easy way I think. You can extend CommonsHttpSolrServer and
override the request method. Copy/paste the code from
CommonsHttpSolrServer#request and make the changes. It is not an elegant way
but it will work.

-- 
Regards,
Shalin Shekhar Mangar.

RE: Passing a Cookie in SolrJ

Posted by Fuad Efendi <fu...@efendi.ca>.
> some sample code for our users that shows them how to query Solr

- I believe you don't have to use SolrJ to query Solr; SolrJ can query and
parse XML response from server; if your clients can use raw URL as a query
and raw XML (JSON etc.) as a response - you don't need SolrJ.

To  pass cookie with SolrJ you need modify source code... or may be you can
get access to core HttpClient objects via some configuration (singleton) and
pass default per-client cookie without altering SOLR


-----Original Message-----
From: Ramirez, Paul M (388J) [mailto:paul.m.ramirez@jpl.nasa.gov] 
Sent: August-18-09 12:48 PM
To: solr-user@lucene.apache.org
Subject: Passing a Cookie in SolrJ

Hi All,

The project I am working on is using Solr and OpenSSO (Sun's single sign on
service). I need to write some sample code for our users that shows them how
to query Solr and I would just like to point them to the SolrJ documentation
but I can't see an easy way to be able to pass a cookie with the request.
The cookie is needed to be able to get through the SSO layer but will just
be ignored by Solr. I see that you are using Apache Commons Http Client and
with that I would be able to write the cookie if I had access to the
HttpMethod being used (GetMethod or PostMethod). However, I can not find an
easy way to get access to this with SolrJ and thought I would ask before
rewriting a simple example using only an ApacheHttpClient without the SolJ
library. Thanks in advance for any pointers you may have.

Thanks,
Paul Ramirez