30
30
import org .springframework .core .log .LogMessage ;
31
31
import org .springframework .dao .IncorrectResultSizeDataAccessException ;
32
32
import org .springframework .jdbc .core .PreparedStatementSetter ;
33
+ import org .springframework .jdbc .core .RowMapper ;
33
34
import org .springframework .security .access .AccessDeniedException ;
34
35
import org .springframework .security .authentication .AuthenticationManager ;
35
36
import org .springframework .security .authentication .UsernamePasswordAuthenticationToken ;
@@ -156,13 +157,20 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
156
157
157
158
private UserCache userCache = new NullUserCache ();
158
159
160
+ private RowMapper <UserDetails > userDetailsMapper = this ::mapToUser ;
161
+
159
162
public JdbcUserDetailsManager () {
160
163
}
161
164
162
165
public JdbcUserDetailsManager (DataSource dataSource ) {
163
166
setDataSource (dataSource );
164
167
}
165
168
169
+ public void setUserDetailsMapper (RowMapper <UserDetails > mapper ) {
170
+ Assert .notNull (mapper , "userDetailsMapper cannot be null" );
171
+ this .userDetailsMapper = mapper ;
172
+ }
173
+
166
174
@ Override
167
175
protected void initDao () throws ApplicationContextException {
168
176
if (this .authenticationManager == null ) {
@@ -178,7 +186,7 @@ protected void initDao() throws ApplicationContextException {
178
186
*/
179
187
@ Override
180
188
protected List <UserDetails > loadUsersByUsername (String username ) {
181
- return getJdbcTemplate ().query (getUsersByUsernameQuery (), this :: mapToUser , username );
189
+ return getJdbcTemplate ().query (getUsersByUsernameQuery (), userDetailsMapper , username );
182
190
}
183
191
184
192
protected UserDetails mapToUser (ResultSet rs , int rowNum ) throws SQLException {
0 commit comments