@Test public void parseSASLFailureExtended() throws FactoryConfigurationError, TransformerException, ParserConfigurationException, XmlPullParserException, IOException, SAXException { // @formatter:off final String saslFailureString = XMLBuilder.create(SASLFailure.ELEMENT, SaslStreamElements.NAMESPACE) .e(SASLError.account_disabled.toString()) .up() .e("text").a("xml:lang", "en") .t("Call 212-555-1212 for assistance.") .up() .e("text").a("xml:lang", "de") .t("Bitte wenden sie sich an (04321) 123-4444") .up() .e("text") .t("Wusel dusel") .asString(); // @formatter:on XmlPullParser parser = TestUtils.getParser(saslFailureString, SASLFailure.ELEMENT); SASLFailure saslFailure = PacketParserUtils.parseSASLFailure(parser); XmlUnitUtils.assertSimilar(saslFailureString, saslFailure.toXML()); }
public SASLFailure(String saslError, Map<String, String> descriptiveTexts) { super(descriptiveTexts); SASLError error = SASLError.fromString(saslError); if (error == null) { // RFC6120 6.5 states that unknown condition must be treat as generic authentication // failure. this.saslError = SASLError.not_authorized; } else { this.saslError = error; } this.saslErrorString = saslError; }
@Test public void parseSASLFailureSimple() throws FactoryConfigurationError, SAXException, IOException, TransformerException, ParserConfigurationException, XmlPullParserException { // @formatter:off final String saslFailureString = XMLBuilder.create(SASLFailure.ELEMENT, SaslStreamElements.NAMESPACE) .e(SASLError.account_disabled.toString()) .asString(); // @formatter:on XmlPullParser parser = TestUtils.getParser(saslFailureString, SASLFailure.ELEMENT); SASLFailure saslFailure = PacketParserUtils.parseSASLFailure(parser); assertXMLEqual(saslFailureString, saslFailure.toString()); }
/** * Get the SASL related error condition. * * @return the SASL related error condition. */ public SASLError getSASLError() { return saslError; }