Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSGI HttpService : securing all the servlets

I'm developing servlets and register them into my OSGI container thanks to HttpService. My goal is to secure all the servlets registered in my OSGI container. I saw that I can register my Servlet with an HttpContext with my own handleSecurity method implementation to process my security.

But I'm thinking to the case where a bundle registers a servlet with the default HttpContext (with implies no security).

So my question is, is there a way to force the security of all the servlets deployed in my OSGI container once for all?

like image 366
guillaume Avatar asked Jan 30 '26 07:01

guillaume


2 Answers

I'm going to use the Service hook feature (OSGI 4.3) in order to override the behaviour of HttpService.registerServlet. In my hook I'll force the usage of my HttContext implementation.

With this solution, any bundle that register a servlet with the HttpService will be secured by my HttpContext implementation.

like image 147
guillaume Avatar answered Feb 02 '26 03:02

guillaume


The short answer is No for using the HttpService.

The longer answer, you might achieve something like this if you use the whiteboard-extender which isn't available per OSGi spec yet, but felix and pax-web do provide it. When using the whiteboard-extender you're able to register your servlet in combination with a reference to a HttpContext (as property). Of course this HttpContext would also need to be a "customized" one but you only need to register it once and are able to reference it from your Servlets. This is probably the closest you get to your question.

like image 45
Achim Nierbeck Avatar answered Feb 02 '26 01:02

Achim Nierbeck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!