use of org.apereo.services.persondir.IPersonAttributeDao in project cas by apereo.
the class CasPersonDirectoryConfiguration method ldapAttributeRepositories.
@ConditionalOnMissingBean(name = "ldapAttributeRepositories")
@Bean
@RefreshScope
public List<IPersonAttributeDao> ldapAttributeRepositories() {
final List<IPersonAttributeDao> list = new ArrayList<>();
final PrincipalAttributesProperties attrs = casProperties.getAuthn().getAttributeRepository();
attrs.getLdap().forEach(ldap -> {
if (StringUtils.isNotBlank(ldap.getBaseDn()) && StringUtils.isNotBlank(ldap.getLdapUrl())) {
final LdaptivePersonAttributeDao ldapDao = new LdaptivePersonAttributeDao();
LOGGER.debug("Configured LDAP attribute source for [{}] and baseDn [{}]", ldap.getLdapUrl(), ldap.getBaseDn());
ldapDao.setConnectionFactory(Beans.newLdaptivePooledConnectionFactory(ldap));
ldapDao.setBaseDN(ldap.getBaseDn());
LOGGER.debug("LDAP attributes are fetched from [{}] via filter [{}]", ldap.getLdapUrl(), ldap.getUserFilter());
ldapDao.setSearchFilter(ldap.getUserFilter());
final SearchControls constraints = new SearchControls();
if (ldap.getAttributes() != null && !ldap.getAttributes().isEmpty()) {
LOGGER.debug("Configured result attribute mapping for [{}] to be [{}]", ldap.getLdapUrl(), ldap.getAttributes());
ldapDao.setResultAttributeMapping(ldap.getAttributes());
final String[] attributes = ldap.getAttributes().keySet().toArray(new String[ldap.getAttributes().keySet().size()]);
constraints.setReturningAttributes(attributes);
} else {
LOGGER.debug("Retrieving all attributes as no explicit attribute mappings are defined for [{}]", ldap.getLdapUrl());
constraints.setReturningAttributes(null);
}
if (ldap.isSubtreeSearch()) {
LOGGER.debug("Configured subtree searching for [{}]", ldap.getLdapUrl());
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
}
constraints.setDerefLinkFlag(true);
ldapDao.setSearchControls(constraints);
ldapDao.setOrder(ldap.getOrder());
LOGGER.debug("Initializing LDAP attribute source for [{}]", ldap.getLdapUrl());
ldapDao.initialize();
list.add(ldapDao);
}
});
return list;
}
use of org.apereo.services.persondir.IPersonAttributeDao in project cas by apereo.
the class CasPersonDirectoryConfiguration method groovyAttributeRepositories.
@ConditionalOnMissingBean(name = "groovyAttributeRepositories")
@Bean
@RefreshScope
public List<IPersonAttributeDao> groovyAttributeRepositories() {
final List<IPersonAttributeDao> list = new ArrayList<>();
casProperties.getAuthn().getAttributeRepository().getGroovy().forEach(groovy -> {
if (groovy.getConfig().getLocation() != null) {
final GroovyPersonAttributeDao dao = new GroovyPersonAttributeDao(new InternalGroovyScriptDao(applicationContext, casProperties));
dao.setCaseInsensitiveUsername(groovy.isCaseInsensitive());
dao.setOrder(groovy.getOrder());
LOGGER.debug("Configured Groovy attribute sources from [{}]", groovy.getConfig().getLocation());
list.add(dao);
}
});
return list;
}
use of org.apereo.services.persondir.IPersonAttributeDao in project cas by apereo.
the class CasPersonDirectoryConfiguration method jsonAttributeRepositories.
@ConditionalOnMissingBean(name = "jsonAttributeRepositories")
@Bean
@RefreshScope
public List<IPersonAttributeDao> jsonAttributeRepositories() {
final List<IPersonAttributeDao> list = new ArrayList<>();
casProperties.getAuthn().getAttributeRepository().getJson().forEach(json -> {
final Resource r = json.getConfig().getLocation();
if (r != null) {
final JsonBackedComplexStubPersonAttributeDao dao = new JsonBackedComplexStubPersonAttributeDao(r);
dao.setOrder(json.getOrder());
LOGGER.debug("Configured JSON attribute sources from [[{}]]", r);
list.add(dao);
}
});
return list;
}
use of org.apereo.services.persondir.IPersonAttributeDao in project cas by apereo.
the class CasPersonDirectoryConfiguration method jdbcAttributeRepositories.
@ConditionalOnMissingBean(name = "jdbcAttributeRepositories")
@Bean
@RefreshScope
public List<IPersonAttributeDao> jdbcAttributeRepositories() {
final List<IPersonAttributeDao> list = new ArrayList<>();
final PrincipalAttributesProperties attrs = casProperties.getAuthn().getAttributeRepository();
attrs.getJdbc().forEach(jdbc -> {
if (StringUtils.isNotBlank(jdbc.getSql()) && StringUtils.isNotBlank(jdbc.getUrl())) {
final AbstractJdbcPersonAttributeDao jdbcDao;
if (jdbc.isSingleRow()) {
LOGGER.debug("Configured single-row JDBC attribute repository for [{}]", jdbc.getUrl());
jdbcDao = new SingleRowJdbcPersonAttributeDao(Beans.newHickariDataSource(jdbc), jdbc.getSql());
} else {
LOGGER.debug("Configured multi-row JDBC attribute repository for [{}]", jdbc.getUrl());
jdbcDao = new MultiRowJdbcPersonAttributeDao(Beans.newHickariDataSource(jdbc), jdbc.getSql());
LOGGER.debug("Configured multi-row JDBC column mappings for [{}] are [{}]", jdbc.getUrl(), jdbc.getColumnMappings());
((MultiRowJdbcPersonAttributeDao) jdbcDao).setNameValueColumnMappings(jdbc.getColumnMappings());
}
jdbcDao.setQueryAttributeMapping(Collections.singletonMap("username", jdbc.getUsername()));
final Map<String, String> mapping = jdbc.getAttributes();
if (mapping != null && !mapping.isEmpty()) {
LOGGER.debug("Configured result attribute mapping for [{}] to be [{}]", jdbc.getUrl(), jdbc.getAttributes());
jdbcDao.setResultAttributeMapping(mapping);
}
jdbcDao.setRequireAllQueryAttributes(jdbc.isRequireAllAttributes());
jdbcDao.setUsernameCaseCanonicalizationMode(jdbc.getCaseCanonicalization());
jdbcDao.setDefaultCaseCanonicalizationMode(jdbc.getCaseCanonicalization());
jdbcDao.setQueryType(jdbc.getQueryType());
jdbcDao.setOrder(jdbc.getOrder());
list.add(jdbcDao);
}
});
return list;
}
use of org.apereo.services.persondir.IPersonAttributeDao in project cas by apereo.
the class CasPersonDirectoryConfiguration method grouperAttributeRepositories.
@ConditionalOnMissingBean(name = "grouperAttributeRepositories")
@Bean
@RefreshScope
public List<IPersonAttributeDao> grouperAttributeRepositories() {
final List<IPersonAttributeDao> list = new ArrayList<>();
final PrincipalAttributesProperties.Grouper gp = casProperties.getAuthn().getAttributeRepository().getGrouper();
if (gp.isEnabled()) {
final GrouperPersonAttributeDao dao = new GrouperPersonAttributeDao();
dao.setOrder(gp.getOrder());
LOGGER.debug("Configured Grouper attribute source");
list.add(dao);
}
return list;
}
Aggregations