wood burning stoves 2.0*
The moose likes Servlets and the fly likes Form Based Authentication fails with unicode characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Form Based Authentication fails with unicode characters" Watch "Form Based Authentication fails with unicode characters" New topic
Author

Form Based Authentication fails with unicode characters

David Squire
Greenhorn

Joined: Sep 23, 2009
Posts: 5
I have set up form based authentication in my application using Tomcat 6 and MySQL 5.0. It works just fine when using English user names and passwords. But, if I use Korean, Japanese, or other Unicode characters, then the login fails.

How can I get form based authentication to work with Unicode?

Thank you!
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

What is the underlying encoding of the database ? Are you able to query the usernames correctly ?

When the information is passed to j_security_check, is it passed correctly or do the characters get garbled ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
David Squire
Greenhorn

Joined: Sep 23, 2009
Posts: 5
Thank you very much for your reply!

The database uses UTF-8. And yes, I can query the user name string out correctly.

I have no idea how to check to see if the information is being passed to j_security_check correctly or not. Yesterday I tried to create a filter that would check that for me, but I found that you cannot use filters to see j_security_check requests.

How would I check the j_username and j_password parameters?

Thank you,

Dave
David Squire
Greenhorn

Joined: Sep 23, 2009
Posts: 5
I now have it working. 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:


2. I also added the following tag to the context.xml file. It explicitly tells Tomcat's FormAuthenticator to use utf-8 encoding:


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
 
 
subject: Form Based Authentication fails with unicode characters