You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Sudhir N <su...@yahoo.com> on 2012/09/07 10:55:01 UTC

Caching authorization

Hello,

I know it's possible to cache authorization, but I haven't been able to figureout how to do that apart from configuring a cache manager.
We have lot's of wildcard permissions, and now it has started showing the performance issues, I would like to cache the authorization..
I have successfully configured EhCacheManager but I am not sure if it is being used (If I put breakpoint in my realm's isPermitted - the method is hit every time)

So what things needs to be done apart from configuring a CacheManager in order to cache the authorization.. 
 
If there's any tutorial/reference point me to that as well

Thanks    
Sudhir 

Re: Caching authorization

Posted by Sean Blaes <se...@hifiit.com>.
isPermitted should be called even if the cache is working… If you look at the AuthorizingRealm source in Shiro, look at the implementations of isPermitted. Note that they call getAuthorizationInfo, and that is where the cache is connected to and utilized. As such, the key thing here is that it still must call isPermitted to ensure that the operation is allowed each time, but it doesn't have to go the database or ldap (depending up on what realm you're using) to lookup what the user is actually allowed to do. So, the cache utilization occurs inside the getAuthorizationInfo so that the lookup of the user's actual permissions and roles is cached. If you want to see whether the cache is being utilized or not, check whether doGetAuthorizationInfo is getting called after it should be cached. If it is, then perhaps you've overridden the getAuthorizationInfo method, and if that's the case, you'll need to implement the cache lookup in that method similar to the AuthorizingRealm code.

--  
Sean Blaes
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Friday, September 7, 2012 at 3:55 AM, Sudhir N wrote:

> Hello,
>  
> I know it's possible to cache authorization, but I haven't been able to figureout how to do that apart from configuring a cache manager.
> We have lot's of wildcard permissions, and now it has started showing the performance issues, I would like to cache the authorization..
> I have successfully configured EhCacheManager but I am not sure if it is being used (If I put breakpoint in my realm's isPermitted - the method is hit every time)
>  
> So what things needs to be done apart from configuring a CacheManager in order to cache the authorization..  
>   
> If there's any tutorial/reference point me to that as well
>  
> Thanks     
> Sudhir  
>   
>  
>  
>  
>  
>