code: @Override
  	public Authentication doLogin(Authentication authentication) {
  		Authentication result = null;
  
  		try {
  			result = getAuthenticationManager().authenticate(authentication);
  		} catch (AuthenticationException e) {
  			logger.info("authentication failed: " + e.getMessage());
  
  			// Fire application event to advise of failed login
  			getApplicationConfig().applicationContext().publishEvent(new AuthenticationFailedEvent(
                      authentication, e));
  
  			// rethrow the exception
  			throw e;
  		}
  
  		// Handle success or failure of the authentication attempt
  		if (logger.isDebugEnabled()) {
  			logger.debug("successful login - update context holder and fire event");
  		}
  
  		// Commit the successful Authentication object to the secure
  		// ContextHolder
  		SecurityContextHolder.getContext().setAuthentication(result);
  		setAuthentication(result);
  
  		// Fire application events to advise of new login
  		getApplicationConfig().applicationContext().publishEvent(new AuthenticationEvent(result));
  		getApplicationConfig().applicationContext().publishEvent(new LoginEvent(result));
  
  		return result;
  	}
docs: Process a login attempt and fire all related events. If the
  authentication fails, then a {@link AuthenticationFailedEvent} is
  published and the exception is rethrown. If the authentication succeeds,
  then an {@link AuthenticationEvent} is published, followed by a
  {@link LoginEvent}.
  
  @param authentication
  token to use for the login attempt
  @return Authentication token resulting from a successful call to
  {@link AuthenticationManager#authenticate(org.springframework.security.core.Authentication)}
  .
  @see ApplicationSecurityManager#doLogin(org.springframework.security.core.Authentication)
  @throws AuthenticationException
  If the authentication attempt fails