Uploaded image for project: 'Shiro'
  1. Shiro
  2. SHIRO-336

Documentation related to EHCache setup needs to be clearer

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0.0
    • Fix Version/s: None
    • Component/s: Caching , Documentation
    • Labels:
    • Environment:
      documentation

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jeff3p Jeff Parker
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified