@@ -0,0 +1,3102 @@
+package org.apereo.cas.authentication.surrogate;%0A%0Aimport com.sun.jndi.toolkit.dir.SearchFilter;%0Aimport org.apereo.cas.authentication.principal.Principal;%0Aimport org.apereo.cas.configuration.support.Beans;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.springframework.jdbc.core.BeanPropertyRowMapper;%0Aimport org.springframework.jdbc.core.JdbcTemplate;%0A%0Aimport javax.naming.directory.SearchResult;%0Aimport javax.persistence.NoResultException;%0Aimport javax.sql.DataSource;%0Aimport javax.xml.ws.Response;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0Aimport java.util.LinkedHashSet;%0Aimport java.util.List;%0Aimport java.util.stream.Collectors;%0A%0A/**%0A * This is %7B@link SurrogateJdbcAuthenticationService%7D.%0A *%0A * @author Misagh Moayyed%0A * @since 5.2.0%0A */%0Apublic class SurrogateJdbcAuthenticationService implements SurrogateAuthenticationService %7B%0A    private static final Logger LOGGER = LoggerFactory.getLogger(SurrogateJdbcAuthenticationService.class);%0A%0A    private final JdbcTemplate jdbcTemplate;%0A    private final String surrogateSearchQuery;%0A    private final String surrogateAccountQuery;%0A%0A    public SurrogateJdbcAuthenticationService(final String surrogateSearchQuery, final DataSource dataSource,%0A                                              final String surrogateAccountQuery) %7B%0A        this.surrogateSearchQuery = surrogateSearchQuery;%0A        this.jdbcTemplate = new JdbcTemplate(dataSource);%0A        this.surrogateAccountQuery = surrogateAccountQuery;%0A    %7D%0A%0A    @Override%0A    public boolean canAuthenticateAs(final String username, final Principal surrogate) %7B%0A        try %7B%0A            if (username.equalsIgnoreCase(surrogate.getId())) %7B%0A                return true;%0A            %7D%0A            LOGGER.debug(%22Executing SQL query %5B%7B%7D%5D%22, surrogateSearchQuery);%0A            final int count = this.jdbcTemplate.queryForObject(surrogateSearchQuery, Integer.class, username);%0A            return count %3E 0;%0A        %7D catch (final NoResultException e) %7B%0A            LOGGER.debug(e.getMessage());%0A        %7D catch (final Exception e) %7B%0A            LOGGER.error(e.getMessage(), e);%0A        %7D%0A        return false;%0A    %7D%0A%0A    @Override%0A    public Collection%3CString%3E getEligibleAccountsForSurrogateToProxy(final String username) %7B%0A        try %7B%0A            final List%3CSurrogateAccount%3E results = this.jdbcTemplate.query(this.surrogateAccountQuery,%0A                    new BeanPropertyRowMapper%3C%3E(SurrogateAccount.class));%0A            return results%0A                    .stream()%0A                    .map(SurrogateAccount::getSurrogateAccount)%0A                    .collect(Collectors.toSet());%0A%0A        %7D catch (final Exception e) %7B%0A            LOGGER.error(e.getMessage(), e);%0A        %7D%0A        return new ArrayList%3C%3E();%0A    %7D%0A%0A    public static class SurrogateAccount %7B%0A        private String surrogateAccount;%0A%0A        public String getSurrogateAccount() %7B%0A            return surrogateAccount;%0A        %7D%0A%0A        public void setSurrogateAccount(final String surrogateAccount) %7B%0A            this.surrogateAccount = surrogateAccount;%0A        %7D%0A    %7D%0A%7D%0A

add jdbc support for surrogate authn