How to handle non-ASCII Username

Yaowen Tu yaowen.tu at gmail.com
Tue Nov 26 00:11:02 EST 2013


Hi,

I am using Username Password login handler. But if the username contain
non-ASCII characters it will fail. Somehow the encoding messed up the
string.

What I have done is in login.jsp, add the following line:
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
That means my response is UTF-8 encoded, and also tells browser to encode
in UTF-8 when posting request to server.

But in Shibboleth IdP side, when it retrieves the parameter in
UsernamePasswordLoginServlet.java, it doesn't set the correct encoding
using:
request.setCharacterEncoding("UTF-8");

It just call request.getParameter(..), which will decode in default
"ISO-885901-1".

Then when my JAAS module gets the username it is already messed up. I have
to manually convert the string to UTF-8 manually like:
String correctUsername =  new String(username.getBytes("iso-8859-1"),
"UTF-8");

Changing the UsernamePasswordLoginServlet.java source code is not what I
want to do either.

Is there any better way to resolve this?

Thanks,
Yaowen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/users/attachments/20131125/109104da/attachment.html 


More information about the users mailing list