Search in sources :

Example 1 with QueryAndEncodeDatabaseAuthenticationHandler

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

the class CasJdbcAuthenticationConfiguration method queryAndEncodeDatabaseAuthenticationHandler.

private AuthenticationHandler queryAndEncodeDatabaseAuthenticationHandler(final QueryEncodeJdbcAuthenticationProperties b) {
    final QueryAndEncodeDatabaseAuthenticationHandler h = new QueryAndEncodeDatabaseAuthenticationHandler(b.getName(), servicesManager, jdbcPrincipalFactory(), b.getOrder(), JpaBeans.newDataSource(b), b.getAlgorithmName(), b.getSql(), b.getPasswordFieldName(), b.getSaltFieldName(), b.getExpiredFieldName(), b.getDisabledFieldName(), b.getNumberOfIterationsFieldName(), b.getNumberOfIterations(), b.getStaticSalt());
    h.setPasswordEncoder(PasswordEncoderUtils.newPasswordEncoder(b.getPasswordEncoder()));
    h.setPrincipalNameTransformer(PrincipalNameTransformerUtils.newPrincipalNameTransformer(b.getPrincipalTransformation()));
    if (queryAndEncodePasswordPolicyConfiguration != null) {
        h.setPasswordPolicyConfiguration(queryAndEncodePasswordPolicyConfiguration);
    }
    h.setPrincipalNameTransformer(PrincipalNameTransformerUtils.newPrincipalNameTransformer(b.getPrincipalTransformation()));
    if (StringUtils.isNotBlank(b.getCredentialCriteria())) {
        h.setCredentialSelectionPredicate(CoreAuthenticationUtils.newCredentialSelectionPredicate(b.getCredentialCriteria()));
    }
    LOGGER.debug("Created authentication handler [{}] to handle database url at [{}]", h.getName(), b.getUrl());
    return h;
}
Also used : QueryAndEncodeDatabaseAuthenticationHandler(org.apereo.cas.adaptors.jdbc.QueryAndEncodeDatabaseAuthenticationHandler)

Example 2 with QueryAndEncodeDatabaseAuthenticationHandler

use of org.apereo.cas.adaptors.jdbc.QueryAndEncodeDatabaseAuthenticationHandler 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) BindJdbcAuthenticationProperties(org.apereo.cas.configuration.model.support.jdbc.BindJdbcAuthenticationProperties) QueryEncodeJdbcAuthenticationProperties(org.apereo.cas.configuration.model.support.jdbc.QueryEncodeJdbcAuthenticationProperties) QueryJdbcAuthenticationProperties(org.apereo.cas.configuration.model.support.jdbc.QueryJdbcAuthenticationProperties) SearchJdbcAuthenticationProperties(org.apereo.cas.configuration.model.support.jdbc.SearchJdbcAuthenticationProperties) 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 3 with QueryAndEncodeDatabaseAuthenticationHandler

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

the class CasJdbcAuthenticationConfiguration method queryAndEncodeDatabaseAuthenticationHandler.

private static AuthenticationHandler queryAndEncodeDatabaseAuthenticationHandler(final QueryEncodeJdbcAuthenticationProperties b, final PasswordPolicyContext config, final ConfigurableApplicationContext applicationContext, final PrincipalFactory jdbcPrincipalFactory, final ServicesManager servicesManager) {
    val h = new QueryAndEncodeDatabaseAuthenticationHandler(b, servicesManager, jdbcPrincipalFactory, JpaBeans.newDataSource(b));
    configureJdbcAuthenticationHandler(h, config, b, applicationContext);
    return h;
}
Also used : lombok.val(lombok.val) QueryAndEncodeDatabaseAuthenticationHandler(org.apereo.cas.adaptors.jdbc.QueryAndEncodeDatabaseAuthenticationHandler)

Example 4 with QueryAndEncodeDatabaseAuthenticationHandler

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

the class CasJdbcAuthenticationConfiguration method queryAndEncodeDatabaseAuthenticationHandler.

private AuthenticationHandler queryAndEncodeDatabaseAuthenticationHandler(final JdbcAuthenticationProperties.Encode b) {
    final QueryAndEncodeDatabaseAuthenticationHandler h = new QueryAndEncodeDatabaseAuthenticationHandler(b.getName(), servicesManager, jdbcPrincipalFactory(), b.getOrder(), Beans.newHickariDataSource(b), b.getAlgorithmName(), b.getSql(), b.getPasswordFieldName(), b.getSaltFieldName(), b.getExpiredFieldName(), b.getDisabledFieldName(), b.getNumberOfIterationsFieldName(), b.getNumberOfIterations(), b.getStaticSalt());
    h.setPasswordEncoder(Beans.newPasswordEncoder(b.getPasswordEncoder()));
    h.setPrincipalNameTransformer(Beans.newPrincipalNameTransformer(b.getPrincipalTransformation()));
    if (queryAndEncodePasswordPolicyConfiguration != null) {
        h.setPasswordPolicyConfiguration(queryAndEncodePasswordPolicyConfiguration);
    }
    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 : QueryAndEncodeDatabaseAuthenticationHandler(org.apereo.cas.adaptors.jdbc.QueryAndEncodeDatabaseAuthenticationHandler)

Aggregations

QueryAndEncodeDatabaseAuthenticationHandler (org.apereo.cas.adaptors.jdbc.QueryAndEncodeDatabaseAuthenticationHandler)4 HashSet (java.util.HashSet)1 lombok.val (lombok.val)1 BindModeSearchDatabaseAuthenticationHandler (org.apereo.cas.adaptors.jdbc.BindModeSearchDatabaseAuthenticationHandler)1 QueryDatabaseAuthenticationHandler (org.apereo.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler)1 SearchModeSearchDatabaseAuthenticationHandler (org.apereo.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler)1 AuthenticationHandler (org.apereo.cas.authentication.AuthenticationHandler)1 BindJdbcAuthenticationProperties (org.apereo.cas.configuration.model.support.jdbc.BindJdbcAuthenticationProperties)1 JdbcAuthenticationProperties (org.apereo.cas.configuration.model.support.jdbc.JdbcAuthenticationProperties)1 QueryEncodeJdbcAuthenticationProperties (org.apereo.cas.configuration.model.support.jdbc.QueryEncodeJdbcAuthenticationProperties)1 QueryJdbcAuthenticationProperties (org.apereo.cas.configuration.model.support.jdbc.QueryJdbcAuthenticationProperties)1 SearchJdbcAuthenticationProperties (org.apereo.cas.configuration.model.support.jdbc.SearchJdbcAuthenticationProperties)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