Results 1 to 4 of 4

Thread: setting the locale for the DaoAuthenticationProvider

  1. #1
    Join Date
    Jun 2005
    Posts
    13

    Default setting the locale for the DaoAuthenticationProvider

    I want the DaoAuthenticationProvider to provide localized exception messages when a user fails to login but the problem I have is spring's DispatcherServlet is not called until after the user is authenticated hence the LocaleContextHolder is not set. I know I can set the locale manually using the LocaleContextHolder but where do I get the Locale from when I dont have access to the http servlet request in the DaoAuthenticationProvider.

    Thanks for your help.

  2. #2
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    I looked at the source for AbstractUserDetailsAuthenticationProvider, which is the super class, and it looks to me like it's using org.acegisecurity.AcegiMessageSource for the messages.

  3. #3
    Join Date
    Jun 2005
    Posts
    13

    Default

    The problem isnt getting the messages from the message source but having the locale set correctly when messages are displayed for a failed login attempt.

    What i ended up doing is sublcassing AuthenticationProcessingFilter and setting the LocaleContextHolder locale in attemptAuthentication from the request. Im unsure if this is a good way of solving my problem but it works.

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

    Default

    Seems a reasonable approach, although maybe writing a dedicated Filter would be more extensible in that if messages need to be generated from other parts of the framework (eg if an authorization fails) the LocaleContextHolder will that way be correctly set.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

Posting Permissions

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