Search in sources :

Example 1 with LdapPasswordManagementService

use of org.apereo.cas.pm.LdapPasswordManagementService in project cas by apereo.

the class LdapPasswordManagementConfiguration method passwordChangeService.

@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@Bean
public PasswordManagementService passwordChangeService(final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties, @Qualifier("passwordManagementCipherExecutor") final CipherExecutor passwordManagementCipherExecutor, @Qualifier("passwordHistoryService") final PasswordHistoryService passwordHistoryService) {
    return BeanSupplier.of(PasswordManagementService.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
        val connectionFactoryMap = new ConcurrentHashMap<String, ConnectionFactory>();
        val passwordManagerProperties = casProperties.getAuthn().getPm();
        passwordManagerProperties.getLdap().forEach(ldap -> connectionFactoryMap.put(ldap.getLdapUrl(), LdapUtils.newLdaptiveConnectionFactory(ldap)));
        return new LdapPasswordManagementService(passwordManagementCipherExecutor, casProperties.getServer().getPrefix(), passwordManagerProperties, passwordHistoryService, connectionFactoryMap);
    }).otherwise(() -> new NoOpPasswordManagementService(passwordManagementCipherExecutor, casProperties.getServer().getPrefix(), casProperties.getAuthn().getPm())).get();
}
Also used : lombok.val(lombok.val) NoOpPasswordManagementService(org.apereo.cas.pm.impl.NoOpPasswordManagementService) LdapPasswordManagementService(org.apereo.cas.pm.LdapPasswordManagementService) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Aggregations

ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 lombok.val (lombok.val)1 LdapPasswordManagementService (org.apereo.cas.pm.LdapPasswordManagementService)1 NoOpPasswordManagementService (org.apereo.cas.pm.impl.NoOpPasswordManagementService)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1