Search in sources :

Example 1 with CouchProfileService

use of org.pac4j.couch.profile.service.CouchProfileService in project cas by apereo.

the class CouchDbAuthenticationConfiguration method couchDbAuthenticatorProfileService.

@ConditionalOnMissingBean(name = "couchDbAuthenticatorProfileService")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public CouchProfileService couchDbAuthenticatorProfileService(@Qualifier("authenticationCouchDbFactory") final CouchDbConnectorFactory authenticationCouchDbFactory, final CasConfigurationProperties casProperties, final ConfigurableApplicationContext applicationContext) {
    val couchDb = casProperties.getAuthn().getCouchDb();
    LOGGER.info("Connected to CouchDb instance @ [{}] using database [{}]", couchDb.getUrl(), couchDb.getDbName());
    val encoder = new SpringSecurityPasswordEncoder(PasswordEncoderUtils.newPasswordEncoder(couchDb.getPasswordEncoder(), applicationContext));
    val auth = new CouchProfileService(authenticationCouchDbFactory.getCouchDbConnector(), couchDb.getAttributes());
    auth.setUsernameAttribute(couchDb.getUsernameAttribute());
    auth.setPasswordAttribute(couchDb.getPasswordAttribute());
    auth.setPasswordEncoder(encoder);
    return auth;
}
Also used : lombok.val(lombok.val) SpringSecurityPasswordEncoder(org.pac4j.core.credentials.password.SpringSecurityPasswordEncoder) CouchProfileService(org.pac4j.couch.profile.service.CouchProfileService) 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 SpringSecurityPasswordEncoder (org.pac4j.core.credentials.password.SpringSecurityPasswordEncoder)1 CouchProfileService (org.pac4j.couch.profile.service.CouchProfileService)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