You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by SwenVogel <sw...@ypsystems.de> on 2010/01/21 16:30:15 UTC

Jetty Security Handler

Hi,

i created a customer jetty security handler and configured the spring
configuration file accordingly.
In the security handler i use my own "exec" camel component for the
authentication.

In short my "exec" component can executes external programs and makes use of
the
apache-commons-exec library.

The problem is that the OnCompletition's are not called. When is use the
component
in other routes everything works fine.

Here is the code from my "exec" producer that adds the OnCompletition:
exchange.addOnCompletion(new ExecOnCompletition(endpoint, processIO));


Here the security handler code:

String authEndpoint = "exec:authProg?dir=c:/&exitValues=0;1&args="
    + username + ";"
    + credentials;

ProducerTemplate template = camelContext.createProducerTemplate();
Exchange result = template.send(authEndpoint, new
DefaultExchange(camelContext));

Integer exitCode = result.getOut().getHeader(
    ExecComponent.EXEC_EXITCODE, Integer.class);

-- 
View this message in context: http://old.nabble.com/Jetty-Security-Handler-tp27259580p27259580.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Jetty Security Handler

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 22, 2010 at 10:29 AM, SwenVogel <sw...@ypsystems.de> wrote:
>
> Hi,
>
> i use the send() method of the producer template, like in the code snippet
> from the first post.
>
> Means "Custom OnCompletion is triggered when you use a route." that when
> i use a standard component for example "file" that the
> GenericFileOnCompletion is triggered?
>
> I thought that a component is like a encapsulated logical unit but it seems
> that the internal
> semantic changes when i use a route or the ProducerTemplate. It's a little
> bit confusing.
>
> For example when i write a component that must do some important kind of
> cleanup
> after processing, this cleanup must be done regardless whether i use a route
> or a
> ProducerTemplate.
>
> Is there a way to manually trigger the OnCompletitions's?
>

You can always manually invoke it

Synchronization onComp = ...
Exchange result = template.send(xxxx);

comp.onComplete(result);





>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Do you send directly to the endpoint of your custom component?
>> Custom OnCompletion is triggered when you use a route.
>>
>>
>>
>> On Thu, Jan 21, 2010 at 4:30 PM, SwenVogel <sw...@ypsystems.de>
>> wrote:
>>>
>>> Hi,
>>>
>>> i created a customer jetty security handler and configured the spring
>>> configuration file accordingly.
>>> In the security handler i use my own "exec" camel component for the
>>> authentication.
>>>
>>> In short my "exec" component can executes external programs and makes use
>>> of
>>> the
>>> apache-commons-exec library.
>>>
>>> The problem is that the OnCompletition's are not called. When is use the
>>> component
>>> in other routes everything works fine.
>>>
>>> Here is the code from my "exec" producer that adds the OnCompletition:
>>> exchange.addOnCompletion(new ExecOnCompletition(endpoint, processIO));
>>>
>>>
>>> Here the security handler code:
>>>
>>> String authEndpoint = "exec:authProg?dir=c:/&exitValues=0;1&args="
>>>    + username + ";"
>>>    + credentials;
>>>
>>> ProducerTemplate template = camelContext.createProducerTemplate();
>>> Exchange result = template.send(authEndpoint, new
>>> DefaultExchange(camelContext));
>>>
>>> Integer exitCode = result.getOut().getHeader(
>>>    ExecComponent.EXEC_EXITCODE, Integer.class);
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Jetty-Security-Handler-tp27259580p27259580.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Jetty-Security-Handler-tp27259580p27270602.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Jetty Security Handler

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 22, 2010 at 10:29 AM, SwenVogel <sw...@ypsystems.de> wrote:
>
> Hi,
>
> i use the send() method of the producer template, like in the code snippet
> from the first post.
>
> Means "Custom OnCompletion is triggered when you use a route." that when
> i use a standard component for example "file" that the
> GenericFileOnCompletion is triggered?
>
> I thought that a component is like a encapsulated logical unit but it seems
> that the internal
> semantic changes when i use a route or the ProducerTemplate. It's a little
> bit confusing.
>

All the cross cutting functions such as interceptors, on completion,
on exception is route based.
Camel does a lot of stuff when building routes which allows it to
weave in those cross cutting stuff at the right places etc.

You can add some custom completion to your component if its important
for your component that it does some cleanup etc.



> For example when i write a component that must do some important kind of
> cleanup
> after processing, this cleanup must be done regardless whether i use a route
> or a
> ProducerTemplate.
>
> Is there a way to manually trigger the OnCompletitions's?
>

No, you can however use the asyncXXXCallback method from producer
template which offers on completion callbacks


