Search code examples
javaxmppmd5openfiresmack

Smack login with md5 hashed password to Openfire


How can I login with MD5 hashed password to openfire?

I'm using smack 4.0.4.

I've tried DIGEST-MD5 registiration but it's not work

SASLAuthentication.registerSASLMechanism("DIGEST-MD5", SASLDigestMD5Mechanism.class); 
SASLAuthentication.supportSASLMechanism("DIGEST-MD5");

I'm getting this error :

SASLError using PLAIN: not-authorized

My code looks like this:

config = new ConnectionConfiguration(xmppServerAddress, Integer.parseInt(xmppServerPort));
config.setDebuggerEnabled(true);
config.setReconnectionAllowed(true);    
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
XMPPTCPConnection connectionTmp = new XMPPTCPConnection(config);
connectionTmp.connect();

connectionTmp.login("username","md5hashedpassword");

Solution

  • I have a similar problem, you could check if your password is in md5.

    I have generate a passwords from the userid (long type) as:

    @Override
        public String generatePassword(long userId) {
            String userIdString = String.valueOf(userId);
            return MD5util.getMD5(userIdString + StringUtil.getStringAlternateCharacters(userIdString));
        }
    

    or find out that your xmpp server (openfire) IP is correctly configured as you wish to login.