[jboss-user] [Security] - Basic Authentication and unicode credentials
aleksandarradulovic
do-not-reply at jboss.com
Tue Sep 1 14:06:50 EDT 2009
Couple of weeks ago, while working on my current project, I configured my application, deployed on JBOSSAS 4.2.3, to use DatabaseServerLoginModule for the purpose of authenticating WebService clients using BasicAuthentication and it went fine.
However, problem occurred when I was requested to enable users to login using Cyrillic letters.
I found no better solution but to make my custom login module, extended from DatabaseServerLoginModule, that does simple string conversion in order to have things done.
Follows the code:
public class DBLoginModule extends DatabaseServerLoginModule{
| public static final String isoEncoding = "ISO-8859-1";
| public static final String utfEncoding = "utf-8";
|
| protected String getUsername() {
| String username = super.getUsername();
|
| try {
| username = transform(username);
| } catch (UnsupportedEncodingException e) {
| e.printStackTrace();
| }
|
| return username;
| }
|
| protected boolean validatePassword(String inputPassword, String expectedPassword) {
| try {
| inputPassword = transform(inputPassword);
| } catch (UnsupportedEncodingException e) {
| e.printStackTrace();
| }
|
| return super.validatePassword(inputPassword, expectedPassword);
| }
|
| public static String transform(String string) throws UnsupportedEncodingException {
| return new String(string.getBytes(isoEncoding),utfEncoding);
| }
| }
Still, I wonder if this is the only solution I was able to apply... And if is, it seems to me quite cumbersome to do things like this - that support should be built in into the server...
And it took me a lot of time to realize what was going on behind the scene, and documentation, including existing posts regarding this or similar problems were quite difficult for me to understand and realize what the problem was.
I would really like to hear your opinion about this and I am looking forward to it!
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4252911#4252911
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4252911
More information about the jboss-user
mailing list