Handler in ESB proxy service

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Handler in ESB proxy service

Piriya Sivalingam
Hi,
 
I have a scenario where I have to decode the JWT token at the ESB layer and fetch the user role from that token and validate at the ESB. I have a handler to decode the generated JWT token and extract the role. I have tried different ways in order to call that handler in my ESB proxy service. 

1. Added the below code inside the synapse configuration of my proxy service located at <ESB_HOME>/repository/deployment/server/synapse-configs/default/proxy-services. 

<handlers>
      <handler class="org.wso2.rest.JwtHandler"/>
   </handlers>

2. Added the above code into the axis2.xml file located at <ESB_HOME>/repository/conf/axis2/axis2.xml.

I start the server in debug mode and noticed that handler does not get executed.

And according to the first method, whenever I make any changes to the proxy, that (handler) gets removed. If I am not wrong, this is the expected behavior. 


Could you please suggest how can I call the handler inside my ESB proxy service?

The ESB version is ESB 5.0.0.

Thanks,
Piriya

--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : +94 77 8462039

http://wso2.com/signature


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Handler in ESB proxy service

Mushthaq Rumy
Hi Piriya,

Have you included the JAR or the OSGI bundle in your ESB pack? If not could you please add it. Can you try adding the handler to your proxy through management console?

Thanks & Regards,
Mushthaq

On Tue, Nov 21, 2017 at 4:55 PM, Piriya Sivalingam <[hidden email]> wrote:
Hi,
 
I have a scenario where I have to decode the JWT token at the ESB layer and fetch the user role from that token and validate at the ESB. I have a handler to decode the generated JWT token and extract the role. I have tried different ways in order to call that handler in my ESB proxy service. 

1. Added the below code inside the synapse configuration of my proxy service located at <ESB_HOME>/repository/deployment/server/synapse-configs/default/proxy-services. 

<handlers>
      <handler class="org.wso2.rest.JwtHandler"/>
   </handlers>

2. Added the above code into the axis2.xml file located at <ESB_HOME>/repository/conf/axis2/axis2.xml.

I start the server in debug mode and noticed that handler does not get executed.

And according to the first method, whenever I make any changes to the proxy, that (handler) gets removed. If I am not wrong, this is the expected behavior. 


Could you please suggest how can I call the handler inside my ESB proxy service?

The ESB version is ESB 5.0.0.

Thanks,
Piriya

--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : <a href="tel:+94%2077%20846%202039" value="+94778462039" target="_blank">+94 77 8462039

http://wso2.com/signature


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Mushthaq Rumy
Software Engineer
Mobile : <a href="tel:%2B94%20%280%29%20773%20451194" value="+94773451194" target="_blank">+94 (0) 779 492140
Email : [hidden email]
WSO2, Inc.; http://wso2.com/
lean . enterprise . middleware.


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Handler in ESB proxy service

Piriya Sivalingam
Hi,

I have already copied the JAR to <ESB_HOME>/repository/components/lib folder. 
And also I have tried adding handler to the proxy via management console. It gets removed when I save the proxy.

On Wed, Nov 22, 2017 at 5:52 AM, Mushthaq Rumy <[hidden email]> wrote:
Hi Piriya,

Have you included the JAR or the OSGI bundle in your ESB pack? If not could you please add it. Can you try adding the handler to your proxy through management console?

Thanks & Regards,
Mushthaq

On Tue, Nov 21, 2017 at 4:55 PM, Piriya Sivalingam <[hidden email]> wrote:
Hi,
 
I have a scenario where I have to decode the JWT token at the ESB layer and fetch the user role from that token and validate at the ESB. I have a handler to decode the generated JWT token and extract the role. I have tried different ways in order to call that handler in my ESB proxy service. 

1. Added the below code inside the synapse configuration of my proxy service located at <ESB_HOME>/repository/deployment/server/synapse-configs/default/proxy-services. 

<handlers>
      <handler class="org.wso2.rest.JwtHandler"/>
   </handlers>

2. Added the above code into the axis2.xml file located at <ESB_HOME>/repository/conf/axis2/axis2.xml.

I start the server in debug mode and noticed that handler does not get executed.

And according to the first method, whenever I make any changes to the proxy, that (handler) gets removed. If I am not wrong, this is the expected behavior. 


Could you please suggest how can I call the handler inside my ESB proxy service?

The ESB version is ESB 5.0.0.

Thanks,
Piriya

--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : <a href="tel:+94%2077%20846%202039" value="+94778462039" target="_blank">+94 77 8462039

http://wso2.com/signature


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Mushthaq Rumy
Software Engineer
Mobile : <a href="tel:%2B94%20%280%29%20773%20451194" value="+94773451194" target="_blank">+94 (0) 779 492140
Email : [hidden email]
WSO2, Inc.; http://wso2.com/
lean . enterprise . middleware.




--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : +94 77 8462039

http://wso2.com/signature


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Handler in ESB proxy service

Nadeeshaan Gunasinghe
Hi Piriya,

AFIK, we usually don't use handlers in Proxy services, we use handlers with REST APIs. The second approach you have followed, only valid for the axis2 handlers and I think that's why it wasn't getting invoked in your scenario. In order to handle your requirement, there are two other options to follow. I think the second option will be a better approach if I understood your requirement properly.

1. Implement a Synapse Handler as in [1]
2. Implements a custom class mediator and invoke it inside the proxy service

[1] https://docs.wso2.com/display/ESB490/Writing+a+Synapse+Handler

Cheers,
Nadeeshaan Gunasinghe
Senior Software Engineer, WSO2 Inc. http://wso2.com
<a href="tel:+94770596754" style="color:rgb(141,141,141);text-decoration:none">+94770596754 | [hidden email] | Skype: nadeeshaan.gunasinghe

