Hi,
this is my code where I check if a user exists in the database. When I write a username correct and password wrong I get a page with an error description, as it is configured in spring-security.xml. But when there is no user in the database and an exception below is triggered I get an error page with a stack trace. How can I catch an exception, so it will display as it should (in a notice div on the login page).
Any help appreciated.PHP Code:@Service("userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService {
private static Log logger = LogFactory.getLog(UserDetailsServiceImpl.class);
@Autowired
private UserDetailsDao userDetailsDao;
@Override
@Transactional
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException {
if (logger.isDebugEnabled()) {
logger.debug("UserDetailsServiceImpl::getSystemUSer");
}
SystemUser systemUser = this.userDetailsDao.findByUsername(username);
if (systemUser != null) {
return systemUser;
}
throw new AccessDeniedException("Access denied.");
}
}


Reply With Quote