title: SMACK API In Band registration fails with forbidden error
body: <p>I am using SMACK API's AccountManager class but failed to successfully create a new account. supportsAccountCreation() returns true.
  The createAccount method fails with the following error. </p>
  
  <pre><code>D/SMACK: SENT (0): &lt;iq to='xmpp.jp' id='e740L-48' type='set'&gt;&lt;query     xmlns='jabber:iq:register'&gt;&lt;username&gt;MY_NEW_USER&lt;/username&gt;&lt;password&gt;**********************&lt;/password&gt;&lt;/query&gt;&lt;/iq&gt;
  D/SMACK: RECV (0): &lt;iq from='xmpp.jp' id='e740L-48' type='error'&gt;&lt;query xmlns='jabber:iq:register'&gt;&lt;username&gt;MY_NEW_USER&lt;/username&gt;&lt;password&gt;*****************&lt;/password&gt;&lt;/query&gt;&lt;error code='403' type='auth'&gt;&lt;forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;&lt;/error&gt;&lt;/iq&gt;
  W/System.err: org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: forbidden - auth
  W/System.err:     at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:232)
  W/System.err:     at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:213)
  W/System.err:     at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:272)
  W/System.err:     at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:244)
  ..
  D/SMACK: SENT (0): &lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='SCRAM-SHA-1'&gt;*****************************************&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><strong>UPDATE: Code added here</strong>
  API v4.1.5</p>
  
  <pre><code>private void initialiseConnection() {
      Log.d("xmpp", "Initialising connection");
      XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
      config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
      config.setServiceName(getServer());
      config.setHost(getServer());
      config.setPort(getPort());
      config.setDebuggerEnabled(true);
      config.setSendPresence(true);
  
  
      XMPPTCPConnection.setUseStreamManagementResumptionDefault(true);
      XMPPTCPConnection.setUseStreamManagementDefault(true);
      connection = new XMPPTCPConnection(config.build());
  
      connection.addConnectionListener(new XMPPConnectionStateHandler(this));
      connection.addConnectionListener(new XMPPAccountLoginHandler(this));
      connection.addConnectionListener(new XMPPOfflineMessageHandler(this));
      connection.addConnectionListener(new XMPPPingMessageHandler(this));
      connection.addConnectionListener(new XMPPReconnectionHandler(this));
      connection.addConnectionListener(new XMPPPresenceHandler(this));
      connection.addConnectionListener(new XMPPDeliveryReceiptHandler(this));
  }
  
  public void connect(final String caller) {
      if (ConnectionManagerHelper.hasDataConnection(context)){
          Log.d(TAG, "Data connection fine");
      } else {
          Log.d(TAG, "Data connection not avaiable");
      }
      AsyncTask&lt;Void, Void, Boolean&gt; connectionThread = new AsyncTask&lt;Void, Void, Boolean&gt;() {
          @Override
          protected synchronized Boolean doInBackground(Void... arg0) {
              if (connection.isConnected()) return false;
              isconnecting = true;
              Log.d("Connect() Function", caller + "=&gt;connecting....");
  
              try {
                  connection.connect();
                  connected = true;
                  notifyConnectionEstablishedEvent();
              } catch (IOException e) {
                  Log.e(TAG, "(" + caller + ")" + " IOException: " + e.getMessage());
                  notifyConnectionFailureEvent();
              } catch (final SmackException e) {
                  Log.e(TAG, "(" + caller + ")" + " SMACKException: " + e.getMessage());
                  notifyConnectionFailureEvent();
              } catch (final XMPPException e) {
                  Log.e(TAG, "(" + caller + ")" + " XMPPException: " + e.getMessage());
                  notifyConnectionFailureEvent();
              }
              return isconnecting = false;
          }
      };
      connectionThread.execute();
  }
  
  public void login() {
      try {
          connection.addAsyncStanzaListener(new StanzaListener() {
              @Override
              public void processPacket(Stanza packet) throws NotConnectedException {
                  Log.d(TAG, packet.toXML().toString());
                  notifyMessageStatusReceivedEvent(packet);
              }
          }, new StanzaFilter() {
              @Override
              public boolean accept(Stanza stanza) {
                  return true;
              }
          });
          Log.d(TAG, "Attempting to login as " + loginUser);
          connection.login(loginUser, passwordUser);
          notifyConnectionConnectedEvent();
      } catch (SmackException.AlreadyLoggedInException e){
          Log.d(TAG, "Already logged on to chat server");
      } catch (XMPPException | SmackException | IOException e) {
          e.printStackTrace();
          //if first login failed, try to create an account and then login
          Log.d(TAG, "Login failed. Trying to create a new account.");
          register();
      }
  }
  
  public void register(){
      Log.d(TAG, "Attempting to register");
      try {
          AccountManager accountManager = AccountManager.getInstance(connection);
          if (accountManager.supportsAccountCreation()){
              Log.d(TAG, "Server supports remote registration");
              accountManager.sensitiveOperationOverInsecureConnection(true);
              Log.d(TAG, "Sending registration request");
              HashMap&lt;String, String&gt; attributes = new HashMap&lt;&gt;();
              attributes.put("email", "test@gmail.com");
              accountManager.createAccount(loginUser, passwordUser, attributes);
          } else {
              Log.w(TAG, "Server does not support remote registrations");
          }
      } catch (XMPPException | SmackException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>I have spent 3 days already googl-ing and stackoverflow-ing. 
  Has someone seen and fixed this already? </p>