views:

1629

answers:

1

I have a Spring application that publishes some RESTful web services using Apache CXF (using jax-rs). I would like to secure access to those services using HTTP basic authentication. The username and password should be in a Spring configuration file. The main application already uses Spring Security and I would prefer not to mess with that setup.

What is the easiest way to do this? I could write my own ServletFilter but surely there must be a way to configure this?

+3  A: 

The author of HTTP Basic Authentication with Apache CXF Revisited provides the code of a CXF Interceptor that implements HTTP Basic Authentication validation and a sample of how to define the security interceptor and enable it on a simple endpoint.

Pascal Thivent
Thanks. I found that one as well. I was hoping for a "few lines of XML" solution but it will do. :)
David Tinker
Actually, I found another solution here: http://www.mail-archive.com/[email protected]/msg02906.html
Pascal Thivent