use of org.apereo.cas.redis.RedisPersonAttributeDao in project cas by apereo.
the class RedisAuthenticationConfiguration method redisPersonAttributeDaos.
@ConditionalOnMissingBean(name = "redisPersonAttributeDaos")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public BeanContainer<IPersonAttributeDao> redisPersonAttributeDaos(final ConfigurableApplicationContext applicationContext, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext, final CasConfigurationProperties casProperties) {
return BeanSupplier.of(BeanContainer.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
val redis = casProperties.getAuthn().getAttributeRepository().getRedis();
return BeanContainer.of(redis.stream().filter(r -> StringUtils.isNotBlank(r.getHost())).map(r -> {
val conn = RedisObjectFactory.newRedisConnectionFactory(r, true, casSslContext);
val template = RedisObjectFactory.newRedisTemplate(conn);
template.initialize();
val cb = new RedisPersonAttributeDao(template);
cb.setOrder(r.getOrder());
FunctionUtils.doIfNotNull(r.getId(), cb::setId);
return cb;
}).collect(Collectors.toList()));
}).otherwise(BeanContainer::empty).get();
}
Aggregations