mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
SMACK-280: The SASL mechanisms work transparent with packet listeners
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@11615 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
ad65a76e77
commit
e3efee2e8f
3 changed files with 121 additions and 12 deletions
|
@ -22,6 +22,9 @@ package org.jivesoftware.smack;
|
|||
|
||||
import org.jivesoftware.smack.Connection.ListenerWrapper;
|
||||
import org.jivesoftware.smack.packet.*;
|
||||
import org.jivesoftware.smack.sasl.SASLMechanism.Challenge;
|
||||
import org.jivesoftware.smack.sasl.SASLMechanism.Failure;
|
||||
import org.jivesoftware.smack.sasl.SASLMechanism.Success;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.xmlpull.mxp1.MXParser;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -281,14 +284,28 @@ class PacketReader {
|
|||
else {
|
||||
// SASL authentication has failed. The server may close the connection
|
||||
// depending on the number of retries
|
||||
final Failure failure = PacketParserUtils.parseSASLFailure(parser);
|
||||
processPacket(failure);
|
||||
connection.getSASLAuthentication().authenticationFailed();
|
||||
}
|
||||
}
|
||||
else if (parser.getName().equals("challenge")) {
|
||||
// The server is challenging the SASL authentication made by the client
|
||||
connection.getSASLAuthentication().challengeReceived(parser.nextText());
|
||||
String challengeData = parser.nextText();
|
||||
processPacket(new Challenge(challengeData));
|
||||
connection.getSASLAuthentication().challengeReceived(challengeData);
|
||||
}
|
||||
else if (parser.getName().equals("success")) {
|
||||
processPacket(new Success(parser.nextText()));
|
||||
// We now need to bind a resource for the connection
|
||||
// Open a new stream and wait for the response
|
||||
connection.packetWriter.openStream();
|
||||
// Reset the state of the parser since a new stream element is going
|
||||
// to be sent by the server
|
||||
resetParser();
|
||||
// The SASL authentication with the server was successful. The next step
|
||||
// will be to bind the resource
|
||||
connection.getSASLAuthentication().authenticated();
|
||||
}
|
||||
else if (parser.getName().equals("compressed")) {
|
||||
// Server confirmed that it's possible to use stream compression. Start
|
||||
|
@ -304,17 +321,6 @@ class PacketReader {
|
|||
// Disconnect the connection
|
||||
connection.disconnect();
|
||||
}
|
||||
else if (parser.getName().equals("success")) {
|
||||
// We now need to bind a resource for the connection
|
||||
// Open a new stream and wait for the response
|
||||
connection.packetWriter.openStream();
|
||||
// Reset the state of the parser since a new stream element is going
|
||||
// to be sent by the server
|
||||
resetParser();
|
||||
// The SASL authentication with the server was successful. The next step
|
||||
// will be to bind the resource
|
||||
connection.getSASLAuthentication().authenticated();
|
||||
}
|
||||
}
|
||||
eventType = parser.next();
|
||||
} while (!done && eventType != XmlPullParser.END_DOCUMENT && thread == readerThread);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue