title: org.jivesoftware.smack.sasl.SASLErrorException: SASLError using PLAIN: not-authorized
body: <p>We have two server one server done authentication through restful API and other is doing authentication from the local db of mongoosim. My authentication gets failed on the server which is doing authentication through mongooseim db. </p>
  
  <p>These are the captured packets for session </p>
  
  <pre><code>D/SMACK: SENT (0): &lt;stream:stream xmlns='jabber:client' to='ip' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='test@ip' xml:lang='en'&gt;
  D/SMACK: RECV (0): &lt;?xml version='1.0'?&gt;&lt;stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='BB3E907D81DDDB71' from='ip' version='1.0' xml:lang='en'&gt;&lt;stream:features&gt;&lt;starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/&gt;&lt;mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;&lt;mechanism&gt;PLAIN&lt;/mechanism&gt;&lt;mechanism&gt;DIGEST-MD5&lt;/mechanism&gt;&lt;mechanism&gt;SCRAM-SHA-1&lt;/mechanism&gt;&lt;/mechanisms&gt;&lt;register xmlns='http://jabber.org/features/iq-register'/&gt;&lt;sm xmlns='urn:xmpp:sm:3'/&gt;&lt;/stream:featur
  </code></pre>
  
  <p>This is the exception I'm getting while authenticating.</p>
  
  <pre><code>01-29 15:58:21.673 4793-5035/com.safarifone.waafi.debug W/System.err: org.jivesoftware.smack.sasl.SASLErrorException: SASLError using PLAIN: not-authorized
  01-29 15:58:21.684 4793-5035/com.safarifone.waafi.debug W/System.err:     at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthentication.java:291)
  01-29 15:58:21.687 4793-5035/com.safarifone.waafi.debug W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1096)
  01-29 15:58:21.688 4793-5035/com.safarifone.waafi.debug W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:994)
  01-29 15:58:21.690 4793-5035/com.safarifone.waafi.debug W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1010)
  </code></pre>
  
  <p>Captured packets </p>
  
  <pre><code>D/SMACK: SENT (0): &lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'&gt;ADkyMzE1NTEwNDI5MgA=&lt;/auth&gt;
  D/SMACK: RECV (0): &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;&lt;not-authorized/&gt;&lt;/failure&gt;
  </code></pre>
  
  <p>This is how I've configured my client </p>
  
  <pre><code>            XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder()
                      .setUsernameAndPassword(mAccount.getUserName(), mAccount.getPassword())
                      .setXmppDomain(com.safarifone.settings.Settings.IM_SERVER)
  
                      .setHost(mAccount.getHost())
                      .setPort(mAccount.getPort())
                      .setKeystoreType(null)
                      .setSendPresence(true)
                      .setResource(IMConstant.XMPP_RESOURCE)
                      .setDebuggerEnabled(true)
                      .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
                      .setConnectTimeout(IMService.CONNECT_TIMEOUT);
  
              Log.d(TAG, "Setting TLS Certificates Settings for XMPPTCPConnectionConfiguration Object ");
            //  TLSUtils.acceptAllCertificates(builder);
  
              Log.d(TAG, "Setting XMPPTCPConnection Static StreamManagement Default Properties to true ");
              XMPPTCPConnection.setUseStreamManagementDefault(true);
              XMPPTCPConnection.setUseStreamManagementResumptionDefault(true);
  
          Log.d(TAG, "Setting SASLAuthentication Blacklist");
  
          SASLAuthentication.unBlacklistSASLMechanism("PLAIN");
          SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5");
          SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");
  
  
          SASLAuthentication.registerSASLMechanism(new SASLPlainMechanism());
  </code></pre>
  
  <p><strong>Note :</strong> <em>I'm able to authenticate if i use some other client like jitsi.</em> </p>