Smack 4.1.1 and OpenFire 3.10.2 SASLError Using Digest-MD5 Not Authorized

Hi guys,

I have managed to get this far - connection to XMPP server succeeded, but login produces the above error.

My dependencies includes compile ‘org.igniterealtime.smack:smack-sasl-provided:4.1.1’ as below

dependencies {

compile fileTree(include: [‘*.jar’], dir: ‘libs’)

compile ‘org.igniterealtime.smack:smack-android:4.1.1’
compile ‘org.igniterealtime.smack:smack-android-extensions:4.1.1’
compile ‘org.igniterealtime.smack:smack-core:4.1.1’
compile ‘org.igniterealtime.smack:smack-tcp:4.1.1’
compile ‘org.igniterealtime.smack:smack-extensions:4.1.1’
compile ‘org.igniterealtime.smack:smack-experimental:4.1.1’
compile ‘org.igniterealtime.smack:smack-resolver-minidns:4.1.1’
compile ‘org.igniterealtime.smack:smack-sasl-provided:4.1.1’
compile ‘org.igniterealtime.smack:smack-im:4.1.1’
compile ‘org.jxmpp:jxmpp-core:0.4.2-beta1’
compile ‘org.jxmpp:jxmpp-util-cache:0.4.2-beta1’
compile ‘de.measite.minidns:minidns:0.1.1’
compile ‘com.android.support:appcompat-v7:22.2.0’
}

My code includes

SASLMechanism mechanism = new SASLDigestMD5Mechanism();

SASLAuthentication.registerSASLMechanism(mechanism);

SASLAuthentication.blacklistSASLMechanism(“SCRAM-SHA-1”);

SASLAuthentication.unBlacklistSASLMechanism(“DIGEST-MD5”);

as below

class DoThread implements Callable {

final int XMPP_DEFAULT_PORT = 5222;

String strServer = “”;

String strUserId = “”;

String strPassword = “”;

String retStr = “”;

DoThread(String pServer, String pUserid, String pPassword) {

this.strServer = pServer;

this.strUserId=pUserid;

this.strPassword=pPassword;

}

public String call() {

//Context context = getApplicationContext();
//SmackAndroid.init(context);

XMPPTCPConnectionConfiguration.Builder connconfig = XMPPTCPConnectionConfiguration.builder(); //Crash here, because the rest of codes are commented out below
connconfig.setUsernameAndPassword(strUserId + “@” + strServer, strPassword);

connconfig.setServiceName(strServer);

connconfig.setHost(strServer);

connconfig.setPort(XMPP_DEFAULT_PORT);

connconfig.setDebuggerEnabled(true);

connconfig.setSecurityMode(XMPPTCPConnectionConfiguration.SecurityMode.disabled);

//connconfig.setCompressionEnabled(false);
//connconfig.setSocketFactory(SSLSocketFactory.getDefault()); // causes handshake to fail

SASLMechanism mechanism = new SASLDigestMD5Mechanism();

SASLAuthentication.registerSASLMechanism(mechanism);

SASLAuthentication.blacklistSASLMechanism(“SCRAM-SHA-1”);

SASLAuthentication.unBlacklistSASLMechanism(“DIGEST-MD5”);

XMPPTCPConnection connection = new XMPPTCPConnection(connconfig.build());

try {

retStr = "Starting. Attempting to connect. ";

connection.connect(); // Point #1
retStr = retStr + "Connection succeeded to " + connection.getHost() + ". Attempting to login. ";

connection.login(); // Point #2
retStr = retStr + "Logged in to " + connection.getHost() + ". Attempting to disconnect. ";

connection.disconnect(); // Point #3
retStr=retStr + “Disconnected.”;

} catch (org.jivesoftware.smack.SmackException | XMPPException | java.io.IOException e) {

e.printStackTrace();

retStr = retStr + e.getMessage();

}

return retStr;

}

}

Error trace as follows

07-19 17:57:44.279 19934-20025/com.flameaters.boombox.boomboxap D/SMACK﹕ SENT (0): <stream:stream xmlns=‘jabber:client’ to=‘23.254.131.168’ xmlns:stream=‘http://etherx.jabber.org/streams’ version=‘1.0’ from=‘maun@23.254.131.168@23.254.131.168’ xml:lang=‘en’>

07-19 17:57:44.522 19934-20026/com.flameaters.boombox.boomboxap D/SMACK﹕ RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client” from=“win-46p5toii7vs” id=“6560af78” xml:lang=“en” version=“1.0”>

07-19 17:57:44.811 19934-20026/com.flameaters.boombox.boomboxap D/SMACK﹕ RECV (0): stream:featuresDIGEST-MD5PLAINANONYMOUSCRAM-MD5</mech anism>zlib</stream:features>

