Integrating Apache Camel CXF-RS + CXF Jax-RS OAuth

I am using Apache Camel with CXF-RS using the standard integration provided by Camel (using an embedded Jetty in executable JAR) and it works perfectly.

I want to add OAuth support (as OAuth 1 provider) to my REST server, as I am already using CXF, I plan to use CXF JAX-RS OAuth integration on it:

Unfortunately, it seems I need to use a servlet for OAuth support and I am struggling to add this before the call of my Camel Processor. As my route is defined by:

String CONTEXT = "?resourceClasses=" + MyServiceResource.class.getName();
final String cxfRSEndpointUri = "cxfrs://http://" + restServerUrl + ":" + restServerPort + CONTEXT;

From the processor point of view (restProcessor), I can't get a HttpServletRequest and a HttpServletResponse from the Exchange object, the cxfrs route don't give me correct bodies:

final HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
final HttpServletResponse response = exchange.getOut().getBody(HttpServletResponse.class);

These two commands return null: cxfrs is not like a classic Camel HTTP route.

Is there a way to configure a Camel Route that would add a servlet filter (OAuthServletFilter given by CXF JAX-RS OAuth) before using the cxfrs route?

The other way I see is to check the sources of CXF JAX-RS OAuth: the class contains the implementation of the checks needed by OAuth, but if possible I prefer not to fork a part of this class, and it would require me to check HTTP headers / values from the exchange object given by camel manually. I believe there should be a better way to do so, but maybe I am wrong.


I finally made it work cleanly: I don't use a "cxfrs:http..." route but instead a "cxfrs:bean:rsServer..." route.

It enables me to define in Spring a CXFRS server bean in which I can add an OAuthRequestFilter to it. Then I reference it in my Camel route and it works!

Need Your Help

x86 ASM Linux - Using the .bss Section

linux assembly x86 nasm

I hope these questions is rather simple: (NASM Compiler, Linux, x86 Intel Syntax)

Need guidance on alternative JVMs for Apple OS X

java osx jvm

Apple has deprecated their JVM and it may not be supported in future versions of OS X. I am not primarily a Java developer, but I do write Java applications now and then, and the primary applicatio...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.