You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by David Radio <da...@gmail.com> on 2014/09/04 18:33:30 UTC

Setting Value for "From" Request Header

Hello Everyone,

My goal is to count all of the incoming CMIS calls and then slice that
information by who is making the calls.

I was wondering if it is possible to achieve this goal without making any
code changes to the Apache Chemistry CMIS Server Framework or Apache
Chemistry CMIS Client API.

For instance, can I use the existing Apache Chemistry Java Client API to
set a value for the "From" request header?

Thanks!
Dave

Re: Setting Value for "From" Request Header

Posted by David Radio <da...@gmail.com>.
Florian,

The following suggestion is perfect!

parameters.put(SessionParameter.HEADER + ".0", "From:Dave");

Thank You!
Dave


On Friday, September 5, 2014, Florian Müller <fm...@apache.org> wrote:

> Hi Dave,
>
> You can set HTTP headers via the session parameters or - if you need more
> logic
> - you can implement your own authentication provider.
>
> To add a HTTP header "From" with the value "Dave", set the session
> parameter
> "org.apache.chemistry.opencmis.binding.header.0" to the value "From:Dave".
>
> In Java that looks like this:
> parameters.put(SessionParameter.HEADER + ".0", "From:Dave");
>
> You can also set multiple headers:
> parameters.put(SessionParameter.HEADER + ".0", "From:Dave");
> parameters.put(SessionParameter.HEADER + ".1", "CmisClient:ProjectOne");
> parameters.put(SessionParameter.HEADER + ".2", "ColorOfTheDay:blue");
>
>
> Implementing you own authentication provider is more effort but gives you
> more
> freedom. Extend the StandardAuthenticationProvider class and override the
> getHTTPHeaders() method. Make sure you call super.getHTTPHeaders() and add
> your
> header to the returned headers. Otherwise you break the authentication and
> the
> cookie handling.
> Once you have your own implementation, you have to add it to the session
> parameters:
> parameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS,
> "com.example.MyAuthenticationProvider");
>
>
> Does this help?
>
>
> - Florian
>
>
> > Florian,
> >
> > Thank you so much for your response, providing links to the documentation
> > was very helpful.
> >
> > First let me apologize if my original question didn't provide enough
> detail
> > or if I didn't fully understand your response.
> >
> > In hindsight I should have mentioned that I already have a tool that runs
> > server-side that can inspect http headers and slice the results and
> report
> > appropriately.
> >
> > I believe the answer you gave me is a server-side solution.  I am
> seeking a
> > client-side property in the Client API for my clients to use to populate
> > the "From" request header (or any other header) with self-identifying
> > information.
> >
> > Thanks Again!
> > Dave
> >
> >
> >
> >
> > On Friday, September 5, 2014, Florian Müller <fmui@apache.org
> <javascript:;>> wrote:
> >
> > > Hi David,
> > >
> > > That is possible with a service wrapper on the server side. There is
> > > sample code
> > > [1] in OpenCMIS that shows how to do that.
> > > Part 2 of the OpenCMIS Server Development Guide [2] covers the details.
> > >
> > > - Florian
> > >
> > >
> > > [1]
> > >
> > >
> https://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/wrapper/SimpleLoggingCmisServiceWrapper.java?view=markup
> > >
> > > [2]
> > >
> > >
> https://github.com/cmisdocs/ServerDevelopmentGuide/blob/master/doc/OpenCMIS%20Server%20Development%20Guide.pdf?raw=true
> > >
> > > > Hello Everyone,
> > > >
> > > > My goal is to count all of the incoming CMIS calls and then slice
> that
> > > > information by who is making the calls.
> > > >
> > > > I was wondering if it is possible to achieve this goal without
> making any
> > > > code changes to the Apache Chemistry CMIS Server Framework or Apache
> > > > Chemistry CMIS Client API.
> > > >
> > > > For instance, can I use the existing Apache Chemistry Java Client
> API to
> > > > set a value for the "From" request header?
> > > >
> > > > Thanks!
> > > > Dave
> > >
>

Re: Setting Value for "From" Request Header

Posted by Florian Müller <fm...@apache.org>.
Hi Dave,

You can set HTTP headers via the session parameters or - if you need more logic
- you can implement your own authentication provider.

To add a HTTP header "From" with the value "Dave", set the session parameter
"org.apache.chemistry.opencmis.binding.header.0" to the value "From:Dave".

In Java that looks like this:
parameters.put(SessionParameter.HEADER + ".0", "From:Dave");

You can also set multiple headers:
parameters.put(SessionParameter.HEADER + ".0", "From:Dave");
parameters.put(SessionParameter.HEADER + ".1", "CmisClient:ProjectOne");
parameters.put(SessionParameter.HEADER + ".2", "ColorOfTheDay:blue");


