use of org.apereo.services.persondir.support.CachingPersonAttributeDaoImpl in project cas by apereo.
the class CasPersonDirectoryConfiguration method cachingAttributeRepository.
@Bean
@ConditionalOnMissingBean(name = "cachingAttributeRepository")
public IPersonAttributeDao cachingAttributeRepository() {
final CachingPersonAttributeDaoImpl impl = new CachingPersonAttributeDaoImpl();
impl.setCacheNullResults(false);
final PrincipalAttributesProperties props = casProperties.getAuthn().getAttributeRepository();
final Cache graphs = Caffeine.newBuilder().maximumSize(props.getMaximumCacheSize()).expireAfterWrite(props.getExpirationTime(), TimeUnit.valueOf(props.getExpirationTimeUnit().toUpperCase())).build();
impl.setUserInfoCache(graphs.asMap());
impl.setCachedPersonAttributesDao(aggregatingAttributeRepository());
LOGGER.debug("Configured cache expiration policy for merging attribute sources to be [{}] minute(s)", props.getExpirationTime());
return impl;
}
use of org.apereo.services.persondir.support.CachingPersonAttributeDaoImpl in project cas by apereo.
the class CasPersonDirectoryConfiguration method composeMergedAndCachedAttributeRepositories.
private IPersonAttributeDao composeMergedAndCachedAttributeRepositories(final List<IPersonAttributeDao> list) {
final MergingPersonAttributeDaoImpl mergingDao = new MergingPersonAttributeDaoImpl();
final String merger = StringUtils.defaultIfBlank(casProperties.getAuthn().getAttributeRepository().getMerger(), "replace".trim());
LOGGER.debug("Configured merging strategy for attribute sources is [{}]", merger);
switch(merger.toLowerCase()) {
case "merge":
mergingDao.setMerger(new MultivaluedAttributeMerger());
break;
case "add":
mergingDao.setMerger(new NoncollidingAttributeAdder());
break;
case "replace":
default:
mergingDao.setMerger(new ReplacingAttributeAdder());
break;
}
final CachingPersonAttributeDaoImpl impl = new CachingPersonAttributeDaoImpl();
impl.setCacheNullResults(false);
final Cache graphs = CacheBuilder.newBuilder().concurrencyLevel(2).weakKeys().maximumSize(casProperties.getAuthn().getAttributeRepository().getMaximumCacheSize()).expireAfterWrite(casProperties.getAuthn().getAttributeRepository().getExpireInMinutes(), TimeUnit.MINUTES).build();
impl.setUserInfoCache(graphs.asMap());
mergingDao.setPersonAttributeDaos(list);
impl.setCachedPersonAttributesDao(mergingDao);
if (list.isEmpty()) {
LOGGER.debug("No attribute repository sources are available/defined to merge together.");
} else {
LOGGER.debug("Configured attribute repository sources to merge together: [{}]", list);
LOGGER.debug("Configured cache expiration policy for merging attribute sources to be [{}] minute(s)", casProperties.getAuthn().getAttributeRepository().getExpireInMinutes());
}
return impl;
}
use of org.apereo.services.persondir.support.CachingPersonAttributeDaoImpl in project uPortal by Jasig.
the class PersonDirectoryConfiguration method getCachingPersonAttributeDao.
/**
* Defines the order that the data providing DAOs are called, results are cached by the outer
* caching DAO.
*/
@Bean(name = "cachingPersonAttributeDao")
@Qualifier("uPortalInternal")
public IPersonAttributeDao getCachingPersonAttributeDao() {
final CachingPersonAttributeDaoImpl rslt = new CachingPersonAttributeDaoImpl();
rslt.setUsernameAttributeProvider(getUsernameAttributeProvider());
rslt.setCacheNullResults(true);
rslt.setCacheKeyGenerator(getUserAttributeCacheKeyGenerator());
rslt.setUserInfoCache(new MapCacheProvider<>(userInfoCache));
rslt.setCachedPersonAttributesDao(getMergingPersonAttributeDao());
return rslt;
}
Aggregations