You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Richard Hierlmeier <rh...@googlemail.com> on 2022/07/14 13:04:55 UTC

Re: Session cookie configuration in http white board

How can I define the  ServletContextHelper for a WAB? I can not find any
hint in the R7 spec.

Richard

Am Mo., 27. Juni 2022 um 16:15 Uhr schrieb Grzegorz Grzybek <
gr.grzybek@gmail.com>:

> Hi
>
>
> pon., 27 cze 2022 o 16:04 Richard Hierlmeier <rh...@googlemail.com>
> napisał(a):
>
>> Hi  Grzegorz.
>>
>> thank you for clarification. Unfortunately I can not upgrade to Karaf 4.4
>> the next time.
>> What would happen when I define the session cookie name in jetty.xml and
>> not in the wab?
>>
>
> To answer more precisely, I'd have to check your current configuration -
> what WAB are you deploying and what are the registration properties of the
> HttpWhiteboard servlet. Only then I could check (going back to Karaf 4.3.7)
> what may be the issue related to context configuration...
>
> regards
> Grzegorz Grzybek
>
>
>>
>>
>> Richard
>>
>>
>> Am Mo., 27. Juni 2022 um 12:02 Uhr schrieb Grzegorz Grzybek <
>> gr.grzybek@gmail.com>:
>>
>>> Hello
>>>
>>> Unfortunately, only with Pax Web 8 (used in Karaf 4.4+) we've refactored
>>> the WAB/HttpService/Whiteboard inter operation. Pax Web 8 allows mixing web
>>> elements coming from different "origins" (whiteboard registration, direct
>>> registration using HttpService or web.xml/web-fragment.xml approach from
>>> WABs).
>>>
>>> So in Pax Web 8 you should be able to reconfigure the session cookie
>>> name and there servlets registered using Whiteboard targetting the same
>>> context (as in WAB) should use the same session configuration.
>>>
>>> Also - Pax Web 8 implements correctly the session separation mentioned
>>> in
>>> https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#service.http.whiteboard.servletcontext
>>> :
>>>
>>> Http Sessions are not shared amongst servlets registered with different
>>>> ServletContextHelpers. That is, HttpRequest.getSession calls must provide
>>>> different sessions per associated ServletContextHelper
>>>>
>>>
>>> So even if two whiteboard servlets are registered to the same target
>>> servlet context, but using different ServletContextHelper, they'll use
>>> different session configuration.
>>>
>>> kind regards
>>> Grzegorz Grzybek
>>>
>>> pon., 27 cze 2022 o 11:33 Richard Hierlmeier <rh...@googlemail.com>
>>> napisał(a):
>>>
>>>>
>>>> My application runs in Karaf 4.3.7. I have a web application that is
>>>> deployed as wab application bundle (wab). This web application changes the
>>>> session cookie name in
>>>> javax.servlet.ServletContextListener#contextInitialized().
>>>>
>>>> In another bundle I have a servlet that is defined with HttpWhiteBoard.
>>>> The servlets from the wab and the servlets from HttpWhiteBoard have
>>>> different http sessions (because they have different session cookie names
>>>> in the ServletContext).
>>>>
>>>> Is it possible to configure the session cookie for Servlets that are
>>>> deployed via HttpWhiteBoard?
>>>>
>>>> Regards
>>>>
>>>>   Richard
>>>>
>>>>

Re: Session cookie configuration in http white board

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Hello

pt., 29 lip 2022 o 17:33 Richard Hierlmeier <rh...@googlemail.com>
napisał(a):

> I implemented a sample project that tests that a http whiteboard servlet
> can have the same http session as a servlet that is part of a WAB.
>
> See https://github.com/rhierlmeier/paxweb8-test
>
> It is working with PAX-WEB 8 :)
>

I'm glad to hear that! You got my github star ;)

regards
Grzegorz Grzybek


