use of org.apereo.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao 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;
}
Aggregations