07-19 17:57:44.827 19934-20025/com.flameaters.boombox.boomboxap D/SMACK﹕ SENT (0): =

07-19 17:57:45.058 19934-20026/com.flameaters.boombox.boomboxap D/SMACK﹕ RECV (0): cmVhbG09Indpbi00NnA1dG9paTd2cyIsbm9uY2 U9Ikt3S0VnWmVRcDByZEd1ald3cXZLRmIvMkplalg0ckRhelQ5SVRyM3ciLHFvcD0iYXV0aCIsY2hhcn NldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=

07-19 17:57:45.116 19934-20025/com.flameaters.boombox.boomboxap D/SMACK﹕ SENT (0): dXNlcm5hbWU9Im1hdW5AMjMuMjU0LjEzMS4xNj giLHJlYWxtPSIyMy4yNTQuMTMxLjE2OCIsbm9uY2U9Ikt3S0VnWmVRcDByZEd1ald3cXZLRmIvMkplal g0ckRhelQ5SVRyM3ciLGNub25jZT0iaTBoMk9oTXQ5cGdaWU5uNW9NVTMyWk91TW40SDVvNzIiLG5jPT AwMDAwMDAxLHFvcD1hdXRoLGRpZ2VzdC11cmk9InhtcHAvMjMuMjU0LjEzMS4xNjgiLHJlc3BvbnNlPT I1YTM2YjAwYTkxNDA2OTliNGZkNjMyMGQyZGY0OTM4LGNoYXJzZXQ9dXRmLTg=

07-19 17:57:45.344 19934-20026/com.flameaters.boombox.boomboxap D/SMACK﹕ RECV (0):

07-19 17:57:45.364 19934-20016/com.flameaters.boombox.boomboxap W/System.err﹕ org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: not-authorized

07-19 17:57:45.367 19934-20016/com.flameaters.boombox.boomboxap W/System.err﹕ at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthenticati on.java:365)

07-19 17:57:45.367 19934-20016/com.flameaters.boombox.boomboxap W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1033)

07-19 17:57:45.367 19934-20016/com.flameaters.boombox.boomboxap W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon nection.java:937)

07-19 17:57:45.367 19934-20016/com.flameaters.boombox.boomboxap W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:952)

07-19 17:57:45.368 19934-20016/com.flameaters.boombox.boomboxap W/System.err﹕ at java.lang.Thread.run(Thread.java:818)

07-19 17:57:45.400 19934-19934/com.flameaters.boombox.boomboxap I/Choreographer﹕ Skipped 154 frames! The application may be doing too much work on its main thread.

07-19 17:59:40.695 19934-19941/com.flameaters.boombox.boomboxap W/art﹕ Suspending all threads took: 10.533ms

07-19 18:00:45.682 19934-20026/com.flameaters.boombox.boomboxap D/SMACK﹕ RECV (0):

07-19 18:00:45.757 19934-19941/com.flameaters.boombox.boomboxap W/art﹕ Suspending all threads took: 7.462ms

07-19 18:00:45.907 19934-20025/com.flameaters.boombox.boomboxap D/SMACK﹕ SENT (0):

07-19 18:03:46.322 19934-20026/com.flameaters.boombox.boomboxap D/SMACK﹕ RECV (0):

07-19 18:03:46.350 19934-20025/com.flameaters.boombox.boomboxap D/SMACK﹕ SENT (0):

07-19 18:06:40.565 19934-19941/com.flameaters.boombox.boomboxap W/art﹕ Suspending all threads took: 10.234ms

07-19 18:06:46.816 19934-20026/com.flameaters.boombox.boomboxap D/SMACK﹕ RECV (0):

07-19 18:06:46.869 19934-20025/com.flameaters.boombox.boomboxap D/SMACK﹕ SENT (0):

Any help would much appreciated. Thank you in advance.

I met almost the same error: org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: not-authorized when I use smack 4.1.0/4.1.5 with openfire 3.10.3 version, but for smack 4.1.0/4.1.5 with openfire 3.9.3 which is ok.

and after I check the server config: I found on 3.10.3 openfire server colleague configured the xmpp.sasl property while on openfire 3.9.3 xmpp.sasl property’s not configured. I’m not sure if it’s the reason. if yes, then how can I connect and login successfully on 3.10.3 configured with xmpp.sasl ?

BTW, in my code, I add following before connect: which I thought it should work well even with openfire server configured with xmpp.sasl, but it seems not.

SASLMechanism mechanism = new SASLDigestMD5Mechanism();

SASLAuthentication.registerSASLMechanism(mechanism);

SASLAuthentication.blacklistSASLMechanism(“SCRAM-SHA-1”);

SASLAuthentication.unBlacklistSASLMechanism(“DIGEST-MD5”);