public ServerSideUser loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException {
log.debug("here");
if (username == null) {
throw new UsernameNotFoundException("Username null not found");
}
List<User> users = getHibernateTemplate().findByNamedParam(
"from User where username = :name", "name",
username.toLowerCase());
log.debug("Found " + users.size() + " users for username "
+ username);
if (users.size() != 1) {
if (users.size() != 0) {
throw new UsernameNotFoundException(
"Duplicate Username Problem: " + username);
} else {
// if OpenID
// consider returning a ROLE 'TRANSIENT_OpenID' user...
throw new UsernameNotFoundException(
"Username not found: " + username);
}
} else {
log.debug("load user success " + users.get(0));
User u = users.get(0);