protected void handleAuthenticationExceptions(AuthenticationException e) {
    if (e instanceof BadCredentialsException || e instanceof UsernameNotFoundException)
      throw SecurityServiceException.newInvalidCredentialsException(e.getMessage());

    throw SecurityServiceException.newAuthenticationFailedException(e.getMessage());
  }