org.apereo.cas.jdbc.AbstractJdbcPersonAttributeDao Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cas-server-support-jdbc-authentication Show documentation
Show all versions of cas-server-support-jdbc-authentication Show documentation
cas-server-support-jdbc-authentication
The newest version!
package org.apereo.cas.jdbc;
import org.apereo.cas.authentication.attribute.AbstractQueryPersonAttributeDao;
import org.apereo.cas.authentication.attribute.CaseCanonicalizationMode;
import org.apereo.cas.authentication.principal.attribute.PersonAttributeDao;
import org.apereo.cas.authentication.principal.attribute.PersonAttributes;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import javax.sql.DataSource;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/**
* Provides common logic for executing a JDBC based query including building the WHERE clause SQL string.
*
* @author Eric Dalquist
* @since 7.1.0
*/
@Slf4j
public abstract class AbstractJdbcPersonAttributeDao extends AbstractQueryPersonAttributeDao {
private static final Pattern WHERE_PLACEHOLDER = Pattern.compile("\\{0\\}");
private final JdbcTemplate simpleJdbcTemplate;
private final String queryTemplate;
@Getter
@Setter
private QueryType queryType = QueryType.AND;
@Getter
@Setter
private Map caseInsensitiveDataAttributes;
protected AbstractJdbcPersonAttributeDao(final DataSource ds, final String queryTemplate) {
simpleJdbcTemplate = new JdbcTemplate(ds);
this.queryTemplate = queryTemplate;
}
/**
* Takes the {@link List} from the query and parses it into the {@link List} of {@link PersonAttributes} attributes to be returned.
*
* @param queryResults Results from the query.
* @param queryUserName The username passed in the query map, if no username attribute existed in the query Map null is provided.
* @return The results of the query
*/
protected abstract List parseAttributeMapFromResults(List queryResults, String queryUserName);
protected abstract RowMapper getRowMapper();
@Override
protected PartialWhereClause appendAttributeToQuery(final PartialWhereClause queryBuilder,
final String dataAttribute, final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy