* @return Returns the User object or null in case of an Exception.
*/
public User authenticate(String loginName, String password) {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
loginName, password);
AuthenticationManager am = (AuthenticationManager) applicationContext.getBean("authenticationManager");
try {
Authentication authentication = am.authenticate(token);
return (User) authentication.getPrincipal();
} catch (AuthenticationException ae) {
logger.debug("acegi authentication failed: " + ae);
return null;
}