AnsweredAssumed Answered

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

Question asked by Flameater Flameater on Jul 19, 2015
Latest reply on Dec 24, 2015 by johnwang

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:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>DIGEST-MD5</mechanism><mech anism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>CRAM-MD5</mech anism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth"/><register xmlns="http://jabber.org/features/iq-register"/></stream:features>

07-19 17:57:44.827  19934-20025/com.flameaters.boombox.boomboxap D/SMACK﹕ SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'>=</auth>

07-19 17:57:45.058  19934-20026/com.flameaters.boombox.boomboxap D/SMACK﹕ RECV (0): <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09Indpbi00NnA1dG9paTd2cyIsbm9uY2 U9Ikt3S0VnWmVRcDByZEd1ald3cXZLRmIvMkplalg0ckRhelQ5SVRyM3ciLHFvcD0iYXV0aCIsY2hhcn NldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>

07-19 17:57:45.116  19934-20025/com.flameaters.boombox.boomboxap D/SMACK﹕ SENT (0): <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>dXNlcm5hbWU9Im1hdW5AMjMuMjU0LjEzMS4xNj giLHJlYWxtPSIyMy4yNTQuMTMxLjE2OCIsbm9uY2U9Ikt3S0VnWmVRcDByZEd1ald3cXZLRmIvMkplal g0ckRhelQ5SVRyM3ciLGNub25jZT0iaTBoMk9oTXQ5cGdaWU5uNW9NVTMyWk91TW40SDVvNzIiLG5jPT AwMDAwMDAxLHFvcD1hdXRoLGRpZ2VzdC11cmk9InhtcHAvMjMuMjU0LjEzMS4xNjgiLHJlc3BvbnNlPT I1YTM2YjAwYTkxNDA2OTliNGZkNjMyMGQyZGY0OTM4LGNoYXJzZXQ9dXRmLTg=</response>

07-19 17:57:45.344  19934-20026/com.flameaters.boombox.boomboxap D/SMACK﹕ RECV (0): <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>

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): <iq type="get" id="20-17" from="win-46p5toii7vs" to="win-46p5toii7vs/6560af78"><ping xmlns="urn:xmpp:ping"/></iq>

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): <iq to='win-46p5toii7vs' id='20-17' type='result'></iq>

07-19 18:03:46.322  19934-20026/com.flameaters.boombox.boomboxap D/SMACK﹕ RECV (0): <iq type="get" id="597-18" from="win-46p5toii7vs" to="win-46p5toii7vs/6560af78"><ping xmlns="urn:xmpp:ping"/></iq>

07-19 18:03:46.350  19934-20025/com.flameaters.boombox.boomboxap D/SMACK﹕ SENT (0): <iq to='win-46p5toii7vs' id='597-18' type='result'></iq>

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): <iq type="get" id="442-19" from="win-46p5toii7vs" to="win-46p5toii7vs/6560af78"><ping xmlns="urn:xmpp:ping"/></iq>

07-19 18:06:46.869  19934-20025/com.flameaters.boombox.boomboxap D/SMACK﹕ SENT (0): <iq to='win-46p5toii7vs' id='442-19' type='result'></iq>

 

Any help would much appreciated. Thank you in advance.

Outcomes