>
> Thank you
>
>   Richard
>
> Am Do., 14. Juli 2022 um 16:47 Uhr schrieb Grzegorz Grzybek <
> gr.grzybek@gmail.com>:
>
>>
>>
>> czw., 14 lip 2022 o 15:50 Richard Hierlmeier <rh...@googlemail.com>
>> napisał(a):
>>
>>> Great, thank you.
>>>
>>> but this works only with PAX-WEB8, correct?
>>>
>>
>> Yes... Pax Web 7 and earlier is not implementing context selection
>> properly.
>> Actually https://github.com/ops4j/org.ops4j.pax.web/issues/1413 /
>> https://ops4j1.jira.com/browse/PAXWEB-1123 was the main reason I decided
>> to refactor Pax Web ;)
>>
>> regards
>> Grzegorz Grzybek
>>
>>
>>>
>>> Richard
>>>
>>> Am Do., 14. Juli 2022 um 15:42 Uhr schrieb Grzegorz Grzybek <
>>> gr.grzybek@gmail.com>:
>>>
>>>>
>>>>
>>>> czw., 14 lip 2022 o 15:34 Richard Hierlmeier <
>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>
>>>>> The only requirement is that a servlet that is deployed via http
>>>>> whiteboard has the same session as the servlet that is part of the WAB.
>>>>>
>>>>
>>>> In order to whiteboard-register a servlet to the same context which is
>>>> backing a WAB, you have to register the servlet pointing to relevant
>>>> context. By default, the selector is:
>>>>
>>>> osgi.http.whiteboard.context.select = (
>>>> osgi.http.whiteboard.context.name=default)
>>>>
>>>> You just have to register a servlet with:
>>>>
>>>> osgi.http.whiteboard.context.select =
>>>> (osgi.http.whiteboard.context.path=/path)
>>>>
>>>> where "/path" is the same value as in Web-ContextPath header of the WAB.
>>>>
>>>> Check AbstractWabWhiteboardConflictIntegrationTest.java
>>>> <https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.6/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWabWhiteboardConflictIntegrationTest.java#L55-L69>[1]
>>>> - it's a filter registration, but the principle is the same.
>>>>
>>>> regards
>>>> Grzegorz Grzybek
>>>> ===
>>>> [1]:
>>>> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.6/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWabWhiteboardConflictIntegrationTest.java#L55-L69
>>>>
>>>>
>>>>>
>>>>> Richard
>>>>>
>>>>> Am Do., 14. Juli 2022 um 15:13 Uhr schrieb Grzegorz Grzybek <
>>>>> gr.grzybek@gmail.com>:
>>>>>
>>>>>> Hello
>>>>>>
>>>>>> czw., 14 lip 2022 o 15:05 Richard Hierlmeier <
>>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>>
>>>>>>> How can I define the  ServletContextHelper for a WAB? I can not find
>>>>>>> any hint in the R7 spec.
>>>>>>>
>>>>>>
>>>>>> You ... can't. There's nothing at all about ServletContextHelper
>>>>>> concept (Whiteboard) in chapter 128 (WABs).
>>>>>>
>>>>>> Pax Web 8 explicitly defines special class
>>>>>> org.ops4j.pax.web.extender.war.internal.WebApplicationHelper, which extends
>>>>>> org.ops4j.pax.web.service.spi.context.DefaultServletContextHelper which
>>>>>> extends org.osgi.service.http.context.ServletContextHelper.
>>>>>>
>>>>>> Such implementation is specially crafted to:
>>>>>>  - provide org.osgi.service.http.context.ServletContextHelper
>>>>>>  - handle WAR scenarios related to resource access
>>>>>>
>>>>>> It is then set inside
>>>>>> org.ops4j.pax.web.service.spi.model.OsgiContextModel - a common "context"
>>>>>> representation for HttpService, Whiteboard and WAB scenarios.
>>>>>>
>>>>>> Out of curiosity - do you have any special requirement that a WAB
>>>>>> needs custom context?
>>>>>>
>>>>>> Mind that org.osgi.service.http.context.ServletContextHelper in
>>>>>> Whiteboard has two responsibilities:
>>>>>>  - security (WABs/WARs have better ways to deal with this)
>>>>>>  - resource access (WABs/WARs have standard resource access methods
>>>>>> defined in the Servlets specification itself)
>>>>>>
>>>>>> regards
>>>>>> Grzegorz Grzybek
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Richard
>>>>>>>
>>>>>>> Am Mo., 27. Juni 2022 um 16:15 Uhr schrieb Grzegorz Grzybek <
>>>>>>> gr.grzybek@gmail.com>:
>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>>
>>>>>>>> pon., 27 cze 2022 o 16:04 Richard Hierlmeier <
>>>>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>>>>
>>>>>>>>> Hi  Grzegorz.
>>>>>>>>>
>>>>>>>>> thank you for clarification. Unfortunately I can not upgrade to
>>>>>>>>> Karaf 4.4 the next time.
>>>>>>>>> What would happen when I define the session cookie name in
>>>>>>>>> jetty.xml and not in the wab?
>>>>>>>>>
>>>>>>>>
>>>>>>>> To answer more precisely, I'd have to check your current
>>>>>>>> configuration - what WAB are you deploying and what are the registration
>>>>>>>> properties of the HttpWhiteboard servlet. Only then I could check (going
>>>>>>>> back to Karaf 4.3.7) what may be the issue related to context
>>>>>>>> configuration...
>>>>>>>>
>>>>>>>> regards
>>>>>>>> Grzegorz Grzybek
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Richard
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Am Mo., 27. Juni 2022 um 12:02 Uhr schrieb Grzegorz Grzybek <
>>>>>>>>> gr.grzybek@gmail.com>:
>>>>>>>>>
>>>>>>>>>> Hello
>>>>>>>>>>
>>>>>>>>>> Unfortunately, only with Pax Web 8 (used in Karaf 4.4+) we've
>>>>>>>>>> refactored the WAB/HttpService/Whiteboard inter operation. Pax Web 8 allows
>>>>>>>>>> mixing web elements coming from different "origins" (whiteboard
>>>>>>>>>> registration, direct registration using HttpService or
>>>>>>>>>> web.xml/web-fragment.xml approach from WABs).
>>>>>>>>>>
>>>>>>>>>> So in Pax Web 8 you should be able to reconfigure the session
>>>>>>>>>> cookie name and there servlets registered using Whiteboard targetting the
>>>>>>>>>> same context (as in WAB) should use the same session configuration.
>>>>>>>>>>
>>>>>>>>>> Also - Pax Web 8 implements correctly the session separation
>>>>>>>>>> mentioned in
>>>>>>>>>> https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#service.http.whiteboard.servletcontext
>>>>>>>>>> :
>>>>>>>>>>
>>>>>>>>>> Http Sessions are not shared amongst servlets registered with
>>>>>>>>>>> different ServletContextHelpers. That is, HttpRequest.getSession calls must
>>>>>>>>>>> provide different sessions per associated ServletContextHelper
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> So even if two whiteboard servlets are registered to the same
>>>>>>>>>> target servlet context, but using different ServletContextHelper, they'll
>>>>>>>>>> use different session configuration.
>>>>>>>>>>
>>>>>>>>>> kind regards
>>>>>>>>>> Grzegorz Grzybek
>>>>>>>>>>
>>>>>>>>>> pon., 27 cze 2022 o 11:33 Richard Hierlmeier <
>>>>>>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> My application runs in Karaf 4.3.7. I have a web application
>>>>>>>>>>> that is deployed as wab application bundle (wab). This web application
>>>>>>>>>>> changes the session cookie name in
>>>>>>>>>>> javax.servlet.ServletContextListener#contextInitialized().
>>>>>>>>>>>
>>>>>>>>>>> In another bundle I have a servlet that is defined with
>>>>>>>>>>> HttpWhiteBoard.
>>>>>>>>>>> The servlets from the wab and the servlets from HttpWhiteBoard
>>>>>>>>>>> have different http sessions (because they have different session cookie
>>>>>>>>>>> names in the ServletContext).
>>>>>>>>>>>
>>>>>>>>>>> Is it possible to configure the session cookie for Servlets that
>>>>>>>>>>> are deployed via HttpWhiteBoard?
>>>>>>>>>>>
>>>>>>>>>>> Regards
>>>>>>>>>>>
>>>>>>>>>>>   Richard
>>>>>>>>>>>
>>>>>>>>>>>

Re: Session cookie configuration in http white board

Posted by Richard Hierlmeier <rh...@googlemail.com>.
I implemented a sample project that tests that a http whiteboard servlet
can have the same http session as a servlet that is part of a WAB.

See https://github.com/rhierlmeier/paxweb8-test

It is working with PAX-WEB 8 :)

Thank you

  Richard

Am Do., 14. Juli 2022 um 16:47 Uhr schrieb Grzegorz Grzybek <
gr.grzybek@gmail.com>:

