|
@@ -110,7 +110,8 @@ import org.springframework.util.Assert;
|
|
|
* @author colin sampaleanu
|
|
|
* @author Luke Taylor
|
|
|
*/
|
|
|
-public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, MessageSourceAware {
|
|
|
+public class JdbcDaoImpl extends JdbcDaoSupport
|
|
|
+ implements UserDetailsService, MessageSourceAware {
|
|
|
// ~ Static fields/initializers
|
|
|
// =====================================================================================
|
|
|
|
|
@@ -126,8 +127,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
|
|
// ~ Instance fields
|
|
|
// ================================================================================================
|
|
|
|
|
|
- protected final MessageSourceAccessor messages = SpringSecurityMessageSource
|
|
|
- .getAccessor();
|
|
|
+ protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
|
|
|
|
|
|
private String authoritiesByUsernameQuery;
|
|
|
private String groupAuthoritiesByUsernameQuery;
|
|
@@ -149,6 +149,13 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
|
|
// ~ Methods
|
|
|
// ========================================================================================================
|
|
|
|
|
|
+ /**
|
|
|
+ * @return the messages
|
|
|
+ */
|
|
|
+ protected MessageSourceAccessor getMessages() {
|
|
|
+ return this.messages;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Allows subclasses to add their own granted authorities to the list to be returned
|
|
|
* in the <tt>UserDetails</tt>.
|
|
@@ -171,6 +178,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
|
|
"Use of either authorities or groups must be enabled");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public UserDetails loadUserByUsername(String username)
|
|
|
throws UsernameNotFoundException {
|
|
|
List<UserDetails> users = loadUsersByUsername(username);
|
|
@@ -218,6 +226,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
|
|
protected List<UserDetails> loadUsersByUsername(String username) {
|
|
|
return getJdbcTemplate().query(this.usersByUsernameQuery,
|
|
|
new String[] { username }, new RowMapper<UserDetails>() {
|
|
|
+ @Override
|
|
|
public UserDetails mapRow(ResultSet rs, int rowNum)
|
|
|
throws SQLException {
|
|
|
String username = rs.getString(1);
|
|
@@ -238,6 +247,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
|
|
protected List<GrantedAuthority> loadUserAuthorities(String username) {
|
|
|
return getJdbcTemplate().query(this.authoritiesByUsernameQuery,
|
|
|
new String[] { username }, new RowMapper<GrantedAuthority>() {
|
|
|
+ @Override
|
|
|
public GrantedAuthority mapRow(ResultSet rs, int rowNum)
|
|
|
throws SQLException {
|
|
|
String roleName = JdbcDaoImpl.this.rolePrefix + rs.getString(2);
|
|
@@ -256,6 +266,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
|
|
protected List<GrantedAuthority> loadGroupAuthorities(String username) {
|
|
|
return getJdbcTemplate().query(this.groupAuthoritiesByUsernameQuery,
|
|
|
new String[] { username }, new RowMapper<GrantedAuthority>() {
|
|
|
+ @Override
|
|
|
public GrantedAuthority mapRow(ResultSet rs, int rowNum)
|
|
|
throws SQLException {
|
|
|
String roleName = getRolePrefix() + rs.getString(3);
|
|
@@ -395,8 +406,10 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
|
|
public void setEnableGroups(boolean enableGroups) {
|
|
|
this.enableGroups = enableGroups;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
public void setMessageSource(MessageSource messageSource) {
|
|
|
+ Assert.notNull(messageSource, "messageSource cannot be null");
|
|
|
this.messages = new MessageSourceAccessor(messageSource);
|
|
|
}
|
|
|
}
|