Search in sources :

Example 1 with LdapAuthenticationProperties

use of org.apereo.cas.configuration.model.support.ldap.LdapAuthenticationProperties in project cas by apereo.

the class CasCoreConfigurationUtilsTests method verifyMappingCollections.

@Test
public void verifyMappingCollections() {
    val props = new CasConfigurationProperties();
    val ldap = new LdapAuthenticationProperties();
    ldap.setLdapUrl("http://localhost:1234");
    ldap.setBaseDn("ou=example");
    ldap.setBindDn("admin-user");
    ldap.setBindCredential("admin-psw");
    props.getAuthn().getLdap().add(ldap);
    val filters = new SimpleFilterProvider().setFailOnUnknownId(false).addFilter(CasConfigurationProperties.class.getSimpleName(), SimpleBeanPropertyFilter.filterOutAllExcept("authn")).addFilter(AuthenticationProperties.class.getSimpleName(), SimpleBeanPropertyFilter.filterOutAllExcept("ldap"));
    val map = CasCoreConfigurationUtils.asMap(props.withHolder(), filters);
    assertTrue(map.keySet().stream().allMatch(key -> key.startsWith("cas.authn.ldap")));
}
Also used : lombok.val(lombok.val) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RefreshAutoConfiguration(org.springframework.cloud.autoconfigure.RefreshAutoConfiguration) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) lombok.val(lombok.val) Assertions(org.junit.jupiter.api.Assertions) Autowired(org.springframework.beans.factory.annotation.Autowired) AuthenticationProperties(org.apereo.cas.configuration.model.core.authentication.AuthenticationProperties) SimpleBeanPropertyFilter(com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter) Tag(org.junit.jupiter.api.Tag) LdapAuthenticationProperties(org.apereo.cas.configuration.model.support.ldap.LdapAuthenticationProperties) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) LdapAuthenticationProperties(org.apereo.cas.configuration.model.support.ldap.LdapAuthenticationProperties) AuthenticationProperties(org.apereo.cas.configuration.model.core.authentication.AuthenticationProperties) LdapAuthenticationProperties(org.apereo.cas.configuration.model.support.ldap.LdapAuthenticationProperties) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with LdapAuthenticationProperties

use of org.apereo.cas.configuration.model.support.ldap.LdapAuthenticationProperties in project cas by apereo.

the class CasDiscoveryProfileConfiguration method availableAttributes.

@Bean
public Set<String> availableAttributes() {
    final LinkedHashSet<String> attributes = new LinkedHashSet<>(0);
    attributes.addAll(attributeRepository.getPossibleUserAttributeNames());
    final List<LdapAuthenticationProperties> ldapProps = casProperties.getAuthn().getLdap();
    if (ldapProps != null) {
        ldapProps.stream().forEach(ldap -> {
            attributes.addAll(transformAttributes(ldap.getPrincipalAttributeList()));
            attributes.addAll(transformAttributes(ldap.getAdditionalAttributes()));
        });
    }
    final JdbcAuthenticationProperties jdbcProps = casProperties.getAuthn().getJdbc();
    if (jdbcProps != null) {
        jdbcProps.getQuery().stream().forEach(jdbc -> attributes.addAll(transformAttributes(jdbc.getPrincipalAttributeList())));
    }
    return attributes;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) LdapAuthenticationProperties(org.apereo.cas.configuration.model.support.ldap.LdapAuthenticationProperties) JdbcAuthenticationProperties(org.apereo.cas.configuration.model.support.jdbc.JdbcAuthenticationProperties) Bean(org.springframework.context.annotation.Bean)

Aggregations

LdapAuthenticationProperties (org.apereo.cas.configuration.model.support.ldap.LdapAuthenticationProperties)2 SimpleBeanPropertyFilter (com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter)1 SimpleFilterProvider (com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)1 LinkedHashSet (java.util.LinkedHashSet)1 lombok.val (lombok.val)1 AuthenticationProperties (org.apereo.cas.configuration.model.core.authentication.AuthenticationProperties)1 JdbcAuthenticationProperties (org.apereo.cas.configuration.model.support.jdbc.JdbcAuthenticationProperties)1 Assertions (org.junit.jupiter.api.Assertions)1 Tag (org.junit.jupiter.api.Tag)1 Test (org.junit.jupiter.api.Test)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 RefreshAutoConfiguration (org.springframework.cloud.autoconfigure.RefreshAutoConfiguration)1 Bean (org.springframework.context.annotation.Bean)1