Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Form Based Authentication fails with unicode characters

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic