Hmmmm, that is indeed a pain. It would be much nicer if the default query simply returned true for those parameters. You could then choose to return them if you want to. I think it would make sense to raise a JIRA issue for this. It is pain! Short term, as you are exending JdbcDaoImpl anyway simply create your own UsersByUsernameMapping. In the mapRow method, set the required values.
Code:
protected void initMappingSqlQueries() {
this.usersByUsernameMapping = new ExtendedUsersByUsernameMapping(getDataSource());
this.authoritiesByUsernameMapping = new AuthoritiesByUsernameMapping(getDataSource());
}
/**
* Query object to look up a user.
*/
protected class ExtendedUsersByUsernameMapping extends MappingSqlQuery {
protected UsersByUsernameMapping(DataSource ds) {
super(ds, usersByUsernameQuery);
declareParameter(new SqlParameter(Types.VARCHAR));
compile();
}
protected Object mapRow(ResultSet rs, int rownum)
throws SQLException {
String username = rs.getString(1);
String password = rs.getString(2);
boolean enabled = rs.getBoolean(3);
boolean accountNonExpired= rs.getBoolean(4);
boolean credentialsNonExpired= rs.getBoolean(5);
boolean accountNonLocked= rs.getBoolean(6);
UserDetails user = new User(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked,
new GrantedAuthority[] {new GrantedAuthorityImpl("HOLDER")});
return user;
}
}