>
>
> czw., 14 lip 2022 o 15:50 Richard Hierlmeier <rh...@googlemail.com>
> napisał(a):
>
>> Great, thank you.
>>
>> but this works only with PAX-WEB8, correct?
>>
>
> Yes... Pax Web 7 and earlier is not implementing context selection
> properly.
> Actually https://github.com/ops4j/org.ops4j.pax.web/issues/1413 /
> https://ops4j1.jira.com/browse/PAXWEB-1123 was the main reason I decided
> to refactor Pax Web ;)
>
> regards
> Grzegorz Grzybek
>
>
>>
>> Richard
>>
>> Am Do., 14. Juli 2022 um 15:42 Uhr schrieb Grzegorz Grzybek <
>> gr.grzybek@gmail.com>:
>>
>>>
>>>
>>> czw., 14 lip 2022 o 15:34 Richard Hierlmeier <rh...@googlemail.com>
>>> napisał(a):
>>>
>>>> The only requirement is that a servlet that is deployed via http
>>>> whiteboard has the same session as the servlet that is part of the WAB.
>>>>
>>>
>>> In order to whiteboard-register a servlet to the same context which is
>>> backing a WAB, you have to register the servlet pointing to relevant
>>> context. By default, the selector is:
>>>
>>> osgi.http.whiteboard.context.select = (osgi.http.whiteboard.context.name
>>> =default)
>>>
>>> You just have to register a servlet with:
>>>
>>> osgi.http.whiteboard.context.select =
>>> (osgi.http.whiteboard.context.path=/path)
>>>
>>> where "/path" is the same value as in Web-ContextPath header of the WAB.
>>>
>>> Check AbstractWabWhiteboardConflictIntegrationTest.java
>>> <https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.6/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWabWhiteboardConflictIntegrationTest.java#L55-L69>[1]
>>> - it's a filter registration, but the principle is the same.
>>>
>>> regards
>>> Grzegorz Grzybek
>>> ===
>>> [1]:
>>> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.6/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWabWhiteboardConflictIntegrationTest.java#L55-L69
>>>
>>>
>>>>
>>>> Richard
>>>>
>>>> Am Do., 14. Juli 2022 um 15:13 Uhr schrieb Grzegorz Grzybek <
>>>> gr.grzybek@gmail.com>:
>>>>
>>>>> Hello
>>>>>
>>>>> czw., 14 lip 2022 o 15:05 Richard Hierlmeier <
>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>
>>>>>> How can I define the  ServletContextHelper for a WAB? I can not find
>>>>>> any hint in the R7 spec.
>>>>>>
>>>>>
>>>>> You ... can't. There's nothing at all about ServletContextHelper
>>>>> concept (Whiteboard) in chapter 128 (WABs).
>>>>>
>>>>> Pax Web 8 explicitly defines special class
>>>>> org.ops4j.pax.web.extender.war.internal.WebApplicationHelper, which extends
>>>>> org.ops4j.pax.web.service.spi.context.DefaultServletContextHelper which
>>>>> extends org.osgi.service.http.context.ServletContextHelper.
>>>>>
>>>>> Such implementation is specially crafted to:
>>>>>  - provide org.osgi.service.http.context.ServletContextHelper
>>>>>  - handle WAR scenarios related to resource access
>>>>>
>>>>> It is then set inside
>>>>> org.ops4j.pax.web.service.spi.model.OsgiContextModel - a common "context"
>>>>> representation for HttpService, Whiteboard and WAB scenarios.
>>>>>
>>>>> Out of curiosity - do you have any special requirement that a WAB
>>>>> needs custom context?
>>>>>
>>>>> Mind that org.osgi.service.http.context.ServletContextHelper in
>>>>> Whiteboard has two responsibilities:
>>>>>  - security (WABs/WARs have better ways to deal with this)
>>>>>  - resource access (WABs/WARs have standard resource access methods
>>>>> defined in the Servlets specification itself)
>>>>>
>>>>> regards
>>>>> Grzegorz Grzybek
>>>>>
>>>>>
>>>>>>
>>>>>> Richard
>>>>>>
>>>>>> Am Mo., 27. Juni 2022 um 16:15 Uhr schrieb Grzegorz Grzybek <
>>>>>> gr.grzybek@gmail.com>:
>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>>
>>>>>>> pon., 27 cze 2022 o 16:04 Richard Hierlmeier <
>>>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>>>
>>>>>>>> Hi  Grzegorz.
>>>>>>>>
>>>>>>>> thank you for clarification. Unfortunately I can not upgrade to
>>>>>>>> Karaf 4.4 the next time.
>>>>>>>> What would happen when I define the session cookie name in
>>>>>>>> jetty.xml and not in the wab?
>>>>>>>>
>>>>>>>
>>>>>>> To answer more precisely, I'd have to check your current
>>>>>>> configuration - what WAB are you deploying and what are the registration
>>>>>>> properties of the HttpWhiteboard servlet. Only then I could check (going
>>>>>>> back to Karaf 4.3.7) what may be the issue related to context
>>>>>>> configuration...
>>>>>>>
>>>>>>> regards
>>>>>>> Grzegorz Grzybek
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Richard
>>>>>>>>
>>>>>>>>
>>>>>>>> Am Mo., 27. Juni 2022 um 12:02 Uhr schrieb Grzegorz Grzybek <
>>>>>>>> gr.grzybek@gmail.com>:
>>>>>>>>
>>>>>>>>> Hello
>>>>>>>>>
>>>>>>>>> Unfortunately, only with Pax Web 8 (used in Karaf 4.4+) we've
>>>>>>>>> refactored the WAB/HttpService/Whiteboard inter operation. Pax Web 8 allows
>>>>>>>>> mixing web elements coming from different "origins" (whiteboard
>>>>>>>>> registration, direct registration using HttpService or
>>>>>>>>> web.xml/web-fragment.xml approach from WABs).
>>>>>>>>>
>>>>>>>>> So in Pax Web 8 you should be able to reconfigure the session
>>>>>>>>> cookie name and there servlets registered using Whiteboard targetting the
>>>>>>>>> same context (as in WAB) should use the same session configuration.
>>>>>>>>>
>>>>>>>>> Also - Pax Web 8 implements correctly the session separation
>>>>>>>>> mentioned in
>>>>>>>>> https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#service.http.whiteboard.servletcontext
>>>>>>>>> :
>>>>>>>>>
>>>>>>>>> Http Sessions are not shared amongst servlets registered with
>>>>>>>>>> different ServletContextHelpers. That is, HttpRequest.getSession calls must
>>>>>>>>>> provide different sessions per associated ServletContextHelper
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> So even if two whiteboard servlets are registered to the same
>>>>>>>>> target servlet context, but using different ServletContextHelper, they'll
>>>>>>>>> use different session configuration.
>>>>>>>>>
>>>>>>>>> kind regards
>>>>>>>>> Grzegorz Grzybek
>>>>>>>>>
>>>>>>>>> pon., 27 cze 2022 o 11:33 Richard Hierlmeier <
>>>>>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> My application runs in Karaf 4.3.7. I have a web application that
>>>>>>>>>> is deployed as wab application bundle (wab). This web application changes
>>>>>>>>>> the session cookie name in
>>>>>>>>>> javax.servlet.ServletContextListener#contextInitialized().
>>>>>>>>>>
>>>>>>>>>> In another bundle I have a servlet that is defined with
>>>>>>>>>> HttpWhiteBoard.
>>>>>>>>>> The servlets from the wab and the servlets from HttpWhiteBoard
>>>>>>>>>> have different http sessions (because they have different session cookie
>>>>>>>>>> names in the ServletContext).
>>>>>>>>>>
>>>>>>>>>> Is it possible to configure the session cookie for Servlets that
>>>>>>>>>> are deployed via HttpWhiteBoard?
>>>>>>>>>>
>>>>>>>>>> Regards
>>>>>>>>>>
>>>>>>>>>>   Richard
>>>>>>>>>>
>>>>>>>>>>

