Search in sources :

Example 1 with CasSSLContext

use of org.apereo.cas.authentication.CasSSLContext 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();
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) BeanCondition(org.apereo.cas.util.spring.beans.BeanCondition) PasswordEncoderUtils(org.apereo.cas.authentication.support.password.PasswordEncoderUtils) RedisPersonAttributeDao(org.apereo.cas.redis.RedisPersonAttributeDao) PersonDirectoryAttributeRepositoryPlanConfigurer(org.apereo.cas.persondir.PersonDirectoryAttributeRepositoryPlanConfigurer) StringUtils(org.apache.commons.lang3.StringUtils) IPersonAttributeDao(org.apereo.services.persondir.IPersonAttributeDao) BeanSupplier(org.apereo.cas.util.spring.beans.BeanSupplier) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) FunctionUtils(org.apereo.cas.util.function.FunctionUtils) AuthenticationHandler(org.apereo.cas.authentication.AuthenticationHandler) PrincipalFactory(org.apereo.cas.authentication.principal.PrincipalFactory) BeanContainer(org.apereo.cas.util.spring.beans.BeanContainer) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) CasRedisTemplate(org.apereo.cas.redis.core.CasRedisTemplate) ServicesManager(org.apereo.cas.services.ServicesManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) PrincipalFactoryUtils(org.apereo.cas.authentication.principal.PrincipalFactoryUtils) PrincipalResolver(org.apereo.cas.authentication.principal.PrincipalResolver) RedisAuthenticationHandler(org.apereo.cas.redis.RedisAuthenticationHandler) lombok.val(lombok.val) ScopedProxyMode(org.springframework.context.annotation.ScopedProxyMode) ConditionalOnFeature(org.apereo.cas.util.spring.boot.ConditionalOnFeature) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) RedisObjectFactory(org.apereo.cas.redis.core.RedisObjectFactory) Collectors(java.util.stream.Collectors) Configuration(org.springframework.context.annotation.Configuration) CasFeatureModule(org.apereo.cas.configuration.support.CasFeatureModule) CasSSLContext(org.apereo.cas.authentication.CasSSLContext) PrincipalNameTransformerUtils(org.apereo.cas.authentication.principal.PrincipalNameTransformerUtils) Bean(org.springframework.context.annotation.Bean) AuthenticationEventExecutionPlanConfigurer(org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer) RedisPersonAttributeDao(org.apereo.cas.redis.RedisPersonAttributeDao) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Collectors (java.util.stream.Collectors)1 lombok.val (lombok.val)1 StringUtils (org.apache.commons.lang3.StringUtils)1 AuthenticationEventExecutionPlanConfigurer (org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer)1 AuthenticationHandler (org.apereo.cas.authentication.AuthenticationHandler)1 CasSSLContext (org.apereo.cas.authentication.CasSSLContext)1 PrincipalFactory (org.apereo.cas.authentication.principal.PrincipalFactory)1 PrincipalFactoryUtils (org.apereo.cas.authentication.principal.PrincipalFactoryUtils)1 PrincipalNameTransformerUtils (org.apereo.cas.authentication.principal.PrincipalNameTransformerUtils)1 PrincipalResolver (org.apereo.cas.authentication.principal.PrincipalResolver)1 PasswordEncoderUtils (org.apereo.cas.authentication.support.password.PasswordEncoderUtils)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 CasFeatureModule (org.apereo.cas.configuration.support.CasFeatureModule)1 PersonDirectoryAttributeRepositoryPlanConfigurer (org.apereo.cas.persondir.PersonDirectoryAttributeRepositoryPlanConfigurer)1 RedisAuthenticationHandler (org.apereo.cas.redis.RedisAuthenticationHandler)1 RedisPersonAttributeDao (org.apereo.cas.redis.RedisPersonAttributeDao)1 CasRedisTemplate (org.apereo.cas.redis.core.CasRedisTemplate)1 RedisObjectFactory (org.apereo.cas.redis.core.RedisObjectFactory)1 ServicesManager (org.apereo.cas.services.ServicesManager)1 FunctionUtils (org.apereo.cas.util.function.FunctionUtils)1