use of org.apereo.services.persondir.support.MergingPersonAttributeDaoImpl in project cas by apereo.
the class ChainingPrincipalResolver method getAttributeRepository.
@Override
public IPersonAttributeDao getAttributeRepository() {
final MergingPersonAttributeDaoImpl dao = new MergingPersonAttributeDaoImpl();
dao.setPersonAttributeDaos(this.chain.stream().map(PrincipalResolver::getAttributeRepository).collect(Collectors.toList()));
return dao;
}
use of org.apereo.services.persondir.support.MergingPersonAttributeDaoImpl 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;
}
Aggregations