Re: Session cookie configuration in http white board

Posted by Grzegorz Grzybek <gr...@gmail.com>.
czw., 14 lip 2022 o 15:50 Richard Hierlmeier <rh...@googlemail.com>
napisał(a):

> Great, thank you.
>
> but this works only with PAX-WEB8, correct?
>

Yes... Pax Web 7 and earlier is not implementing context selection properly.
Actually https://github.com/ops4j/org.ops4j.pax.web/issues/1413 /
https://ops4j1.jira.com/browse/PAXWEB-1123 was the main reason I decided to
refactor Pax Web ;)

regards
Grzegorz Grzybek


>
> Richard
>
> Am Do., 14. Juli 2022 um 15:42 Uhr schrieb Grzegorz Grzybek <
> gr.grzybek@gmail.com>:
>
>>
>>
>> czw., 14 lip 2022 o 15:34 Richard Hierlmeier <rh...@googlemail.com>
>> napisał(a):
>>
>>> The only requirement is that a servlet that is deployed via http
>>> whiteboard has the same session as the servlet that is part of the WAB.
>>>
>>
>> In order to whiteboard-register a servlet to the same context which is
>> backing a WAB, you have to register the servlet pointing to relevant
>> context. By default, the selector is:
>>
>> osgi.http.whiteboard.context.select = (osgi.http.whiteboard.context.name
>> =default)
>>
>> You just have to register a servlet with:
>>
>> osgi.http.whiteboard.context.select =
>> (osgi.http.whiteboard.context.path=/path)
>>
>> where "/path" is the same value as in Web-ContextPath header of the WAB.
>>
>> Check AbstractWabWhiteboardConflictIntegrationTest.java
>> <https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.6/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWabWhiteboardConflictIntegrationTest.java#L55-L69>[1]
>> - it's a filter registration, but the principle is the same.
>>
>> regards
>> Grzegorz Grzybek
>> ===
>> [1]:
>> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.6/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWabWhiteboardConflictIntegrationTest.java#L55-L69
>>
>>
>>>
>>> Richard
>>>
>>> Am Do., 14. Juli 2022 um 15:13 Uhr schrieb Grzegorz Grzybek <
>>> gr.grzybek@gmail.com>:
>>>
>>>> Hello
>>>>
>>>> czw., 14 lip 2022 o 15:05 Richard Hierlmeier <
>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>
>>>>> How can I define the  ServletContextHelper for a WAB? I can not find
>>>>> any hint in the R7 spec.
>>>>>
>>>>
>>>> You ... can't. There's nothing at all about ServletContextHelper
>>>> concept (Whiteboard) in chapter 128 (WABs).
>>>>
>>>> Pax Web 8 explicitly defines special class
>>>> org.ops4j.pax.web.extender.war.internal.WebApplicationHelper, which extends
>>>> org.ops4j.pax.web.service.spi.context.DefaultServletContextHelper which
>>>> extends org.osgi.service.http.context.ServletContextHelper.
>>>>
>>>> Such implementation is specially crafted to:
>>>>  - provide org.osgi.service.http.context.ServletContextHelper
>>>>  - handle WAR scenarios related to resource access
>>>>
>>>> It is then set inside
>>>> org.ops4j.pax.web.service.spi.model.OsgiContextModel - a common "context"
>>>> representation for HttpService, Whiteboard and WAB scenarios.
>>>>
>>>> Out of curiosity - do you have any special requirement that a WAB needs
>>>> custom context?
>>>>
>>>> Mind that org.osgi.service.http.context.ServletContextHelper in
>>>> Whiteboard has two responsibilities:
>>>>  - security (WABs/WARs have better ways to deal with this)
>>>>  - resource access (WABs/WARs have standard resource access methods
>>>> defined in the Servlets specification itself)
>>>>
>>>> regards
>>>> Grzegorz Grzybek
>>>>
>>>>
>>>>>
>>>>> Richard
>>>>>
>>>>> Am Mo., 27. Juni 2022 um 16:15 Uhr schrieb Grzegorz Grzybek <
>>>>> gr.grzybek@gmail.com>:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>>
>>>>>> pon., 27 cze 2022 o 16:04 Richard Hierlmeier <
>>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>>
>>>>>>> Hi  Grzegorz.
>>>>>>>
>>>>>>> thank you for clarification. Unfortunately I can not upgrade to
>>>>>>> Karaf 4.4 the next time.
>>>>>>> What would happen when I define the session cookie name in jetty.xml
>>>>>>> and not in the wab?
>>>>>>>
>>>>>>
>>>>>> To answer more precisely, I'd have to check your current
>>>>>> configuration - what WAB are you deploying and what are the registration
>>>>>> properties of the HttpWhiteboard servlet. Only then I could check (going
>>>>>> back to Karaf 4.3.7) what may be the issue related to context
>>>>>> configuration...
>>>>>>
>>>>>> regards
>>>>>> Grzegorz Grzybek
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Richard
>>>>>>>
>>>>>>>
>>>>>>> Am Mo., 27. Juni 2022 um 12:02 Uhr schrieb Grzegorz Grzybek <
>>>>>>> gr.grzybek@gmail.com>:
>>>>>>>
>>>>>>>> Hello
>>>>>>>>
>>>>>>>> Unfortunately, only with Pax Web 8 (used in Karaf 4.4+) we've
>>>>>>>> refactored the WAB/HttpService/Whiteboard inter operation. Pax Web 8 allows
>>>>>>>> mixing web elements coming from different "origins" (whiteboard
>>>>>>>> registration, direct registration using HttpService or
>>>>>>>> web.xml/web-fragment.xml approach from WABs).
>>>>>>>>
>>>>>>>> So in Pax Web 8 you should be able to reconfigure the session
>>>>>>>> cookie name and there servlets registered using Whiteboard targetting the
>>>>>>>> same context (as in WAB) should use the same session configuration.
>>>>>>>>
>>>>>>>> Also - Pax Web 8 implements correctly the session separation
>>>>>>>> mentioned in
>>>>>>>> https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#service.http.whiteboard.servletcontext
>>>>>>>> :
>>>>>>>>
>>>>>>>> Http Sessions are not shared amongst servlets registered with
>>>>>>>>> different ServletContextHelpers. That is, HttpRequest.getSession calls must
>>>>>>>>> provide different sessions per associated ServletContextHelper
>>>>>>>>>
>>>>>>>>
>>>>>>>> So even if two whiteboard servlets are registered to the same
>>>>>>>> target servlet context, but using different ServletContextHelper, they'll
>>>>>>>> use different session configuration.
>>>>>>>>
>>>>>>>> kind regards
>>>>>>>> Grzegorz Grzybek
>>>>>>>>
>>>>>>>> pon., 27 cze 2022 o 11:33 Richard Hierlmeier <
>>>>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>>>>
>>>>>>>>>
>>>>>>>>> My application runs in Karaf 4.3.7. I have a web application that
>>>>>>>>> is deployed as wab application bundle (wab). This web application changes
>>>>>>>>> the session cookie name in
>>>>>>>>> javax.servlet.ServletContextListener#contextInitialized().
>>>>>>>>>
>>>>>>>>> In another bundle I have a servlet that is defined with
>>>>>>>>> HttpWhiteBoard.
>>>>>>>>> The servlets from the wab and the servlets from HttpWhiteBoard
>>>>>>>>> have different http sessions (because they have different session cookie
>>>>>>>>> names in the ServletContext).
>>>>>>>>>
>>>>>>>>> Is it possible to configure the session cookie for Servlets that
>>>>>>>>> are deployed via HttpWhiteBoard?
>>>>>>>>>
>>>>>>>>> Regards
>>>>>>>>>
>>>>>>>>>   Richard
>>>>>>>>>
>>>>>>>>>

