Smack 3.2.2 SASL authentication DIGEST-MD5 failed: invalid-authzid
Question
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 {
con.connect();
} catch (XMPPException e) {
e.printStackTrace();
}
try {
con.login(loginText, passText);
} catch (XMPPException e) {
e.printStackTrace();
}
}
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)
Solution
Don't use toString(). Try using getPassword() instead as shown here. Even with a JTextField, you should be using getText() instead of toString().
This is not a smack issue but a straight up Java one.