code: public synchronized void login() throws XMPPException, SmackException, IOException, InterruptedException {
          // The previously used username, password and resource take over precedence over the
          // ones from the connection configuration
          CharSequence username = usedUsername != null ? usedUsername : config.getUsername();
          String password = usedPassword != null ? usedPassword : config.getPassword();
          Resourcepart resource = usedResource != null ? usedResource : config.getResource();
          login(username, password, resource);
      }
docs: Logs in to the server using the strongest SASL mechanism supported by
  the server. If more than the connection's default stanza timeout elapses in each step of the
  authentication process without a response from the server, a
  {@link SmackException.NoResponseException} will be thrown.
  <p>
  Before logging in (i.e. authenticate) to the server the connection must be connected
  by calling {@link #connect}.
  </p>
  <p>
  It is possible to log in without sending an initial available presence by using
  {@link ConnectionConfiguration.Builder#setSendPresence(boolean)}.
  Finally, if you want to not pass a password and instead use a more advanced mechanism
  while using SASL then you may be interested in using
  {@link ConnectionConfiguration.Builder#setCallbackHandler(javax.security.auth.callback.CallbackHandler)}.
  For more advanced login settings see {@link ConnectionConfiguration}.
  </p>
  
  @throws XMPPException if an error occurs on the XMPP protocol level.
  @throws SmackException if an error occurs somewhere else besides XMPP protocol level.
  @throws IOException if an I/O error occurs during login.
  @throws InterruptedException