Login exception SASL authentication failed using mechanism DIGEST-MD5 asmack in android

只谈情不闲聊 提交于 2019-12-04 10:16:45

In the Openfire configuration it is machinename.domain.com

This SASL mechanism uses also the Xmpp Domain name for authentication, not only username and password. This is why authentication fails.

mean your username & password must be like:

username: abc111@domain.com (whatever your domain name)

password: abcabc111

for more detail check this conversation.

Ajay

I am using below code in my, its working fine in here..

try {   
    ConnectionConfiguration connConfig = new ConnectionConfiguration("HOST_IP", Integer.parseInt("PORT_NO"));
    XMPPConnection connection = new XMPPConnection(connConfig);
    connection.connect();

    try {
        // Login

        connection.login("USER_NAME", "PASSWORD");

        // Set the status to available

        Presence presence = new Presence(Presence.Type.available);
        connection.sendPacket(presence);
        xmppClient.setConnection(connection);
    } catch (XMPPException ex) {
        Log.w("XMPPClient", "[SettingsDialog] Failed to log in as " + username);
        Log.w("XMPPClient", ex.toString());
        xmppClient.setConnection(null);
    }
} catch (XMPPException ex) {
    Log.w("XMPPClient", "[SettingsDialog] Failed to connect to " + connection.getHost());
    Log.w("XMPPClient", ex.toString());
    xmppClient.setConnection(null);
}

And I have also added smack.jar file.

Please check below post, i think it might help you..

https://stackoverflow.com/a/6659403/1849482

And many users are getting this error in login. check below links for More Information..

http://community.igniterealtime.org/thread/44219

http://code.google.com/p/asmack/issues/detail?id=33

asmack uses Novell's Open LDAP DigestMD5SaslClient.java which does not support the escape of backslash ('\') and double-quote ('"') for SASL. According to XEP-0106, user name "user@company.com" should be encoded as "user\040company.com". Fully complying with SASL spec, it should be encoded as "user\\040company.com", but asmack didn't. If your XMPP server (e.g. Openfire) uses Java's SASL implementation, it will have a mismatch. Smack 3.x uses Java's SASL implementation, so it works fine. Smack 4.x is supposed to replace asmack, but I don't know if Smack 4.x uses Novell or Java SASL implementation.

BTW, this problem exists in iOS xmppframework as well.

If you are interested in my fix, I'll post it somewhere.

Here is the link to the revised DigestMD5SaslClient.java with the escape quoted string.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!