Sunday, November 3, 2013

How to Test JWT caching in WSO2 API Manager


How to Test JWT caching in API Manager

Before get in to this post (http://ushanib.blogspot.com/2013/03/how-to-test-values-in-oauth2-token.html) should be referred to know the steps to enable JWT token.
When you enable JWT token in a distributed set up you should enable it in publisher node and the key manager node.
This is enabled in publisher node because to change the API template accordingly.
Enable in keymanager node : To cache it in keymanager
But when you enable caching you will have to enable it only in the key manager node.

Steps:
=====
  1. First you need to enable JWT token as explained in this post
  2. To enable Caching you need to set “true” in the following parameter in the api-manager.xml in <AM_Home>/repository/conf.
    <EnableJWTCache>true</EnableJWTCache>

To Test :
======
  1. First without the caching enabled you can vie the results as explained in the post mentioned.

  2. Then to go to your My Application page as given in the below screenshot and edit the application name that you have subscribed to. E.g., In the above mentioned post, subscription is done to DefaultApplication. You can change the name of it as app1.




  3. Then send a API call request and follow the steps 11 to 15 as given in this post.

  4. You will see the changed app name fter decoding the encoded value as follows :

"http://wso2.org/claims/applicationname":"app1"

  1. Now enable the JWT caching as given in step 2 above and edit the app name as app2 and perform the above step 3 again.

Observation :
==========
  1. Once you decode, you will be able to see the application name as app1 still since the JWT caching is enabled and the app name will be taken from the cache.

  2. But if you disable JWT caching and do the same steps you will be able to see the changed app name.

  3. If you have enabled key manager or gateway caching with JWT caching still it will show you the cached app name. But if the JWT caching is disabled and gateway or key manager caching is enabled, you should not be able to see the app name changes since the JWT caching is disabled.