Re: Session cookie configuration in http white board

Posted by Richard Hierlmeier <rh...@googlemail.com>.
Great, thank you.

but this works only with PAX-WEB8, correct?

Richard

Am Do., 14. Juli 2022 um 15:42 Uhr schrieb Grzegorz Grzybek <
gr.grzybek@gmail.com>:

>
>
> czw., 14 lip 2022 o 15:34 Richard Hierlmeier <rh...@googlemail.com>
> napisał(a):
>
>> The only requirement is that a servlet that is deployed via http
>> whiteboard has the same session as the servlet that is part of the WAB.
>>
>
> In order to whiteboard-register a servlet to the same context which is
> backing a WAB, you have to register the servlet pointing to relevant
> context. By default, the selector is:
>
> osgi.http.whiteboard.context.select = (osgi.http.whiteboard.context.name
> =default)
>
> You just have to register a servlet with:
>
> osgi.http.whiteboard.context.select =
> (osgi.http.whiteboard.context.path=/path)
>
> where "/path" is the same value as in Web-ContextPath header of the WAB.
>
> Check AbstractWabWhiteboardConflictIntegrationTest.java
> <https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.6/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWabWhiteboardConflictIntegrationTest.java#L55-L69>[1]
> - it's a filter registration, but the principle is the same.
>
> regards
> Grzegorz Grzybek
> ===
> [1]:
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.6/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWabWhiteboardConflictIntegrationTest.java#L55-L69
>
>
>>
>> Richard
>>
>> Am Do., 14. Juli 2022 um 15:13 Uhr schrieb Grzegorz Grzybek <
>> gr.grzybek@gmail.com>:
>>
>>> Hello
>>>
>>> czw., 14 lip 2022 o 15:05 Richard Hierlmeier <rh...@googlemail.com>
>>> napisał(a):
>>>
>>>> How can I define the  ServletContextHelper for a WAB? I can not find
>>>> any hint in the R7 spec.
>>>>
>>>
>>> You ... can't. There's nothing at all about ServletContextHelper concept
>>> (Whiteboard) in chapter 128 (WABs).
>>>
>>> Pax Web 8 explicitly defines special class
>>> org.ops4j.pax.web.extender.war.internal.WebApplicationHelper, which extends
>>> org.ops4j.pax.web.service.spi.context.DefaultServletContextHelper which
>>> extends org.osgi.service.http.context.ServletContextHelper.
>>>
>>> Such implementation is specially crafted to:
>>>  - provide org.osgi.service.http.context.ServletContextHelper
>>>  - handle WAR scenarios related to resource access
>>>
>>> It is then set inside
>>> org.ops4j.pax.web.service.spi.model.OsgiContextModel - a common "context"
>>> representation for HttpService, Whiteboard and WAB scenarios.
>>>
>>> Out of curiosity - do you have any special requirement that a WAB needs
>>> custom context?
>>>
>>> Mind that org.osgi.service.http.context.ServletContextHelper in
>>> Whiteboard has two responsibilities:
>>>  - security (WABs/WARs have better ways to deal with this)
>>>  - resource access (WABs/WARs have standard resource access methods
>>> defined in the Servlets specification itself)
>>>
>>> regards
>>> Grzegorz Grzybek
>>>
>>>
>>>>
>>>> Richard
>>>>
>>>> Am Mo., 27. Juni 2022 um 16:15 Uhr schrieb Grzegorz Grzybek <
>>>> gr.grzybek@gmail.com>:
>>>>
>>>>> Hi
>>>>>
>>>>>
>>>>> pon., 27 cze 2022 o 16:04 Richard Hierlmeier <
>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>
>>>>>> Hi  Grzegorz.
>>>>>>
>>>>>> thank you for clarification. Unfortunately I can not upgrade to Karaf
>>>>>> 4.4 the next time.
>>>>>> What would happen when I define the session cookie name in jetty.xml
>>>>>> and not in the wab?
>>>>>>
>>>>>
>>>>> To answer more precisely, I'd have to check your current configuration
>>>>> - what WAB are you deploying and what are the registration properties of
>>>>> the HttpWhiteboard servlet. Only then I could check (going back to Karaf
>>>>> 4.3.7) what may be the issue related to context configuration...
>>>>>
>>>>> regards
>>>>> Grzegorz Grzybek
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>> Richard
>>>>>>
>>>>>>
>>>>>> Am Mo., 27. Juni 2022 um 12:02 Uhr schrieb Grzegorz Grzybek <
>>>>>> gr.grzybek@gmail.com>:
>>>>>>
>>>>>>> Hello
>>>>>>>
>>>>>>> Unfortunately, only with Pax Web 8 (used in Karaf 4.4+) we've
>>>>>>> refactored the WAB/HttpService/Whiteboard inter operation. Pax Web 8 allows
>>>>>>> mixing web elements coming from different "origins" (whiteboard
>>>>>>> registration, direct registration using HttpService or
>>>>>>> web.xml/web-fragment.xml approach from WABs).
>>>>>>>
>>>>>>> So in Pax Web 8 you should be able to reconfigure the session cookie
>>>>>>> name and there servlets registered using Whiteboard targetting the same
>>>>>>> context (as in WAB) should use the same session configuration.
>>>>>>>
>>>>>>> Also - Pax Web 8 implements correctly the session separation
>>>>>>> mentioned in
>>>>>>> https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#service.http.whiteboard.servletcontext
>>>>>>> :
>>>>>>>
>>>>>>> Http Sessions are not shared amongst servlets registered with
>>>>>>>> different ServletContextHelpers. That is, HttpRequest.getSession calls must
>>>>>>>> provide different sessions per associated ServletContextHelper
>>>>>>>>
>>>>>>>
>>>>>>> So even if two whiteboard servlets are registered to the same target
>>>>>>> servlet context, but using different ServletContextHelper, they'll use
>>>>>>> different session configuration.
>>>>>>>
>>>>>>> kind regards
>>>>>>> Grzegorz Grzybek
>>>>>>>
>>>>>>> pon., 27 cze 2022 o 11:33 Richard Hierlmeier <
>>>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>>>
>>>>>>>>
>>>>>>>> My application runs in Karaf 4.3.7. I have a web application that
>>>>>>>> is deployed as wab application bundle (wab). This web application changes
>>>>>>>> the session cookie name in
>>>>>>>> javax.servlet.ServletContextListener#contextInitialized().
>>>>>>>>
>>>>>>>> In another bundle I have a servlet that is defined with
>>>>>>>> HttpWhiteBoard.
>>>>>>>> The servlets from the wab and the servlets from HttpWhiteBoard have
>>>>>>>> different http sessions (because they have different session cookie names
>>>>>>>> in the ServletContext).
>>>>>>>>
>>>>>>>> Is it possible to configure the session cookie for Servlets that
>>>>>>>> are deployed via HttpWhiteBoard?
>>>>>>>>
>>>>>>>> Regards
>>>>>>>>
>>>>>>>>   Richard
>>>>>>>>
>>>>>>>>

