Вопрос

I've got the CXF OSGi bundle deployed on a karaf container with several endpoints each in their own bundle. The endpoints are a mix of JAX-RS and JAX-WS flavors. I'd like to enable some security on the endpoints with JOSSO and need to register a servlet filter to do so. Obviously, with no web.xml to declare the filter, I need to register them in the OSGi service registry.

I've attempted to use the pax-web http whiteboard to register a filter but the doFilter method is never invoked. I noticed the Distributed OSGI cxf implementation has a provision for setting a org.apache.cxf.httpservice.filter property to true on the filter and specifying a dummy string for servletNames so as not to confuse pax-web whiteboard. Is there something similar for the standard CXF (non-distributed) OSGi bundle that I can do to register a servlet filter?

Это было полезно?

Решение

After lots of digging I was able to set a filter to the CXF Servlet with Felix + PAX Web. The trick is to register the filter from within the CXF bundle (there is a distinct http context for each bundle).

In my code I fetched the bundle context, called getBundles(), located the cxf bundle and obtained the bundle context of the CXF bundle. Then I registered the filter on the CXF bundle's context. I feel very dirty now, but it works.

I recall to have seen a recommendation to create a fragement bundle for configuration of PAX's Jetty server, this would probably also work for registering a filter - however I didn't want to create another artifact in our project at the current time.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top