powered by Jive Software

Smack 3.2.2 SASL authentication DIGEST-MD5 failed: invalid-authzid


I have big problem. Every time when I’m trying to connect to any jabber server I have got “SASL authentication DIGEST-MD5 failed” notification. I dont have this error when I dont use JPasswordField, but using JTextField in IM is pointless. I have tried every method I found, but it’s all thesame.

The code:

private void bLoginAction(JTextField login, JPasswordField pass) {

loginText = login.getText();

passText = pass.getPassword().toString();

String[] data = loginText.split("@");

Connection.DEBUG_ENABLED = true;

ConnectionConfiguration config = new ConnectionConfiguration(data[1], 5222);

Connection con = new XMPPConnection(config);

try {
} catch (XMPPException e) {

try {

con.login(loginText, passText);
} catch (XMPPException e) {



Print from printStackTrace():

SASL authentication DIGEST-MD5 failed: invalid-authzid:

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 337)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)

at org.jivesoftware.smack.Connection.login(Connection.java:348)

Probably because you are using*** toString()***. Try using getPassword() instead as shown here. Even with a JTextField, you should be using getText() instead of ***toString()***.

It doesnt work either. Look that connect.login() uses as arguments 2 strings so sooner or later I must convert char[] to string.

Then create a String from the char[].

The point is that toString() is not the appropriate method to use to extract your user input. That is not its recommended usage in any Java class as it is meant to give a string representation of the object. It is mainly used for logging and debugging. You can only rely on it to give (hopefully) useful information to the developer, not application or UI level information (except for the most simple of classes, such as primitive data type wrappers).

1 Like

Thank you! It worked perfectly.