Re: Session cookie configuration in http white board

Posted by Grzegorz Grzybek <gr...@gmail.com>.
czw., 14 lip 2022 o 15:34 Richard Hierlmeier <rh...@googlemail.com>
napisał(a):

> The only requirement is that a servlet that is deployed via http
> whiteboard has the same session as the servlet that is part of the WAB.
>

In order to whiteboard-register a servlet to the same context which is
backing a WAB, you have to register the servlet pointing to relevant
context. By default, the selector is:

osgi.http.whiteboard.context.select = (osgi.http.whiteboard.context.name
=default)

You just have to register a servlet with:

osgi.http.whiteboard.context.select =
(osgi.http.whiteboard.context.path=/path)

where "/path" is the same value as in Web-ContextPath header of the WAB.

Check AbstractWabWhiteboardConflictIntegrationTest.java
<https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.6/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWabWhiteboardConflictIntegrationTest.java#L55-L69>[1]
- it's a filter registration, but the principle is the same.

regards
Grzegorz Grzybek
===
[1]:
https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.6/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWabWhiteboardConflictIntegrationTest.java#L55-L69


>
> Richard
>
> Am Do., 14. Juli 2022 um 15:13 Uhr schrieb Grzegorz Grzybek <
> gr.grzybek@gmail.com>:
>
>> Hello
>>
>> czw., 14 lip 2022 o 15:05 Richard Hierlmeier <rh...@googlemail.com>
>> napisał(a):
>>
>>> How can I define the  ServletContextHelper for a WAB? I can not find any
>>> hint in the R7 spec.
>>>
>>
>> You ... can't. There's nothing at all about ServletContextHelper concept
>> (Whiteboard) in chapter 128 (WABs).
>>
>> Pax Web 8 explicitly defines special class
>> org.ops4j.pax.web.extender.war.internal.WebApplicationHelper, which extends
>> org.ops4j.pax.web.service.spi.context.DefaultServletContextHelper which
>> extends org.osgi.service.http.context.ServletContextHelper.
>>
>> Such implementation is specially crafted to:
>>  - provide org.osgi.service.http.context.ServletContextHelper
>>  - handle WAR scenarios related to resource access
>>
>> It is then set inside
>> org.ops4j.pax.web.service.spi.model.OsgiContextModel - a common "context"
>> representation for HttpService, Whiteboard and WAB scenarios.
>>
>> Out of curiosity - do you have any special requirement that a WAB needs
>> custom context?
>>
>> Mind that org.osgi.service.http.context.ServletContextHelper in
>> Whiteboard has two responsibilities:
>>  - security (WABs/WARs have better ways to deal with this)
>>  - resource access (WABs/WARs have standard resource access methods
>> defined in the Servlets specification itself)
>>
>> regards
>> Grzegorz Grzybek
>>
>>
>>>
>>> Richard
>>>
>>> Am Mo., 27. Juni 2022 um 16:15 Uhr schrieb Grzegorz Grzybek <
>>> gr.grzybek@gmail.com>:
>>>
>>>> Hi
>>>>
>>>>
>>>> pon., 27 cze 2022 o 16:04 Richard Hierlmeier <
>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>
>>>>> Hi  Grzegorz.
>>>>>
>>>>> thank you for clarification. Unfortunately I can not upgrade to Karaf
>>>>> 4.4 the next time.
>>>>> What would happen when I define the session cookie name in jetty.xml
>>>>> and not in the wab?
>>>>>
>>>>
>>>> To answer more precisely, I'd have to check your current configuration
>>>> - what WAB are you deploying and what are the registration properties of
>>>> the HttpWhiteboard servlet. Only then I could check (going back to Karaf
>>>> 4.3.7) what may be the issue related to context configuration...
>>>>
>>>> regards
>>>> Grzegorz Grzybek
>>>>
>>>>
>>>>>
>>>>>
>>>>> Richard
>>>>>
>>>>>
>>>>> Am Mo., 27. Juni 2022 um 12:02 Uhr schrieb Grzegorz Grzybek <
>>>>> gr.grzybek@gmail.com>:
>>>>>
>>>>>> Hello
>>>>>>
>>>>>> Unfortunately, only with Pax Web 8 (used in Karaf 4.4+) we've
>>>>>> refactored the WAB/HttpService/Whiteboard inter operation. Pax Web 8 allows
>>>>>> mixing web elements coming from different "origins" (whiteboard
>>>>>> registration, direct registration using HttpService or
>>>>>> web.xml/web-fragment.xml approach from WABs).
>>>>>>
>>>>>> So in Pax Web 8 you should be able to reconfigure the session cookie
>>>>>> name and there servlets registered using Whiteboard targetting the same
>>>>>> context (as in WAB) should use the same session configuration.
>>>>>>
>>>>>> Also - Pax Web 8 implements correctly the session separation
>>>>>> mentioned in
>>>>>> https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#service.http.whiteboard.servletcontext
>>>>>> :
>>>>>>
>>>>>> Http Sessions are not shared amongst servlets registered with
>>>>>>> different ServletContextHelpers. That is, HttpRequest.getSession calls must
>>>>>>> provide different sessions per associated ServletContextHelper
>>>>>>>
>>>>>>
>>>>>> So even if two whiteboard servlets are registered to the same target
>>>>>> servlet context, but using different ServletContextHelper, they'll use
>>>>>> different session configuration.
>>>>>>
>>>>>> kind regards
>>>>>> Grzegorz Grzybek
>>>>>>
>>>>>> pon., 27 cze 2022 o 11:33 Richard Hierlmeier <
>>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>>
>>>>>>>
>>>>>>> My application runs in Karaf 4.3.7. I have a web application that is
>>>>>>> deployed as wab application bundle (wab). This web application changes the
>>>>>>> session cookie name in
>>>>>>> javax.servlet.ServletContextListener#contextInitialized().
>>>>>>>
>>>>>>> In another bundle I have a servlet that is defined with
>>>>>>> HttpWhiteBoard.
>>>>>>> The servlets from the wab and the servlets from HttpWhiteBoard have
>>>>>>> different http sessions (because they have different session cookie names
>>>>>>> in the ServletContext).
>>>>>>>
>>>>>>> Is it possible to configure the session cookie for Servlets that are
>>>>>>> deployed via HttpWhiteBoard?
>>>>>>>
>>>>>>> Regards
>>>>>>>
>>>>>>>   Richard
>>>>>>>
>>>>>>>

