You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by helander <le...@gmail.com> on 2012/07/19 09:37:48 UTC

Forced "termination" of the current exchange and returning appropriate response code

In my setup I have a cxf endpoint that are consumed by a route. As the first
step in my route I have a bean that picks up the TLSSession from the
exchange and puts back a property on the exchange that contains the peer
certificates. I doing this in order to access information from the client
certificates further down the route. In the case that no client certificate
has been provided (access was via http and not https or the http server
configuration may not have required the certificates to be provided by the
client) I would like to force the exchange to "return" ( no further
processing along the route) and provide some appropriate return code.

What specific operations do I have to do on the exchange (or its in/out
messages) to make Camel "terminate" the route with the appropriate (HTTP)
return code.

/Lars

--
View this message in context: http://camel.465427.n5.nabble.com/Forced-termination-of-the-current-exchange-and-returning-appropriate-response-code-tp5716235.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Forced "termination" of the current exchange and returning appropriate response code

Posted by helander <le...@gmail.com>.
Hi Claus,

thanks for the suggestions. This will help a lot.

/Lars



--
View this message in context: http://camel.465427.n5.nabble.com/Forced-termination-of-the-current-exchange-and-returning-appropriate-response-code-tp5716235p5716306.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Forced "termination" of the current exchange and returning appropriate response code

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can do a content based router, and if the certificate is invalid,
then return a response.
http://camel.apache.org/content-based-router.html

There is also a stop EIP to stop further processing. You can put that
on the exchange as a property from java code, eg so you can just use a
bean to check if the certificate is valid or not. And if not valid,
then set the message with some response payload, and then mark it to
stop.

There is a constant on Exchange with the name of the property
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Exchange.html#ROUTE_STOP

See for example the StopProcessor source code.

There are other ways such as thrown an exception and using the error
handler to react and stop routing etc.


On Thu, Jul 19, 2012 at 9:37 AM, helander <le...@gmail.com> wrote:
> In my setup I have a cxf endpoint that are consumed by a route. As the first
> step in my route I have a bean that picks up the TLSSession from the
> exchange and puts back a property on the exchange that contains the peer
> certificates. I doing this in order to access information from the client
> certificates further down the route. In the case that no client certificate
> has been provided (access was via http and not https or the http server
> configuration may not have required the certificates to be provided by the
> client) I would like to force the exchange to "return" ( no further
> processing along the route) and provide some appropriate return code.
>
> What specific operations do I have to do on the exchange (or its in/out
> messages) to make Camel "terminate" the route with the appropriate (HTTP)
> return code.
>
> /Lars
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Forced-termination-of-the-current-exchange-and-returning-appropriate-response-code-tp5716235.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen