Search in sources :

Example 1 with QueryDatabaseAuthenticationHandler

use of org.apereo.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler in project cas by apereo.

the class CasJdbcAuthenticationConfiguration method jdbcAuthenticationHandlers.

@ConditionalOnMissingBean(name = "jdbcAuthenticationHandlers")
@Bean
@RefreshScope
public Collection<AuthenticationHandler> jdbcAuthenticationHandlers() {
    final Collection<AuthenticationHandler> handlers = new HashSet<>();
    final JdbcAuthenticationProperties jdbc = casProperties.getAuthn().getJdbc();
    jdbc.getBind().forEach(b -> handlers.add(bindModeSearchDatabaseAuthenticationHandler(b)));
    jdbc.getEncode().forEach(b -> handlers.add(queryAndEncodeDatabaseAuthenticationHandler(b)));
    jdbc.getQuery().forEach(b -> handlers.add(queryDatabaseAuthenticationHandler(b)));
    jdbc.getSearch().forEach(b -> handlers.add(searchModeSearchDatabaseAuthenticationHandler(b)));
    return handlers;
}
Also used : BindModeSearchDatabaseAuthenticationHandler(org.apereo.cas.adaptors.jdbc.BindModeSearchDatabaseAuthenticationHandler) AuthenticationHandler(org.apereo.cas.authentication.AuthenticationHandler) QueryDatabaseAuthenticationHandler(org.apereo.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler) QueryAndEncodeDatabaseAuthenticationHandler(org.apereo.cas.adaptors.jdbc.QueryAndEncodeDatabaseAuthenticationHandler) SearchModeSearchDatabaseAuthenticationHandler(org.apereo.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler) JdbcAuthenticationProperties(org.apereo.cas.configuration.model.support.jdbc.JdbcAuthenticationProperties) HashSet(java.util.HashSet) 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 QueryDatabaseAuthenticationHandler

use of org.apereo.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler in project cas by apereo.

the class CasJdbcAuthenticationConfiguration method queryDatabaseAuthenticationHandler.

private AuthenticationHandler queryDatabaseAuthenticationHandler(final JdbcAuthenticationProperties.Query b) {
    final Map<String, String> attributes = Beans.transformPrincipalAttributesListIntoMap(b.getPrincipalAttributeList());
    LOGGER.debug("Created and mapped principal attributes [{}] for [{}]...", attributes, b.getUrl());
    final QueryDatabaseAuthenticationHandler h = new QueryDatabaseAuthenticationHandler(b.getName(), servicesManager, jdbcPrincipalFactory(), b.getOrder(), Beans.newHickariDataSource(b), b.getSql(), b.getFieldPassword(), b.getFieldExpired(), b.getFieldDisabled(), attributes);
    h.setPasswordEncoder(Beans.newPasswordEncoder(b.getPasswordEncoder()));
    h.setPrincipalNameTransformer(Beans.newPrincipalNameTransformer(b.getPrincipalTransformation()));
    if (queryPasswordPolicyConfiguration != null) {
        h.setPasswordPolicyConfiguration(queryPasswordPolicyConfiguration);
    }
    h.setPrincipalNameTransformer(Beans.newPrincipalNameTransformer(b.getPrincipalTransformation()));
    if (StringUtils.isNotBlank(b.getCredentialCriteria())) {
        final Predicate<String> predicate = Pattern.compile(b.getCredentialCriteria()).asPredicate();
        h.setCredentialSelectionPredicate(credential -> predicate.test(credential.getId()));
    }
    LOGGER.debug("Created authentication handler [{}] to handle database url at [{}]", h.getName(), b.getUrl());
    return h;
}
Also used : QueryDatabaseAuthenticationHandler(org.apereo.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler)

Aggregations

QueryDatabaseAuthenticationHandler (org.apereo.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler)2 HashSet (java.util.HashSet)1 BindModeSearchDatabaseAuthenticationHandler (org.apereo.cas.adaptors.jdbc.BindModeSearchDatabaseAuthenticationHandler)1 QueryAndEncodeDatabaseAuthenticationHandler (org.apereo.cas.adaptors.jdbc.QueryAndEncodeDatabaseAuthenticationHandler)1 SearchModeSearchDatabaseAuthenticationHandler (org.apereo.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler)1 AuthenticationHandler (org.apereo.cas.authentication.AuthenticationHandler)1 JdbcAuthenticationProperties (org.apereo.cas.configuration.model.support.jdbc.JdbcAuthenticationProperties)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