Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CacheManager properties have been set- Apache Shiro

How can I set cacheManager properties, while using Apache shiro. On debugging , I am getting INFO like,

80104 [1045903843@qtp-967078155-3] INFO org.apache.shiro.realm.AuthorizingRealm - No cache or cacheManager properties have been set.  Authorization cache cannot be obtained.

I am using JSF2 and Google Cloud SQL.

like image 791
lofa in Avatar asked Jan 06 '12 07:01

lofa in


2 Answers

If using Shiro's INI config, you set the SecurityManager's cacheManager property like any other bean property. For example:

[main]

cacheManager = com.something.impl.SomeCacheManager
# config cacheManager as necessary, e.g.
# cacheManager.foo = bar

securityManager.cacheManager = $cacheManager

You can use the out-of-the-box EhCacheManager or implement the CacheManager and Cache interfaces yourself to use a custom cache backing store (e.g. Memcache, Coherence, GigaSpaces, any modern NoSQL Key/Value store, etc...)

like image 125
Les Hazlewood Avatar answered Sep 30 '22 01:09

Les Hazlewood


It seems like EhCacheManager is not part of shiro-core 1.2.1 (in the Maven package anyway). I solved the problem by adding the following to my [main] section in shiro.ini:

[main]
builtInCacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $builtInCacheManager
like image 22
Allan Lykke Christensen Avatar answered Sep 30 '22 01:09

Allan Lykke Christensen