Re: Session cookie configuration in http white board

Posted by Richard Hierlmeier <rh...@googlemail.com>.
The only requirement is that a servlet that is deployed via http whiteboard
has the same session as the servlet that is part of the WAB.

Richard

Am Do., 14. Juli 2022 um 15:13 Uhr schrieb Grzegorz Grzybek <
gr.grzybek@gmail.com>:

> Hello
>
> czw., 14 lip 2022 o 15:05 Richard Hierlmeier <rh...@googlemail.com>
> napisał(a):
>
>> How can I define the  ServletContextHelper for a WAB? I can not find any
>> hint in the R7 spec.
>>
>
> You ... can't. There's nothing at all about ServletContextHelper concept
> (Whiteboard) in chapter 128 (WABs).
>
> Pax Web 8 explicitly defines special class
> org.ops4j.pax.web.extender.war.internal.WebApplicationHelper, which extends
> org.ops4j.pax.web.service.spi.context.DefaultServletContextHelper which
> extends org.osgi.service.http.context.ServletContextHelper.
>
> Such implementation is specially crafted to:
>  - provide org.osgi.service.http.context.ServletContextHelper
>  - handle WAR scenarios related to resource access
>
> It is then set inside org.ops4j.pax.web.service.spi.model.OsgiContextModel
> - a common "context" representation for HttpService, Whiteboard and WAB
> scenarios.
>
> Out of curiosity - do you have any special requirement that a WAB needs
> custom context?
>
> Mind that org.osgi.service.http.context.ServletContextHelper in Whiteboard
> has two responsibilities:
>  - security (WABs/WARs have better ways to deal with this)
>  - resource access (WABs/WARs have standard resource access methods
> defined in the Servlets specification itself)
>
> regards
> Grzegorz Grzybek
>
>
>>
>> Richard
>>
>> Am Mo., 27. Juni 2022 um 16:15 Uhr schrieb Grzegorz Grzybek <
>> gr.grzybek@gmail.com>:
>>
>>> Hi
>>>
>>>
>>> pon., 27 cze 2022 o 16:04 Richard Hierlmeier <rh...@googlemail.com>
>>> napisał(a):
>>>
>>>> Hi  Grzegorz.
>>>>
>>>> thank you for clarification. Unfortunately I can not upgrade to Karaf
>>>> 4.4 the next time.
>>>> What would happen when I define the session cookie name in jetty.xml
>>>> and not in the wab?
>>>>
>>>
>>> To answer more precisely, I'd have to check your current configuration -
>>> what WAB are you deploying and what are the registration properties of the
>>> HttpWhiteboard servlet. Only then I could check (going back to Karaf 4.3.7)
>>> what may be the issue related to context configuration...
>>>
>>> regards
>>> Grzegorz Grzybek
>>>
>>>
>>>>
>>>>
>>>> Richard
>>>>
>>>>
>>>> Am Mo., 27. Juni 2022 um 12:02 Uhr schrieb Grzegorz Grzybek <
>>>> gr.grzybek@gmail.com>:
>>>>
>>>>> Hello
>>>>>
>>>>> Unfortunately, only with Pax Web 8 (used in Karaf 4.4+) we've
>>>>> refactored the WAB/HttpService/Whiteboard inter operation. Pax Web 8 allows
>>>>> mixing web elements coming from different "origins" (whiteboard
>>>>> registration, direct registration using HttpService or
>>>>> web.xml/web-fragment.xml approach from WABs).
>>>>>
>>>>> So in Pax Web 8 you should be able to reconfigure the session cookie
>>>>> name and there servlets registered using Whiteboard targetting the same
>>>>> context (as in WAB) should use the same session configuration.
>>>>>
>>>>> Also - Pax Web 8 implements correctly the session separation mentioned
>>>>> in
>>>>> https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#service.http.whiteboard.servletcontext
>>>>> :
>>>>>
>>>>> Http Sessions are not shared amongst servlets registered with
>>>>>> different ServletContextHelpers. That is, HttpRequest.getSession calls must
>>>>>> provide different sessions per associated ServletContextHelper
>>>>>>
>>>>>
>>>>> So even if two whiteboard servlets are registered to the same target
>>>>> servlet context, but using different ServletContextHelper, they'll use
>>>>> different session configuration.
>>>>>
>>>>> kind regards
>>>>> Grzegorz Grzybek
>>>>>
>>>>> pon., 27 cze 2022 o 11:33 Richard Hierlmeier <
>>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>>
>>>>>>
>>>>>> My application runs in Karaf 4.3.7. I have a web application that is
>>>>>> deployed as wab application bundle (wab). This web application changes the
>>>>>> session cookie name in
>>>>>> javax.servlet.ServletContextListener#contextInitialized().
>>>>>>
>>>>>> In another bundle I have a servlet that is defined with
>>>>>> HttpWhiteBoard.
>>>>>> The servlets from the wab and the servlets from HttpWhiteBoard have
>>>>>> different http sessions (because they have different session cookie names
>>>>>> in the ServletContext).
>>>>>>
>>>>>> Is it possible to configure the session cookie for Servlets that are
>>>>>> deployed via HttpWhiteBoard?
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>>   Richard
>>>>>>
>>>>>>

