/*配置文件内容:
#设置jdbc认证
cas.authn.jdbc.query[0].url=jdbc:mysql://127.0.0.1:3306/springdemo?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8
cas.authn.jdbc.query[0].user=root
cas.authn.jdbc.query[0].password=****
cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver
cas.authn.jdbc.query[0].sql=select * from user where name=?
cas.authn.jdbc.query[0].fieldPassword=password
*其中fieldPassword是指数据库中用户表的密码字段
*
*/
public class QueryDatabaseAuthenticationHandler extends AbstractJdbcUsernamePasswordAuthenticationHandler {//这个是cas默认的jdbc验证方式 private final String sql;//这个是获取配置文件中的sql命令 private final String fieldPassword; private final String fieldExpired; private final String fieldDisabled; private final Map<String, Object> principalAttributeMap; public QueryDatabaseAuthenticationHandler(final String name, final ServicesManager servicesManager, final PrincipalFactory principalFactory, final Integer order, final DataSource dataSource, final String sql, final String fieldPassword, final String fieldExpired, final String fieldDisabled, final Map<String, Object> attributes) { super(name, servicesManager, principalFactory, order, dataSource); this.sql = sql; this.fieldPassword = fieldPassword; this.fieldExpired = fieldExpired; this.fieldDisabled = fieldDisabled; this.principalAttributeMap = attributes; if (StringUtils.isBlank(this.fieldPassword)) { LOGGER.warn("When the password field is left undefined, CAS will skip comparing database and user passwords for equality " + ", (specially if the query results do not contain the password field)," + "and will instead only rely on a successful query execution with returned results in order to verify credentials"); } }
如何修改cas 的jdbc验证方式,做更多自定义的操作?