Search in sources :

Example 1 with RedisAuthenticationHandler

use of org.apereo.cas.redis.RedisAuthenticationHandler in project cas by apereo.

the class RedisAuthenticationConfiguration method redisAuthenticationHandler.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "redisAuthenticationHandler")
public AuthenticationHandler redisAuthenticationHandler(final CasConfigurationProperties casProperties, final ConfigurableApplicationContext applicationContext, @Qualifier("redisPrincipalFactory") final PrincipalFactory redisPrincipalFactory, @Qualifier("authenticationRedisTemplate") final CasRedisTemplate authenticationRedisTemplate, @Qualifier(ServicesManager.BEAN_NAME) final ServicesManager servicesManager) {
    return BeanSupplier.of(AuthenticationHandler.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
        val redis = casProperties.getAuthn().getRedis();
        val handler = new RedisAuthenticationHandler(redis.getName(), servicesManager, redisPrincipalFactory, redis.getOrder(), authenticationRedisTemplate);
        handler.setPrincipalNameTransformer(PrincipalNameTransformerUtils.newPrincipalNameTransformer(redis.getPrincipalTransformation()));
        handler.setPasswordEncoder(PasswordEncoderUtils.newPasswordEncoder(redis.getPasswordEncoder(), applicationContext));
        return handler;
    }).otherwiseProxy().get();
}
Also used : lombok.val(lombok.val) RedisAuthenticationHandler(org.apereo.cas.redis.RedisAuthenticationHandler) 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

lombok.val (lombok.val)1 RedisAuthenticationHandler (org.apereo.cas.redis.RedisAuthenticationHandler)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1