Re: Session cookie configuration in http white board

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Hello

czw., 14 lip 2022 o 15:05 Richard Hierlmeier <rh...@googlemail.com>
napisał(a):

> How can I define the  ServletContextHelper for a WAB? I can not find any
> hint in the R7 spec.
>

You ... can't. There's nothing at all about ServletContextHelper concept
(Whiteboard) in chapter 128 (WABs).

Pax Web 8 explicitly defines special class
org.ops4j.pax.web.extender.war.internal.WebApplicationHelper, which extends
org.ops4j.pax.web.service.spi.context.DefaultServletContextHelper which
extends org.osgi.service.http.context.ServletContextHelper.

Such implementation is specially crafted to:
 - provide org.osgi.service.http.context.ServletContextHelper
 - handle WAR scenarios related to resource access

It is then set inside org.ops4j.pax.web.service.spi.model.OsgiContextModel
- a common "context" representation for HttpService, Whiteboard and WAB
scenarios.

Out of curiosity - do you have any special requirement that a WAB needs
custom context?

Mind that org.osgi.service.http.context.ServletContextHelper in Whiteboard
has two responsibilities:
 - security (WABs/WARs have better ways to deal with this)
 - resource access (WABs/WARs have standard resource access methods defined
in the Servlets specification itself)

regards
Grzegorz Grzybek


>
> Richard
>
> Am Mo., 27. Juni 2022 um 16:15 Uhr schrieb Grzegorz Grzybek <
> gr.grzybek@gmail.com>:
>
>> Hi
>>
>>
>> pon., 27 cze 2022 o 16:04 Richard Hierlmeier <rh...@googlemail.com>
>> napisał(a):
>>
>>> Hi  Grzegorz.
>>>
>>> thank you for clarification. Unfortunately I can not upgrade to Karaf
>>> 4.4 the next time.
>>> What would happen when I define the session cookie name in jetty.xml and
>>> not in the wab?
>>>
>>
>> To answer more precisely, I'd have to check your current configuration -
>> what WAB are you deploying and what are the registration properties of the
>> HttpWhiteboard servlet. Only then I could check (going back to Karaf 4.3.7)
>> what may be the issue related to context configuration...
>>
>> regards
>> Grzegorz Grzybek
>>
>>
>>>
>>>
>>> Richard
>>>
>>>
>>> Am Mo., 27. Juni 2022 um 12:02 Uhr schrieb Grzegorz Grzybek <
>>> gr.grzybek@gmail.com>:
>>>
>>>> Hello
>>>>
>>>> Unfortunately, only with Pax Web 8 (used in Karaf 4.4+) we've
>>>> refactored the WAB/HttpService/Whiteboard inter operation. Pax Web 8 allows
>>>> mixing web elements coming from different "origins" (whiteboard
>>>> registration, direct registration using HttpService or
>>>> web.xml/web-fragment.xml approach from WABs).
>>>>
>>>> So in Pax Web 8 you should be able to reconfigure the session cookie
>>>> name and there servlets registered using Whiteboard targetting the same
>>>> context (as in WAB) should use the same session configuration.
>>>>
>>>> Also - Pax Web 8 implements correctly the session separation mentioned
>>>> in
>>>> https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#service.http.whiteboard.servletcontext
>>>> :
>>>>
>>>> Http Sessions are not shared amongst servlets registered with different
>>>>> ServletContextHelpers. That is, HttpRequest.getSession calls must provide
>>>>> different sessions per associated ServletContextHelper
>>>>>
>>>>
>>>> So even if two whiteboard servlets are registered to the same target
>>>> servlet context, but using different ServletContextHelper, they'll use
>>>> different session configuration.
>>>>
>>>> kind regards
>>>> Grzegorz Grzybek
>>>>
>>>> pon., 27 cze 2022 o 11:33 Richard Hierlmeier <
>>>> rhierlmeier@googlemail.com> napisał(a):
>>>>
>>>>>
>>>>> My application runs in Karaf 4.3.7. I have a web application that is
>>>>> deployed as wab application bundle (wab). This web application changes the
>>>>> session cookie name in
>>>>> javax.servlet.ServletContextListener#contextInitialized().
>>>>>
>>>>> In another bundle I have a servlet that is defined with HttpWhiteBoard.
>>>>> The servlets from the wab and the servlets from HttpWhiteBoard have
>>>>> different http sessions (because they have different session cookie names
>>>>> in the ServletContext).
>>>>>
>>>>> Is it possible to configure the session cookie for Servlets that are
>>>>> deployed via HttpWhiteBoard?
>>>>>
>>>>> Regards
>>>>>
>>>>>   Richard
>>>>>
>>>>>