Results 1 to 2 of 2
  1. #1
    davesquire is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Question Form Based Authentication fails with unicode characters

    I have implemented form based authentication using Tomcat 6 and MySQL 5.0. It works just fine for user names and passwords that use English characters. But, if I try to use Korean, Japanese, or other Unicode characters, then the login always fails.

    How can I make form based authentication work for Unicode?

    Thank you!

  2. #2
    davesquire is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Default I figured it out. Finally.

    I made two changes in my configuration files. I'm not entirely sure which one fixed it or if they are both necessary. But just for your information, here are the two changes.

    1. Since I am using MySQL as the user database, the Realm's connection URL to the database needed to have the encoding information. Here is what I now have in my context.xml file:
    Java Code:
        <Realm connectionName="myConnectionName" connectionPassword="***"
            connectionURL="jdbc:mysql://127.0.0.1:3306/MyDatabase?useUnicode=true&characterEncoding=UTF-8" driverName="com.mysql.jdbc.Driver"
            roleNameCol="Role" userCredCol="Password" userNameCol="UserName" userRoleTable="Users"
            userTable="Users" className="org.apache.catalina.realm.JDBCRealm" digest="SHA" digestEncoding="utf-8" />

    2. I also added the following tag to the context.xml file. It explicitly tells Tomcat's FormAuthenticator to use utf-8 encoding:
    Java Code:
        <Valve className="org.apache.catalina.authenticator.FormAuthenticator" characterEncoding="utf-8" />

    And as a final note, I made these changes and restarted my Tomcat, but it still did not work until I came back to work the next day. (And, yes, I did indeed spend several hours searching for answers. I found nothing and went home frustrated.) Therefore, if it is not working for you, you may want to reboot the computer just to make sure...

    I hope that this post will help someone.

    Dave

Similar Threads

  1. OCR System for Recognise Characters in an Application Form
    By LankanSniper in forum Advanced Java
    Replies: 6
    Last Post: 02-18-2010, 01:28 PM
  2. Form based authentication
    By Mrs. Deswal in forum Networking
    Replies: 1
    Last Post: 07-01-2009, 09:05 AM
  3. Form Based Authentication
    By archmisha in forum Java Servlet
    Replies: 1
    Last Post: 02-06-2009, 11:27 AM
  4. writing and reading unicode characters from a file
    By ranoosh in forum Advanced Java
    Replies: 4
    Last Post: 09-28-2008, 05:34 AM
  5. Replies: 0
    Last Post: 04-04-2008, 10:36 AM

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
  •