Results 1 to 4 of 4

Thread: j_spring_security_check problem with UTF8 symbols

  1. #1
    Join Date
    Dec 2009
    Posts
    2

    Default j_spring_security_check problem with UTF8 symbols

    Hello!
    I have users with Russian characters in usernames in my database. Names are stored in UTF-8 encoding.
    I have simple login form
    HTML Code:
    <%@page contentType="text/html;charset=UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Login page</title>
    </head>
    <body>
    	    <form name="f" action="j_spring_security_check" method="POST">
          <table>
            <tr><td>Логин:</td><td><input type='text' name='j_username' value='qweqwe'/></td></tr>
            <tr><td>Пароль:</td><td><input type='password' name='j_password'></td></tr>
            <tr><td><input type="checkbox" name="_spring_security_remember_me"></td><td>Don't ask for my password for two weeks</td></tr>
    
            <tr><td colspan='2'><input name="submit" type="submit"></td></tr>
            <tr><td colspan='2'><input name="reset" type="reset"></td></tr>
          </table>
    
        </form>
    </body>
    </html>
    But when I try to login using Russian username I get
    Code:
    22:38:27,272  WARN LoggerListener:60 - Authentication event AuthenticationFailureBadCredentialsEvent: ?а?????????░???╗; details: org.springframework.s
    ecurity.ui.WebAuthenticationDetails@166c8: RemoteIpAddress: 95.132.70.176; SessionId: 5C3842B23ACE43BFC0581D646287021E; exception: Bad credentials
    When I use programmatic login
    Code:
    AuthenticationManager manager = (AuthenticationManager) appContext.getBean("_authenticationManager");
    manager.authenticate(usernamePasswordAuthenticationToken);
    everithing is fine. The same user is able to log in.

    So what should I do to enable utf-8 support in j_spring_security_check ?

  2. #2

    Default

    I don't know the answer to your question, but I'm sure it would be helpful for you to list your current security context config file...

  3. #3
    Join Date
    Oct 2008
    Location
    Poland, Wrocław
    Posts
    429

    Default

    Hi

    Make sure, that the very first filter in your web.xml (even before Spring-Security filter) is org.springframework.web.filter.CharacterEncodingFi lter with UTF-8 set as "encoding" init-param.
    It will invoke:
    Code:
    request.setCharacterEncoding(this.encoding);
    before any "request.getParameter()".

    regards
    Grzegorz Grzybek

  4. #4
    Join Date
    Dec 2009
    Posts
    2

    Default

    Quote Originally Posted by Grzegorz Grzybek View Post
    Hi

    Make sure, that the very first filter in your web.xml (even before Spring-Security filter) is org.springframework.web.filter.CharacterEncodingFi lter with UTF-8 set as "encoding" init-param.
    It will invoke:
    Code:
    request.setCharacterEncoding(this.encoding);
    before any "request.getParameter()".

    regards
    Grzegorz Grzybek
    Thank you very much! I had CharacterEncodingFilter in web xml, but it was after SSFilterChain.

Tags for this Thread

Posting Permissions

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