Results 1 to 3 of 3

Thread: Using I18n in the login page

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Location
    Brazil
    Posts
    21

    Default Using I18n in the login page

    Hi folks,

    I would like to show messages personalized with UsernameNotFoundException in my login page 8)
    <%
    ((AuthenticationException) session.getAttribute(AbstractProcessingFilter.ACEG I_SECURITY_LAST_EXCEPTION_KEY)).getMessage()
    %>
    but, all exception that is throwed in AuthenticationDao.loadUserByUsername
    public UserDetails loadUserByUsername(String username)
    throws UsernameNotFoundException, DataAccessException;
    it is catched in DaoAuthenticationProvider.getUserFromBackend and substituted by BadCredentialsException
    private UserDetails getUserFromBackend(String username) {
    try {
    return this.authenticationDao.loadUserByUsername(username );
    } catch (UsernameNotFoundException notFound) {
    throw new BadCredentialsException("Bad credentials presented");
    } catch (DataAccessException repositoryProblem) {
    throw new AuthenticationServiceException(repositoryProblem
    .getMessage(), repositoryProblem);
    }
    }
    How I can show my proper messages?
    Eduardo Valentim

    \"The best way to learn is to teach\"

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    In CVS HEAD DaoAuthenticationProvider version 1.24 was updated last week:


    Code:
        private UserDetails getUserFromBackend&#40;String username&#41; &#123;
            try &#123;
                return this.authenticationDao.loadUserByUsername&#40;username&#41;;
            &#125; catch &#40;UsernameNotFoundException notFound&#41; &#123;
                if &#40;hideUserNotFoundExceptions&#41; &#123;
                    throw new BadCredentialsException&#40;"Bad credentials presented"&#41;;
                &#125; else &#123;
                    throw notFound;
                &#125;
            &#125; catch &#40;DataAccessException repositoryProblem&#41; &#123;
                throw new AuthenticationServiceException&#40;repositoryProblem
                    .getMessage&#40;&#41;, repositoryProblem&#41;;
            &#125;
        &#125;
    So your different exception is no longer "swallowed" if you set the hideUserNotFoundExceptions to false (it defaults to true).

  3. #3
    Join Date
    Aug 2004
    Location
    Brazil
    Posts
    21

    Default Great solution

    Hello Ben,

    Great solution :!:

    Best Regards,
    Eduardo Valentim

    \"The best way to learn is to teach\"

Similar Threads

  1. Pageable data list with Hibernate
    By robmorgan in forum Data
    Replies: 23
    Last Post: Jul 24th, 2006, 06:12 PM
  2. Replies: 3
    Last Post: Oct 31st, 2005, 03:23 AM
  3. Replies: 0
    Last Post: Aug 30th, 2005, 08:01 AM
  4. propogate request params through login page?
    By dlevine in forum Security
    Replies: 4
    Last Post: Jun 21st, 2005, 12:15 PM
  5. Replies: 1
    Last Post: Mar 22nd, 2005, 07:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •