Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form Based Authentication fails with unicode characters

 
David Squire
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
David Squire
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic