1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 06:12:05 +01:00

Clear saslException class field before throwing

Thanks to PolFW, who writes:

A SASLErrorException is thrown before we have received the "<success
xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>". This is because
SASLAuthentication is keeping a reference to a "saslException" so to
clear that after a authentication failure we have to invoke again
connect on the xmpptcpconnection to initialize again the
saslAuthentication. But it doesn't solve the issue because an
AlreadyConnectedException is thrown before the initialisation of the
"this.saslAuthentication.init();"

Note that the user uses one time tokens for authentication.
This commit is contained in:
Florian Schmaus 2019-09-23 19:47:37 +02:00
parent be0830fc8f
commit 5b1d2664af

View file

@ -216,6 +216,11 @@ public final class SASLAuthentication {
}
if (saslException != null) {
Exception saslException = this.saslException;
// Clear the saslException class field, so that this exception is not thrown after a new authenticate()
// invocation (with different credentials).
this.saslException = null;
if (saslException instanceof SmackSaslException) {
throw (SmackSaslException) saslException;
} else if (saslException instanceof SASLErrorException) {
@ -321,7 +326,6 @@ public final class SASLAuthentication {
*/
void init() {
authenticationSuccessful = false;
saslException = null;
}
String getNameOfLastUsedSaslMechansism() {