Implementing you own authentication provider is more effort but gives you more
freedom. Extend the StandardAuthenticationProvider class and override the
getHTTPHeaders() method. Make sure you call super.getHTTPHeaders() and add your
header to the returned headers. Otherwise you break the authentication and the
cookie handling.
Once you have your own implementation, you have to add it to the session
parameters:
parameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS,
"com.example.MyAuthenticationProvider");


Does this help?


- Florian


> Florian,
> 
> Thank you so much for your response, providing links to the documentation
> was very helpful.
> 
> First let me apologize if my original question didn't provide enough detail
> or if I didn't fully understand your response.
> 
> In hindsight I should have mentioned that I already have a tool that runs
> server-side that can inspect http headers and slice the results and report
> appropriately.
> 
> I believe the answer you gave me is a server-side solution.  I am seeking a
> client-side property in the Client API for my clients to use to populate
> the "From" request header (or any other header) with self-identifying
> information.
> 
> Thanks Again!
> Dave
> 
> 
> 
> 
> On Friday, September 5, 2014, Florian Müller <fm...@apache.org> wrote:
> 
> > Hi David,
> >
> > That is possible with a service wrapper on the server side. There is
> > sample code
> > [1] in OpenCMIS that shows how to do that.
> > Part 2 of the OpenCMIS Server Development Guide [2] covers the details.
> >
> > - Florian
> >
> >
> > [1]
> >
> > https://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/wrapper/SimpleLoggingCmisServiceWrapper.java?view=markup
> >
> > [2]
> >
> > https://github.com/cmisdocs/ServerDevelopmentGuide/blob/master/doc/OpenCMIS%20Server%20Development%20Guide.pdf?raw=true
> >
> > > Hello Everyone,
> > >
> > > My goal is to count all of the incoming CMIS calls and then slice that
> > > information by who is making the calls.
> > >
> > > I was wondering if it is possible to achieve this goal without making any
> > > code changes to the Apache Chemistry CMIS Server Framework or Apache
> > > Chemistry CMIS Client API.
> > >
> > > For instance, can I use the existing Apache Chemistry Java Client API to
> > > set a value for the "From" request header?
> > >
> > > Thanks!
> > > Dave
> >

Re: Setting Value for "From" Request Header

Posted by David Radio <da...@gmail.com>.
Florian,

Thank you so much for your response, providing links to the documentation
was very helpful.

First let me apologize if my original question didn't provide enough detail
or if I didn't fully understand your response.

In hindsight I should have mentioned that I already have a tool that runs
server-side that can inspect http headers and slice the results and report
appropriately.

I believe the answer you gave me is a server-side solution.  I am seeking a
client-side property in the Client API for my clients to use to populate
the "From" request header (or any other header) with self-identifying
information.

Thanks Again!
Dave




On Friday, September 5, 2014, Florian Müller <fm...@apache.org> wrote:

> Hi David,
>
> That is possible with a service wrapper on the server side. There is
> sample code
> [1] in OpenCMIS that shows how to do that.
> Part 2 of the OpenCMIS Server Development Guide [2] covers the details.
>
> - Florian
>
>
> [1]
>
> https://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/wrapper/SimpleLoggingCmisServiceWrapper.java?view=markup
>
> [2]
>
> https://github.com/cmisdocs/ServerDevelopmentGuide/blob/master/doc/OpenCMIS%20Server%20Development%20Guide.pdf?raw=true
>
> > Hello Everyone,
> >
> > My goal is to count all of the incoming CMIS calls and then slice that
> > information by who is making the calls.
> >
> > I was wondering if it is possible to achieve this goal without making any
> > code changes to the Apache Chemistry CMIS Server Framework or Apache
> > Chemistry CMIS Client API.
> >
> > For instance, can I use the existing Apache Chemistry Java Client API to
> > set a value for the "From" request header?
> >
> > Thanks!
> > Dave
>

Re: Setting Value for "From" Request Header

Posted by Florian Müller <fm...@apache.org>.
Hi David,

That is possible with a service wrapper on the server side. There is sample code
[1] in OpenCMIS that shows how to do that.
Part 2 of the OpenCMIS Server Development Guide [2] covers the details.

- Florian


[1]
https://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/wrapper/SimpleLoggingCmisServiceWrapper.java?view=markup

[2]
https://github.com/cmisdocs/ServerDevelopmentGuide/blob/master/doc/OpenCMIS%20Server%20Development%20Guide.pdf?raw=true

> Hello Everyone,
> 
> My goal is to count all of the incoming CMIS calls and then slice that
> information by who is making the calls.
> 
> I was wondering if it is possible to achieve this goal without making any
> code changes to the Apache Chemistry CMIS Server Framework or Apache
> Chemistry CMIS Client API.
> 
> For instance, can I use the existing Apache Chemistry Java Client API to
> set a value for the "From" request header?
> 
> Thanks!
> Dave