Announcement Announcement Module
Collapse
No announcement yet.
j_spring_security_check problem with UTF8 symbols Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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...

    Comment


    • #3
      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

      Comment


      • #4
        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.

        Comment

        Working...
        X