camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cristiano Costantini <cristiano.costant...@gmail.com>
Subject Re: Authentication in "pipes and filters" ???
Date Fri, 17 Apr 2015 09:36:04 GMT
Hi Willem, hi all,
thank you for your support,

I wanted to avoid to throw an exception, because then I have to handle it
in order to return proper payload (I want empty payload if the user is not
authenticated) in the response.

I've maybe found a different approach that I am now investigating:
As I am processing the message in a custom Processor (who both performs
authentication and checks authorization), I've discovered that I can stop
the processing in the Processor by setting a property on the exchange:

exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);

So if the message is not authorized, I first set the body to my empty body
(I set to a Collections.emptyList() ) and then stop it.

The Junit tests now are working, I now integrate it to check if there are
other issues.

Feedback on the approach of using "Exchange.ROUTE_STOP" is welcome :-)

Bye,
Cristiano



Il giorno gio 16 apr 2015 alle ore 17:19 Willem Jiang <
willem.jiang@gmail.com> ha scritto:

> I think you can just throw out the authentication failure exception and
> you can use the error handler to setup some kind of reject exception for
> the response to use.
>
> --
> Willem Jiang
>
> Red Hat, Inc.
> Web: http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (English)
> http://jnn.iteye.com (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
> On April 16, 2015 at 4:15:38 PM, Cristiano Costantini (
> cristiano.costantini@gmail.com) wrote:
> > Hello,
> >
> > I was searching to implement a "Pipes and Filter" EIP that, as the
> picture
> > illustrated in http://camel.apache.org/pipes-and-filters.html, it has a
> > step that "Authenticates" the exchange.
> >
> > I have not however figured out how to manage a failed authentication:
> > how do I best implement the rejection of the exchange to be further
> > processed by subsequents endpoints?
> >
> > I'm confused as my exchange is an InOut, so I cannot simply abort the
> > processing, I need to send back some output (either an empty response or
> > error code) to the initial from endpoint...
> >
> > Any suggestion?
> > thanks,
> > Cristiano
> >
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message