1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 10:49:41 +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:
Günther Niess 2010-02-09 12:24:24 +00:00 committed by niess
parent ad65a76e77
commit e3efee2e8f
3 changed files with 121 additions and 12 deletions

View file

@ -25,6 +25,7 @@ import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.sasl.SASLMechanism.Failure;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@ -590,6 +591,33 @@ public class PacketParserUtils {
return properties;
}
/**
* Parses SASL authentication error packets.
*
* @param parser the XML parser.
* @return a SASL Failure packet.
* @throws Exception if an exception occurs while parsing the packet.
*/
public static Failure parseSASLFailure(XmlPullParser parser) throws Exception {
String condition = null;
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (!parser.getName().equals("failure")) {
condition = parser.getName();
}
}
else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("failure")) {
done = true;
}
}
}
return new Failure(condition);
}
/**
* Parses stream error packets.
*