Documentation related to EHCache setup needs to be clearer
----------------------------------------------------------

                 Key: SHIRO-336
                 URL: https://issues.apache.org/jira/browse/SHIRO-336
             Project: Shiro
          Issue Type: Improvement
          Components: Caching , Documentation
    Affects Versions: 2.0.0
         Environment: documentation
            Reporter: Jeff Parker
            Priority: Minor


See thread: 
http://shiro-user.582556.n2.nabble.com/Issue-with-Shiro-authorization-getting-cleared-td7140992.html

It turns out that this was a cache "problem".  AuthorizingRealm requires its 
own cache to be defined and sans doing that reverts back to the default cache 
(2 minute cache).  The cache HAS to be named as follows:

authorizationCacheName = getClass().getName() + 
DEFAULT_AUTHORIZATION_CACHE_SUFFIX;

where the suffix is ".authorizationCache".  Failing to define an eternal cache 
for this results in really odd behavior.  If you override AuthorizingCache then 
you'll need to define the cache using your own class name as shown below.

    <cache name="com.samples.MyCustomRealm.authorizationCache"
           maxElementsInMemory="10000"
           overflowToDisk="true"
           eternal="true"
           timeToLiveSeconds="0"
           timeToIdleSeconds="0"
           diskPersistent="true"
           diskExpiryThreadIntervalSeconds="600">
    </cache>

Maybe this is in the documentation somewhere, but I totally missed it and it 
caused me a lot of time and effort to figure it out.  The documentation does 
say that expiring the cache without telling Shiro about it is a very bad thing 
-- I agree.   I hope this bit of information benefits somebody else. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to