>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Do you send directly to the endpoint of your custom component?
>> Custom OnCompletion is triggered when you use a route.
>>
>>
>>
>> On Thu, Jan 21, 2010 at 4:30 PM, SwenVogel <sw...@ypsystems.de>
>> wrote:
>>>
>>> Hi,
>>>
>>> i created a customer jetty security handler and configured the spring
>>> configuration file accordingly.
>>> In the security handler i use my own "exec" camel component for the
>>> authentication.
>>>
>>> In short my "exec" component can executes external programs and makes use
>>> of
>>> the
>>> apache-commons-exec library.
>>>
>>> The problem is that the OnCompletition's are not called. When is use the
>>> component
>>> in other routes everything works fine.
>>>
>>> Here is the code from my "exec" producer that adds the OnCompletition:
>>> exchange.addOnCompletion(new ExecOnCompletition(endpoint, processIO));
>>>
>>>
>>> Here the security handler code:
>>>
>>> String authEndpoint = "exec:authProg?dir=c:/&exitValues=0;1&args="
>>>    + username + ";"
>>>    + credentials;
>>>
>>> ProducerTemplate template = camelContext.createProducerTemplate();
>>> Exchange result = template.send(authEndpoint, new
>>> DefaultExchange(camelContext));
>>>
>>> Integer exitCode = result.getOut().getHeader(
>>>    ExecComponent.EXEC_EXITCODE, Integer.class);
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Jetty-Security-Handler-tp27259580p27259580.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Jetty-Security-Handler-tp27259580p27270602.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Jetty Security Handler

Posted by SwenVogel <sw...@ypsystems.de>.
Hi,

i use the send() method of the producer template, like in the code snippet
from the first post.

Means "Custom OnCompletion is triggered when you use a route." that when
i use a standard component for example "file" that the
GenericFileOnCompletion is triggered?

I thought that a component is like a encapsulated logical unit but it seems
that the internal 
semantic changes when i use a route or the ProducerTemplate. It's a little
bit confusing.

For example when i write a component that must do some important kind of
cleanup
after processing, this cleanup must be done regardless whether i use a route
or a
ProducerTemplate.

Is there a way to manually trigger the OnCompletitions's?



Claus Ibsen-2 wrote:
> 
> Hi
> 
> Do you send directly to the endpoint of your custom component?
> Custom OnCompletion is triggered when you use a route.
> 
> 
> 
> On Thu, Jan 21, 2010 at 4:30 PM, SwenVogel <sw...@ypsystems.de>
> wrote:
>>
>> Hi,
>>
>> i created a customer jetty security handler and configured the spring
>> configuration file accordingly.
>> In the security handler i use my own "exec" camel component for the
>> authentication.
>>
>> In short my "exec" component can executes external programs and makes use
>> of
>> the
>> apache-commons-exec library.
>>
>> The problem is that the OnCompletition's are not called. When is use the
>> component
>> in other routes everything works fine.
>>
>> Here is the code from my "exec" producer that adds the OnCompletition:
>> exchange.addOnCompletion(new ExecOnCompletition(endpoint, processIO));
>>
>>
>> Here the security handler code:
>>
>> String authEndpoint = "exec:authProg?dir=c:/&exitValues=0;1&args="
>>    + username + ";"
>>    + credentials;
>>
>> ProducerTemplate template = camelContext.createProducerTemplate();
>> Exchange result = template.send(authEndpoint, new
>> DefaultExchange(camelContext));
>>
>> Integer exitCode = result.getOut().getHeader(
>>    ExecComponent.EXEC_EXITCODE, Integer.class);
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Jetty-Security-Handler-tp27259580p27259580.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Jetty-Security-Handler-tp27259580p27270602.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Jetty Security Handler

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

Do you send directly to the endpoint of your custom component?
Custom OnCompletion is triggered when you use a route.



On Thu, Jan 21, 2010 at 4:30 PM, SwenVogel <sw...@ypsystems.de> wrote:
>
> Hi,
>
> i created a customer jetty security handler and configured the spring
> configuration file accordingly.
> In the security handler i use my own "exec" camel component for the
> authentication.
>
> In short my "exec" component can executes external programs and makes use of
> the
> apache-commons-exec library.
>
> The problem is that the OnCompletition's are not called. When is use the
> component
> in other routes everything works fine.
>
> Here is the code from my "exec" producer that adds the OnCompletition:
> exchange.addOnCompletion(new ExecOnCompletition(endpoint, processIO));
>
>
> Here the security handler code:
>
> String authEndpoint = "exec:authProg?dir=c:/&exitValues=0;1&args="
>    + username + ";"
>    + credentials;
>
> ProducerTemplate template = camelContext.createProducerTemplate();
> Exchange result = template.send(authEndpoint, new
> DefaultExchange(camelContext));
>
> Integer exitCode = result.getOut().getHeader(
>    ExecComponent.EXEC_EXITCODE, Integer.class);
>
> --
> View this message in context: http://old.nabble.com/Jetty-Security-Handler-tp27259580p27259580.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Jetty Security Handler

Posted by huntc <hu...@mac.com>.
Hi,

I needed to adorn my own authorisation policy to Jetty endpoints a while
back and so we subsequently modified the component. Take a look at
http://camel.apache.org/jetty.html and the section entitled "Jetty handlers
and security configuration".

The approach uses JAAS.

Maybe this will be useful to you.

Kind regards,
Christopher

-- 
View this message in context: http://old.nabble.com/Jetty-Security-Handler-tp27259580p27289340.html
Sent from the Camel - Users mailing list archive at Nabble.com.