title: Throwing Custom Exception and Display Error Message from Custom AuthenticationProvider
body: <p>This is a follow up to <a href="https://stackoverflow.com/questions/6412591/hooking-into-pre-authentication-with-spring-security-core">this question</a>.</p>
  
  <p>I have a custom AuthenticationProvider that extends AbstractUserDetailsAuthenticationProvider.  In the additionalAuthenticationChecks I am doing some custom auth work and part of this process is to display some messages to the user on the login screen.  Currently, for testing, I created a UserNotActivatedException:</p>
  
  <pre><code>class UserNotActivatedException extends AuthenticationException {
  
    public UserNotActivatedException(String message, Throwable t) {
      super(message, t)
    }
  
    public UserNotActivatedException(String message) {
      super(message)
    }
  
    public UserNotActivatedException(String message, Object extraInformation) {
      super(message, extraInformation)
    }
  
  }
  </code></pre>
  
  <p>And in the additionalAuthenticationChecks I am just immediately throwing it for testing.  Now, I need to know what I need to do to get my own fail message to show up on the login screen.  In the spring-security-core default config, we can override the following:</p>
  
  <pre><code>errors.login.disabled = "Sorry, your account is disabled."
  errors.login.expired = "Sorry, your account has expired."
  errors.login.passwordExpired = "Sorry, your password has expired."
  errors.login.locked = "Sorry, your account is locked."
  errors.login.fail = "Sorry, we were not able to find a user with that username and password."
  </code></pre>
  
  <p>But I don't see how I can add my own additional messages.</p>