The goal is to configure Spring to use UserCache
interface for retrieving user details from cache.
Spring configures default
public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider
when we use standard security configuration. Nothing exceptional. By default the cache logic in the AbstractUserDetailsAuthenticationProvider
uses `NullUserCache' implementation.
Another implementation(wrapper?) for the interface provided is: org.springframework.security.core.userdetails.cache.EhCacheBasedUserCache
with setter setCache(Ehcache ehcache)
Questions:
A. How to configure this ehcache instance, do I need full blown cache manager for my scenario?
B. How to override Spring default bean(DaoAuthenticationProvider) ? Just declare my own with the same name and then set the cache on it or autowire and then set the cache on it?
With regards to point A, yes you need a
CacheManager
in order to get hold of anCache
instance with Ehcache.