AnsweredAssumed Answered

Smack 4.1.1 login failed, SASLError using DIGEST-MD5: not-authorized

Question asked by Alex on Jun 21, 2015

I am new to openfire/smack. Trying to use openfire as a push server for an android project.

 

So far, installed openfire 3.10.1 to Centos Linux successfully(tested with spark). Keep most of configuration default.

 

Using Smack 4.1.1, I was able to connect to server but failed at login, I attached my code and failure log as below.

Is it complicated to setup XMPP between Android client and openfire? Can someone point me to useful document of security and authentication setting?

 

Thanks in advance.

 

 

public void connect(){

  AsyncTask<Void, Void, Boolean> connectionThread = new AsyncTask<Void, Void, Boolean>(){

  @Override

  protected Boolean doInBackground(Void... arg0){

 

                XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();

                configBuilder.setUsernameAndPassword("atest", "123");

                configBuilder.setHost("ivypolis.com");

                //configBuilder.setPort(5222);

                configBuilder.setDebuggerEnabled(true);

                configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

                //configBuilder.setSecurityMode(XMPPTCPConnectionConfiguration.SecurityMode.req uired );

                //SASLMechanism mechanism = new SASLDigestMD5Mechanism();

                SASLMechanism mechanism = new SASLPlainMechanism();

                SASLAuthentication.registerSASLMechanism(mechanism);

                //SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");

                //SASLAuthentication.unBlacklistSASLMechanism("DIGEST-MD5");

                configBuilder.setCompressionEnabled(false);

                configBuilder.setSendPresence(false);

                configBuilder.setServiceName("ivypolis.com");

 

                //SASLAuthentication.supportSASLMechanism("PLAIN", 0);

 

                AbstractXMPPConnection connection = new XMPPTCPConnection(configBuilder.build());

 

 

                // Connect to the server

                try {

                    connection.connect();

                } catch (SmackException e) {

                    e.printStackTrace();

                } catch (IOException e) {

                    e.printStackTrace();

                } catch (XMPPException e) {

                    e.printStackTrace();

                }

 

 

                // Log into the server

                try {

                    Log.e("Login", "reach here");

                    connection.login("atest","123");

                } catch (XMPPException e) {

                    e.printStackTrace();

                } catch (SmackException e) {

                    e.printStackTrace();

                } catch (IOException e) {

                    e.printStackTrace();

                }

                Log.e("before disconnect", "reach here");

                // Disconnect from the server

                //connection.disconnect();

                return true;

  }

  };

  connectionThread.execute();

  }

 

 

 

Android Log:

 

 

06-21 15:35:49.790    3442-3501/exampl.com.testxmpp D/SMACK﹕ SENT (0): <stream:stream xmlns='jabber:client' to='ivypolis.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='atest@ivypolis.com@ivypolis.com' xml:lang='en'>

06-21 15:35:50.243    3442-3502/exampl.com.testxmpp D/SMACK﹕ RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="iz23qi1f87sz" id="bcf58ca1" xml:lang="en" version="1.0">

06-21 15:35:50.461    3442-3502/exampl.com.testxmpp 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>CRAM-MD5</mechanism></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>

06-21 15:35:50.477    3442-3478/exampl.com.testxmpp E/Login﹕ reach here

06-21 15:35:50.485    3442-3501/exampl.com.testxmpp D/SMACK﹕ SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'>=</auth>

06-21 15:35:50.711    3442-3502/exampl.com.testxmpp D/SMACK﹕ RECV (0): <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09Iml6MjNxaTFmODdzeiIsbm9uY2U9Ij g2dVRXREZhU09pSU9QajQyd2F5dmxSRFZvZWVud3lnMG9XcHF4dzkiLHFvcD0iYXV0aCIsY2hhcnNldD 11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>

06-21 15:35:50.735    3442-3501/exampl.com.testxmpp D/SMACK﹕ SENT (0): <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>dXNlcm5hbWU9ImF0ZXN0QGl2eXBvbGlzLmNvbS IscmVhbG09Iml2eXBvbGlzLmNvbSIsbm9uY2U9Ijg2dVRXREZhU09pSU9QajQyd2F5dmxSRFZvZWVud3 lnMG9XcHF4dzkiLGNub25jZT0iUGVHN1RVTnN5VzBZSzdJMVgzTDgzU2E0ZzBuOGExaTciLG5jPTAwMD AwMDAxLHFvcD1hdXRoLGRpZ2VzdC11cmk9InhtcHAvaXZ5cG9saXMuY29tIixyZXNwb25zZT0zZjVhMD E0Zjc4M2RhZWE0MjgwZTUyMGZjMTk4NGU3YixjaGFyc2V0PXV0Zi04</response>

06-21 15:35:50.969    3442-3502/exampl.com.testxmpp D/SMACK﹕ RECV (0): <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>

06-21 15:35:50.969    3442-3478/exampl.com.testxmpp W/System.err﹕ org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: not-authorized

06-21 15:35:50.977    3442-3478/exampl.com.testxmpp W/System.err﹕ at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthenticati on.java:365)

06-21 15:35:50.977    3442-3478/exampl.com.testxmpp W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1033)

06-21 15:35:50.977    3442-3478/exampl.com.testxmpp W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon nection.java:937)

06-21 15:35:50.977    3442-3478/exampl.com.testxmpp W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:952)

06-21 15:35:50.977    3442-3478/exampl.com.testxmpp W/System.err﹕ at java.lang.Thread.run(Thread.java:811)

06-21 15:35:50.977    3442-3478/exampl.com.testxmpp E/before disconnect﹕ reach here

Outcomes