3030import org .springframework .core .log .LogMessage ;
3131import org .springframework .dao .IncorrectResultSizeDataAccessException ;
3232import org .springframework .jdbc .core .PreparedStatementSetter ;
33+ import org .springframework .jdbc .core .RowMapper ;
3334import org .springframework .security .access .AccessDeniedException ;
3435import org .springframework .security .authentication .AuthenticationManager ;
3536import org .springframework .security .authentication .UsernamePasswordAuthenticationToken ;
@@ -156,13 +157,20 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
156157
157158 private UserCache userCache = new NullUserCache ();
158159
160+ private RowMapper <UserDetails > userDetailsMapper = this ::mapToUser ;
161+
159162 public JdbcUserDetailsManager () {
160163 }
161164
162165 public JdbcUserDetailsManager (DataSource dataSource ) {
163166 setDataSource (dataSource );
164167 }
165168
169+ public void setUserDetailsMapper (RowMapper <UserDetails > mapper ) {
170+ Assert .notNull (mapper , "userDetailsMapper cannot be null" );
171+ this .userDetailsMapper = mapper ;
172+ }
173+
166174 @ Override
167175 protected void initDao () throws ApplicationContextException {
168176 if (this .authenticationManager == null ) {
@@ -178,7 +186,7 @@ protected void initDao() throws ApplicationContextException {
178186 */
179187 @ Override
180188 protected List <UserDetails > loadUsersByUsername (String username ) {
181- return getJdbcTemplate ().query (getUsersByUsernameQuery (), this :: mapToUser , username );
189+ return getJdbcTemplate ().query (getUsersByUsernameQuery (), userDetailsMapper , username );
182190 }
183191
184192 protected UserDetails mapToUser (ResultSet rs , int rowNum ) throws SQLException {
0 commit comments