title: Smack XMPP: Can't login to openfire server: "SASLErrorException: SASLError using DIGEST-MD5: not-authorized"
body: <p>I am trying to create a basic connection and login to an Openfire server that I have installed. I have the following user in my users database which I created through the Openfire web admin interface:</p>
  
  <pre><code>User: user
  Password: 12345678
  </code></pre>
  
  <p>I can connect fine to the server as the connection returns true in my sout. The problem is when it tries to log in I get the following error:</p>
  
  <pre><code>org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: not-authorized
  </code></pre>
  
  <p>I have the following code: </p>
  
  <pre><code>private XMPPConnection connection;
  
  public void connect(String serverIP) {
      try {
  
          System.setProperty("smack.debugEnabled", "true");
          ConnectionConfiguration config = new ConnectionConfiguration(serverIP, 5223);
          config.setDebuggerEnabled(true);
          config.setSocketFactory(new DummySSLSocketFactory());    
          config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
          config.setCompressionEnabled(true);
          connection = new XMPPTCPConnection(config);
          connection.connect();
  
          System.out.println("Connected: " + connection.isConnected());
          connection.login("user", "12345678");
          System.out.println("Logged in: " + connection.isAuthenticated());
  
      } catch (SmackException | IOException | XMPPException ex) {
          ex.printStackTrace();
      }
  }
  
  public static void main(String[] args) {
      connectionHandler test = new connectionHandler();
      test.connect("localhost");
  }
  </code></pre>
  
  <p>If anyone can correct what I am doing wrong I would be really grateful. </p>
  
  <p>I have also tried the username as the email would be for example</p>
  
  <pre><code>user@localhost.com
  or
  user@localhost
  </code></pre>