Search in sources :

Example 1 with NoOpPasswordManagementService

use of org.apereo.cas.pm.impl.NoOpPasswordManagementService in project cas by apereo.

the class PasswordManagementConfiguration method passwordChangeService.

@ConditionalOnMissingBean(name = "passwordChangeService")
@RefreshScope
@Bean
public PasswordManagementService passwordChangeService() {
    final PasswordManagementProperties pm = casProperties.getAuthn().getPm();
    if (pm.isEnabled()) {
        final Resource location = pm.getJson().getLocation();
        if (location != null) {
            LOGGER.debug("Configuring password management based on JSON resource [{}]", location);
            return new JsonResourcePasswordManagementService(passwordManagementCipherExecutor(), casProperties.getServer().getPrefix(), casProperties.getAuthn().getPm(), location);
        }
        LOGGER.warn("No storage service (LDAP, Database, etc) is configured to handle the account update and password service operations. " + "Password management functionality will have no effect and will be disabled until a storage service is configured. " + "To explicitly disable the password management functionality, add 'cas.authn.pm.enabled=false' to the CAS configuration");
    } else {
        LOGGER.debug("Password management is disabled. To enable the password management functionality, " + "add 'cas.authn.pm.enabled=true' to the CAS configuration and then configure storage options for account updates");
    }
    return new NoOpPasswordManagementService(passwordManagementCipherExecutor(), casProperties.getServer().getPrefix(), casProperties.getAuthn().getPm());
}
Also used : PasswordManagementProperties(org.apereo.cas.configuration.model.support.pm.PasswordManagementProperties) NoOpPasswordManagementService(org.apereo.cas.pm.impl.NoOpPasswordManagementService) Resource(org.springframework.core.io.Resource) JsonResourcePasswordManagementService(org.apereo.cas.pm.impl.JsonResourcePasswordManagementService) 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)

Example 2 with NoOpPasswordManagementService

use of org.apereo.cas.pm.impl.NoOpPasswordManagementService 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

NoOpPasswordManagementService (org.apereo.cas.pm.impl.NoOpPasswordManagementService)2 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)2 Bean (org.springframework.context.annotation.Bean)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 lombok.val (lombok.val)1 PasswordManagementProperties (org.apereo.cas.configuration.model.support.pm.PasswordManagementProperties)1 LdapPasswordManagementService (org.apereo.cas.pm.LdapPasswordManagementService)1 JsonResourcePasswordManagementService (org.apereo.cas.pm.impl.JsonResourcePasswordManagementService)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Resource (org.springframework.core.io.Resource)1