On Wed, Nov 22, 2017 at 10:18 AM, Piriya Sivalingam <[hidden email]> wrote:
Hi,

I have already copied the JAR to <ESB_HOME>/repository/components/lib folder. 
And also I have tried adding handler to the proxy via management console. It gets removed when I save the proxy.

On Wed, Nov 22, 2017 at 5:52 AM, Mushthaq Rumy <[hidden email]> wrote:
Hi Piriya,

Have you included the JAR or the OSGI bundle in your ESB pack? If not could you please add it. Can you try adding the handler to your proxy through management console?

Thanks & Regards,
Mushthaq

On Tue, Nov 21, 2017 at 4:55 PM, Piriya Sivalingam <[hidden email]> wrote:
Hi,
 
I have a scenario where I have to decode the JWT token at the ESB layer and fetch the user role from that token and validate at the ESB. I have a handler to decode the generated JWT token and extract the role. I have tried different ways in order to call that handler in my ESB proxy service. 

1. Added the below code inside the synapse configuration of my proxy service located at <ESB_HOME>/repository/deployment/server/synapse-configs/default/proxy-services. 

<handlers>
      <handler class="org.wso2.rest.JwtHandler"/>
   </handlers>

2. Added the above code into the axis2.xml file located at <ESB_HOME>/repository/conf/axis2/axis2.xml.

I start the server in debug mode and noticed that handler does not get executed.

And according to the first method, whenever I make any changes to the proxy, that (handler) gets removed. If I am not wrong, this is the expected behavior. 


Could you please suggest how can I call the handler inside my ESB proxy service?

The ESB version is ESB 5.0.0.

Thanks,
Piriya

--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : <a href="tel:+94%2077%20846%202039" value="+94778462039" target="_blank">+94 77 8462039

http://wso2.com/signature


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Mushthaq Rumy
Software Engineer
Mobile : <a href="tel:%2B94%20%280%29%20773%20451194" value="+94773451194" target="_blank">+94 (0) 779 492140
Email : [hidden email]
WSO2, Inc.; http://wso2.com/
lean . enterprise . middleware.




--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : <a href="tel:+94%2077%20846%202039" value="+94778462039" target="_blank">+94 77 8462039

http://wso2.com/signature


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev



_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Handler in ESB proxy service

Piriya Sivalingam
Hi Nadeeshaan,

Thank you for the description and I think your second method will work for my scenario. I will try it and let you know.

Thank you.
Piriya

On Wed, Nov 22, 2017 at 10:48 AM, Nadeeshaan Gunasinghe <[hidden email]> wrote:
Hi Piriya,

AFIK, we usually don't use handlers in Proxy services, we use handlers with REST APIs. The second approach you have followed, only valid for the axis2 handlers and I think that's why it wasn't getting invoked in your scenario. In order to handle your requirement, there are two other options to follow. I think the second option will be a better approach if I understood your requirement properly.

1. Implement a Synapse Handler as in [1]
2. Implements a custom class mediator and invoke it inside the proxy service

[1] https://docs.wso2.com/display/ESB490/Writing+a+Synapse+Handler

Cheers,
Nadeeshaan Gunasinghe
Senior Software Engineer, WSO2 Inc. http://wso2.com
<a href="tel:+94770596754" style="color:rgb(141,141,141);text-decoration:none" target="_blank">+94770596754 | [hidden email] | Skype: nadeeshaan.gunasinghe

On Wed, Nov 22, 2017 at 10:18 AM, Piriya Sivalingam <[hidden email]> wrote:
Hi,

I have already copied the JAR to <ESB_HOME>/repository/components/lib folder. 
And also I have tried adding handler to the proxy via management console. It gets removed when I save the proxy.

On Wed, Nov 22, 2017 at 5:52 AM, Mushthaq Rumy <[hidden email]> wrote:
Hi Piriya,

Have you included the JAR or the OSGI bundle in your ESB pack? If not could you please add it. Can you try adding the handler to your proxy through management console?

Thanks & Regards,
Mushthaq

On Tue, Nov 21, 2017 at 4:55 PM, Piriya Sivalingam <[hidden email]> wrote:
Hi,
 
I have a scenario where I have to decode the JWT token at the ESB layer and fetch the user role from that token and validate at the ESB. I have a handler to decode the generated JWT token and extract the role. I have tried different ways in order to call that handler in my ESB proxy service. 

1. Added the below code inside the synapse configuration of my proxy service located at <ESB_HOME>/repository/deployment/server/synapse-configs/default/proxy-services. 

<handlers>
      <handler class="org.wso2.rest.JwtHandler"/>
   </handlers>

2. Added the above code into the axis2.xml file located at <ESB_HOME>/repository/conf/axis2/axis2.xml.

I start the server in debug mode and noticed that handler does not get executed.

And according to the first method, whenever I make any changes to the proxy, that (handler) gets removed. If I am not wrong, this is the expected behavior. 


Could you please suggest how can I call the handler inside my ESB proxy service?

The ESB version is ESB 5.0.0.

Thanks,
Piriya

--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : <a href="tel:+94%2077%20846%202039" value="+94778462039" target="_blank">+94 77 8462039

http://wso2.com/signature


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Mushthaq Rumy
Software Engineer
Mobile : <a href="tel:%2B94%20%280%29%20773%20451194" value="+94773451194" target="_blank">+94 (0) 779 492140
Email : [hidden email]
WSO2, Inc.; http://wso2.com/
lean . enterprise . middleware.




--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : <a href="tel:+94%2077%20846%202039" value="+94778462039" target="_blank">+94 77 8462039

http://wso2.com/signature


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev





--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : +94 77 8462039

http://wso2.com/signature


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev