mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-21 11:32:17 +00:00
Add userDetailsMapper as a class member
Signed-off-by: dae won <eodnjs01477@gmail.com>
This commit is contained in:
parent
e8fe003c4c
commit
6ac3426e39
@ -30,6 +30,7 @@ import org.springframework.context.ApplicationContextException;
|
|||||||
import org.springframework.core.log.LogMessage;
|
import org.springframework.core.log.LogMessage;
|
||||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||||
import org.springframework.jdbc.core.PreparedStatementSetter;
|
import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
@ -156,6 +157,8 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
|||||||
|
|
||||||
private UserCache userCache = new NullUserCache();
|
private UserCache userCache = new NullUserCache();
|
||||||
|
|
||||||
|
private RowMapper<UserDetails> userDetailsMapper = this::mapToUser;
|
||||||
|
|
||||||
public JdbcUserDetailsManager() {
|
public JdbcUserDetailsManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +166,11 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
|||||||
setDataSource(dataSource);
|
setDataSource(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUserDetailsMapper(RowMapper<UserDetails> mapper) {
|
||||||
|
Assert.notNull(mapper, "userDetailsMapper cannot be null");
|
||||||
|
this.userDetailsMapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initDao() throws ApplicationContextException {
|
protected void initDao() throws ApplicationContextException {
|
||||||
if (this.authenticationManager == null) {
|
if (this.authenticationManager == null) {
|
||||||
@ -178,7 +186,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected List<UserDetails> loadUsersByUsername(String username) {
|
protected List<UserDetails> loadUsersByUsername(String username) {
|
||||||
return getJdbcTemplate().query(getUsersByUsernameQuery(), this::mapToUser, username);
|
return getJdbcTemplate().query(getUsersByUsernameQuery(), userDetailsMapper, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UserDetails mapToUser(ResultSet rs, int rowNum) throws SQLException {
|
protected UserDetails mapToUser(ResultSet rs, int rowNum) throws SQLException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user