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); } }