From 616c13dc474c6f5d7a9ef1e58fe7ab6672e13da5 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Wed, 13 Sep 2023 14:48:22 -0500 Subject: [PATCH] Convert exceptions while parsing to SmackParsingException. --- .../extensions/EmptyElementIqProvider.java | 9 ++- .../xmpp/extensions/SafeParseIqProvider.java | 77 +++++++++++++++++++ .../xmpp/extensions/coin/CoinIQProvider.java | 10 ++- .../colibri/ColibriStatsIqProvider.java | 10 +-- .../ConferenceModifiedIQProvider.java | 6 +- .../colibri2/ConferenceModifyIQProvider.java | 6 +- .../inputevt/InputEvtIQProvider.java | 27 +++---- .../extensions/jibri/JibriIqProvider.java | 11 +-- .../extensions/jingle/JingleIQProvider.java | 10 +-- .../jingleinfo/JingleInfoQueryIQProvider.java | 11 +-- .../jitsimeet/ConferenceIqProvider.java | 21 +++-- .../jitsimeet/LoginUrlIqProvider.java | 10 +-- .../jitsimeet/LogoutIqProvider.java | 10 +-- .../extensions/jitsimeet/MuteIqProvider.java | 11 +-- .../jitsimeet/MuteVideoIqProvider.java | 11 +-- .../xmpp/extensions/rayo/RayoIqProvider.java | 11 +-- .../ThumbnailStreamInitiationProvider.java | 11 +-- .../xmpp/extensions/visitors/VisitorsIq.kt | 10 +-- 18 files changed, 158 insertions(+), 114 deletions(-) create mode 100644 src/main/java/org/jitsi/xmpp/extensions/SafeParseIqProvider.java diff --git a/src/main/java/org/jitsi/xmpp/extensions/EmptyElementIqProvider.java b/src/main/java/org/jitsi/xmpp/extensions/EmptyElementIqProvider.java index 045eefb6..87f79113 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/EmptyElementIqProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/EmptyElementIqProvider.java @@ -16,8 +16,8 @@ package org.jitsi.xmpp.extensions; import java.io.*; + import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.xml.*; import org.jivesoftware.smack.xml.XmlPullParser.*; @@ -26,7 +26,7 @@ * Implements an {@link IqProvider} for empty elements. */ public abstract class EmptyElementIqProvider - extends IqProvider + extends SafeParseIqProvider { private final String element; @@ -49,9 +49,10 @@ protected EmptyElementIqProvider(String element, String namespace) * @return a new IQ instance parsed from the specified IQ * sub-document */ - public final T parse(XmlPullParser parser, int initialDepth, + @Override + protected T doParse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + throws XmlPullParserException, IOException { T iq; diff --git a/src/main/java/org/jitsi/xmpp/extensions/SafeParseIqProvider.java b/src/main/java/org/jitsi/xmpp/extensions/SafeParseIqProvider.java new file mode 100644 index 00000000..0cc8a87b --- /dev/null +++ b/src/main/java/org/jitsi/xmpp/extensions/SafeParseIqProvider.java @@ -0,0 +1,77 @@ +/* + * Copyright @ 2023 - present 8x8, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jitsi.xmpp.extensions; + +import org.jivesoftware.smack.packet.*; +import org.jivesoftware.smack.parsing.*; +import org.jivesoftware.smack.provider.*; +import org.jivesoftware.smack.xml.*; + +import java.io.*; + +/** + * Catch all unexpected exceptions while parsing and convert them to a {@link SmackParsingException}. + * + * Implementations should override either {@link #doParse(XmlPullParser)} or + * {@link #doParse(XmlPullParser, int, IqData, XmlEnvironment)} if they need the extra parameters. + */ +public abstract class SafeParseIqProvider extends IqProvider +{ + @Override + public I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) + throws XmlPullParserException, IOException, SmackParsingException + { + try + { + return doParse(parser, initialDepth, iqData, xmlEnvironment); + } + catch (XmlPullParserException | IOException | SmackParsingException e) + { + throw e; + } + catch (Exception e) + { + throw new OtherSmackParsingException(e); + } + } + + /** + * Default implementation which ignores all params except {@code parser}. + * Override if the extra parameters are needed. + */ + protected I doParse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) + throws Exception + { + return doParse(parser); + } + + /** + * Override this method if the extra parameters are not needed. + */ + protected I doParse(XmlPullParser parser) + throws Exception + { + throw new SmackParsingException("Not implemented"); + } + + static class OtherSmackParsingException extends SmackParsingException + { + OtherSmackParsingException(Exception e) + { + super(e); + } + } +} diff --git a/src/main/java/org/jitsi/xmpp/extensions/coin/CoinIQProvider.java b/src/main/java/org/jitsi/xmpp/extensions/coin/CoinIQProvider.java index 0c4b6f68..9f8bb510 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/coin/CoinIQProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/coin/CoinIQProvider.java @@ -17,7 +17,7 @@ import org.jitsi.xmpp.extensions.*; -import org.jivesoftware.smack.packet.*; +import org.jitsi.xmpp.extensions.colibri2.*; import org.jivesoftware.smack.parsing.*; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.xml.*; @@ -30,7 +30,7 @@ * @author Sebastien Vincent */ public class CoinIQProvider - extends IqProvider + extends SafeParseIqProvider { /** * Provider for description packet extension. @@ -110,10 +110,12 @@ public CoinIQProvider() * * @param parser XML parser * @return CoinIQ - * @throws Exception if something goes wrong during parsing + * @throws XmlPullParserException if something goes wrong during parsing + * @throws IOException if something goes wrong during parsing + * @throws SmackParsingException if something goes wrong during parsing */ @Override - public CoinIQ parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) + protected CoinIQ doParse(XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException { CoinIQ coinIQ = new CoinIQ(); diff --git a/src/main/java/org/jitsi/xmpp/extensions/colibri/ColibriStatsIqProvider.java b/src/main/java/org/jitsi/xmpp/extensions/colibri/ColibriStatsIqProvider.java index 2b065a13..d25f46d9 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/colibri/ColibriStatsIqProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/colibri/ColibriStatsIqProvider.java @@ -18,8 +18,7 @@ import java.io.*; import org.jitsi.xmpp.extensions.*; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; +import org.jitsi.xmpp.extensions.colibri2.*; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.xml.*; @@ -31,7 +30,7 @@ * @author Boris Grozev */ public class ColibriStatsIqProvider - extends IqProvider + extends SafeParseIqProvider { /** Initializes a new ColibriIQProvider instance. */ public ColibriStatsIqProvider() @@ -64,8 +63,9 @@ public ColibriStatsIqProvider() * @return a new IQ instance parsed from the specified IQ * sub-document */ - public ColibriStatsIQ parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + @Override + protected ColibriStatsIQ doParse(XmlPullParser parser) + throws XmlPullParserException, IOException { String namespace = parser.getNamespace(); ColibriStatsIQ iq; diff --git a/src/main/java/org/jitsi/xmpp/extensions/colibri2/ConferenceModifiedIQProvider.java b/src/main/java/org/jitsi/xmpp/extensions/colibri2/ConferenceModifiedIQProvider.java index 5891a75d..fb35aee1 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/colibri2/ConferenceModifiedIQProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/colibri2/ConferenceModifiedIQProvider.java @@ -16,9 +16,9 @@ package org.jitsi.xmpp.extensions.colibri2; +import org.jitsi.xmpp.extensions.*; import org.jivesoftware.smack.packet.*; import org.jivesoftware.smack.parsing.*; -import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.xml.*; import java.io.*; @@ -26,10 +26,10 @@ /** * Provider for Colibri2 conference-modify IQs. */ -public class ConferenceModifiedIQProvider extends IqProvider +public class ConferenceModifiedIQProvider extends SafeParseIqProvider { @Override - public ConferenceModifiedIQ parse( + protected ConferenceModifiedIQ doParse( XmlPullParser parser, int initialDepth, IqData iqData, diff --git a/src/main/java/org/jitsi/xmpp/extensions/colibri2/ConferenceModifyIQProvider.java b/src/main/java/org/jitsi/xmpp/extensions/colibri2/ConferenceModifyIQProvider.java index e9b7dde0..69766835 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/colibri2/ConferenceModifyIQProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/colibri2/ConferenceModifyIQProvider.java @@ -16,9 +16,9 @@ package org.jitsi.xmpp.extensions.colibri2; +import org.jitsi.xmpp.extensions.*; import org.jivesoftware.smack.packet.*; import org.jivesoftware.smack.parsing.*; -import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.xml.*; import java.io.*; @@ -26,10 +26,10 @@ /** * Provider for Colibri2 conference-modify IQs. */ -public class ConferenceModifyIQProvider extends IqProvider +public class ConferenceModifyIQProvider extends SafeParseIqProvider { @Override - public ConferenceModifyIQ parse( + protected ConferenceModifyIQ doParse( XmlPullParser parser, int initialDepth, IqData iqData, diff --git a/src/main/java/org/jitsi/xmpp/extensions/inputevt/InputEvtIQProvider.java b/src/main/java/org/jitsi/xmpp/extensions/inputevt/InputEvtIQProvider.java index 4fff4b89..8ab30f48 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/inputevt/InputEvtIQProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/inputevt/InputEvtIQProvider.java @@ -15,20 +15,16 @@ */ package org.jitsi.xmpp.extensions.inputevt; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; -import org.jivesoftware.smack.provider.*; +import org.jitsi.xmpp.extensions.*; import org.jivesoftware.smack.xml.*; -import java.io.*; - /** * Implements an IQProvider which parses incoming InputEvtIQs. * * @author Sebastien Vincent */ public class InputEvtIQProvider - extends IqProvider + extends SafeParseIqProvider { /** * Parse the Input IQ sub-document and returns the corresponding @@ -39,13 +35,11 @@ public class InputEvtIQProvider * @throws Exception if something goes wrong during parsing */ @Override - public InputEvtIQ parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + protected InputEvtIQ doParse(XmlPullParser parser) + throws Exception { InputEvtIQ inputEvtIQ = new InputEvtIQ(); - InputEvtAction action - = InputEvtAction.parseString( - parser.getAttributeValue("", InputEvtIQ.ACTION_ATTR_NAME)); + InputEvtAction action = InputEvtAction.parseString(parser.getAttributeValue("", InputEvtIQ.ACTION_ATTR_NAME)); inputEvtIQ.setAction(action); @@ -57,13 +51,10 @@ public InputEvtIQ parse(XmlPullParser parser, int initialDepth, IqData data, Xml { case START_ELEMENT: // - if (RemoteControlExtensionProvider.ELEMENT_REMOTE_CONTROL - .equals(parser.getName())) + if (RemoteControlExtensionProvider.ELEMENT_REMOTE_CONTROL.equals(parser.getName())) { - RemoteControlExtensionProvider provider - = new RemoteControlExtensionProvider(); - RemoteControlExtension item - = provider.parse(parser); + RemoteControlExtensionProvider provider = new RemoteControlExtensionProvider(); + RemoteControlExtension item = provider.parse(parser); inputEvtIQ.addRemoteControl(item); } @@ -71,7 +62,9 @@ public InputEvtIQ parse(XmlPullParser parser, int initialDepth, IqData data, Xml case END_ELEMENT: if (InputEvtIQ.ELEMENT.equals(parser.getName())) + { done = true; + } break; } } diff --git a/src/main/java/org/jitsi/xmpp/extensions/jibri/JibriIqProvider.java b/src/main/java/org/jitsi/xmpp/extensions/jibri/JibriIqProvider.java index f76b050f..59bee1b0 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/jibri/JibriIqProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/jibri/JibriIqProvider.java @@ -17,28 +17,25 @@ import org.apache.commons.lang3.StringUtils; +import org.jitsi.xmpp.extensions.*; import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; -import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.util.*; import org.jivesoftware.smack.xml.*; import org.jxmpp.jid.*; import org.jxmpp.jid.impl.*; -import java.io.*; - /** * Parses {@link JibriIq}. */ public class JibriIqProvider - extends IqProvider + extends SafeParseIqProvider { /** * {@inheritDoc} */ @Override - public JibriIq parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + protected JibriIq doParse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) + throws Exception { String namespace = parser.getNamespace(); diff --git a/src/main/java/org/jitsi/xmpp/extensions/jingle/JingleIQProvider.java b/src/main/java/org/jitsi/xmpp/extensions/jingle/JingleIQProvider.java index 26b93730..7edb9ba2 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/jingle/JingleIQProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/jingle/JingleIQProvider.java @@ -18,24 +18,22 @@ import org.jitsi.xmpp.extensions.*; import org.jitsi.xmpp.extensions.colibri.*; +import org.jitsi.xmpp.extensions.colibri2.*; import org.jitsi.xmpp.extensions.condesc.*; import org.jitsi.xmpp.extensions.jitsimeet.*; import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.util.*; import org.jivesoftware.smack.xml.*; import org.jxmpp.jid.*; import org.jxmpp.jid.impl.*; -import java.io.*; - /** * An implementation of a Jingle IQ provider that parses incoming Jingle IQs. * * @author Emil Ivov */ -public class JingleIQProvider extends IqProvider +public class JingleIQProvider extends SafeParseIqProvider { /** * Creates a new instance of the JingleIQProvider and register all @@ -258,8 +256,8 @@ public JingleIQProvider() * @throws Exception if an error occurs parsing the XML. */ @Override - public JingleIQ parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + protected JingleIQ doParse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) + throws Exception { //let's first handle the "jingle" element params. JingleAction action = JingleAction.parseString(parser diff --git a/src/main/java/org/jitsi/xmpp/extensions/jingleinfo/JingleInfoQueryIQProvider.java b/src/main/java/org/jitsi/xmpp/extensions/jingleinfo/JingleInfoQueryIQProvider.java index 249ec34e..1ab7c95c 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/jingleinfo/JingleInfoQueryIQProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/jingleinfo/JingleInfoQueryIQProvider.java @@ -17,20 +17,17 @@ import org.jitsi.xmpp.extensions.*; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; +import org.jitsi.xmpp.extensions.colibri2.*; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.xml.*; -import java.io.*; - /** * Provider for the JingleInfoQueryIQ. * * @author Sebastien Vincent */ public class JingleInfoQueryIQProvider - extends IqProvider + extends SafeParseIqProvider { /** * STUN packet extension provider. @@ -63,8 +60,8 @@ public JingleInfoQueryIQProvider() * @throws Exception if an error occurs parsing the XML. */ @Override - public JingleInfoQueryIQ parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + protected JingleInfoQueryIQ doParse(XmlPullParser parser) + throws Exception { boolean done = false; JingleInfoQueryIQ iq = new JingleInfoQueryIQ(); diff --git a/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/ConferenceIqProvider.java b/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/ConferenceIqProvider.java index 3f0af00e..bb9bd30a 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/ConferenceIqProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/ConferenceIqProvider.java @@ -18,7 +18,7 @@ import org.apache.commons.lang3.StringUtils; -import org.jivesoftware.smack.packet.*; +import org.jitsi.xmpp.extensions.*; import org.jivesoftware.smack.parsing.*; import org.jivesoftware.smack.provider.*; @@ -37,7 +37,7 @@ * @author Pawel Domas */ public class ConferenceIqProvider - extends IqProvider + extends SafeParseIqProvider { /** * Creates new instance of ConferenceIqProvider. @@ -46,14 +46,11 @@ public ConferenceIqProvider() { // ProviderManager.addIQProvider( - ConferenceIq.ELEMENT, ConferenceIq.NAMESPACE, this); + ConferenceIq.ELEMENT, ConferenceIq.NAMESPACE, this); } - /** - * {@inheritDoc} - */ @Override - public ConferenceIq parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) + protected ConferenceIq doParse(XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException { String namespace = parser.getNamespace(); @@ -196,11 +193,12 @@ public static EntityBareJid getRoomJid(String unescapedValue) // the node part of the jid may contain '@' which is not allowed // and passing the correct node value to Localpart.from will check // for all not allowed jid characters - int ix = unescapedValue.lastIndexOf("@"); + int ix = unescapedValue == null ? -1 : unescapedValue.lastIndexOf("@"); if (ix == -1) - throw new XmppStringprepException(unescapedValue, - "wrong room name jid format"); + { + throw new XmppStringprepException(unescapedValue, "wrong room name jid format"); + } String domainPart = unescapedValue.substring(ix + 1); String localPart = unescapedValue.substring(0, ix); @@ -211,7 +209,6 @@ public static EntityBareJid getRoomJid(String unescapedValue) throw new XmppStringprepException(unescapedValue, "Localpart must not contain '@'"); } - return JidCreate.entityBareFrom( - Localpart.from(localPart), Domainpart.from(domainPart)); + return JidCreate.entityBareFrom(Localpart.from(localPart), Domainpart.from(domainPart)); } } diff --git a/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/LoginUrlIqProvider.java b/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/LoginUrlIqProvider.java index ffa255a6..263ab6ac 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/LoginUrlIqProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/LoginUrlIqProvider.java @@ -17,16 +17,14 @@ import org.apache.commons.lang3.StringUtils; +import org.jitsi.xmpp.extensions.*; import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.util.*; import org.jivesoftware.smack.xml.*; import org.jxmpp.jid.*; import org.jxmpp.jid.impl.*; -import java.io.*; - /** * Provider handles parsing of {@link ConferenceIq} and {@link LoginUrlIq} * stanzas and converting objects back to their XML representation. @@ -34,7 +32,7 @@ * @author Pawel Domas */ public class LoginUrlIqProvider - extends IqProvider + extends SafeParseIqProvider { /** * Creates new instance of ConferenceIqProvider. @@ -50,8 +48,8 @@ public LoginUrlIqProvider() * {@inheritDoc} */ @Override - public LoginUrlIq parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + protected LoginUrlIq doParse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) + throws Exception { String namespace = parser.getNamespace(); diff --git a/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/LogoutIqProvider.java b/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/LogoutIqProvider.java index f2fb85ab..59581b31 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/LogoutIqProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/LogoutIqProvider.java @@ -17,14 +17,12 @@ import org.apache.commons.lang3.StringUtils; +import org.jitsi.xmpp.extensions.*; import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.util.*; import org.jivesoftware.smack.xml.*; -import java.io.*; - /** * Provider handles parsing of {@link ConferenceIq} and {@link LoginUrlIq} * stanzas and converting objects back to their XML representation. @@ -32,7 +30,7 @@ * @author Pawel Domas */ public class LogoutIqProvider - extends IqProvider + extends SafeParseIqProvider { /** * Creates new instance of ConferenceIqProvider. @@ -48,8 +46,8 @@ public LogoutIqProvider() * {@inheritDoc} */ @Override - public LogoutIq parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + protected LogoutIq doParse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) + throws Exception { String namespace = parser.getNamespace(); diff --git a/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/MuteIqProvider.java b/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/MuteIqProvider.java index 3f97a4dd..fbd15eb4 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/MuteIqProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/MuteIqProvider.java @@ -15,23 +15,20 @@ */ package org.jitsi.xmpp.extensions.jitsimeet; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; +import org.jitsi.xmpp.extensions.*; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.xml.*; import org.jxmpp.jid.*; import org.jxmpp.jid.impl.*; -import java.io.*; - /** * The parser of {@link MuteIq}. * * @author Pawel Domas */ public class MuteIqProvider - extends IqProvider + extends SafeParseIqProvider { /** * Registers this IQ provider into given ProviderManager. @@ -48,8 +45,8 @@ public static void registerMuteIqProvider() * {@inheritDoc} */ @Override - public MuteIq parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + protected MuteIq doParse(XmlPullParser parser) + throws Exception { String namespace = parser.getNamespace(); diff --git a/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/MuteVideoIqProvider.java b/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/MuteVideoIqProvider.java index 26c7b260..939c195b 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/MuteVideoIqProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/jitsimeet/MuteVideoIqProvider.java @@ -15,23 +15,20 @@ */ package org.jitsi.xmpp.extensions.jitsimeet; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; +import org.jitsi.xmpp.extensions.*; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.xml.*; import org.jxmpp.jid.*; import org.jxmpp.jid.impl.*; -import java.io.*; - /** * The parser of {@link MuteVideoIq}. * * @author Steffen Kolmer */ public class MuteVideoIqProvider - extends IqProvider + extends SafeParseIqProvider { /** * Registers this IQ provider into given ProviderManager. @@ -48,8 +45,8 @@ public static void registerMuteVideoIqProvider() * {@inheritDoc} */ @Override - public MuteVideoIq parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + protected MuteVideoIq doParse(XmlPullParser parser) + throws Exception { String namespace = parser.getNamespace(); diff --git a/src/main/java/org/jitsi/xmpp/extensions/rayo/RayoIqProvider.java b/src/main/java/org/jitsi/xmpp/extensions/rayo/RayoIqProvider.java index 6ddfbf60..c046a5d3 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/rayo/RayoIqProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/rayo/RayoIqProvider.java @@ -17,13 +17,10 @@ import org.apache.commons.lang3.StringUtils; import org.jitsi.xmpp.extensions.*; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; +import org.jitsi.xmpp.extensions.colibri2.*; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.xml.*; -import java.io.*; - /** * Provider handles parsing of Rayo IQ stanzas and converting objects back to * their XML representation. @@ -33,7 +30,7 @@ * @author Pawel Domas */ public class RayoIqProvider - extends IqProvider + extends SafeParseIqProvider { /** * Rayo namespace. @@ -80,8 +77,8 @@ public void registerRayoIQs() * {@inheritDoc} */ @Override - public RayoIq parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + protected RayoIq doParse(XmlPullParser parser) + throws Exception { String namespace = parser.getNamespace(); diff --git a/src/main/java/org/jitsi/xmpp/extensions/thumbnail/ThumbnailStreamInitiationProvider.java b/src/main/java/org/jitsi/xmpp/extensions/thumbnail/ThumbnailStreamInitiationProvider.java index a36c7e5d..e0a56c1e 100644 --- a/src/main/java/org/jitsi/xmpp/extensions/thumbnail/ThumbnailStreamInitiationProvider.java +++ b/src/main/java/org/jitsi/xmpp/extensions/thumbnail/ThumbnailStreamInitiationProvider.java @@ -16,21 +16,18 @@ package org.jitsi.xmpp.extensions.thumbnail; import org.jitsi.utils.logging2.*; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.parsing.*; -import org.jivesoftware.smack.provider.*; +import org.jitsi.xmpp.extensions.*; import org.jivesoftware.smack.xml.*; import org.jivesoftware.smackx.si.packet.*; import org.jivesoftware.smackx.xdata.packet.*; import org.jivesoftware.smackx.xdata.provider.*; import org.jxmpp.util.XmppDateTime; -import java.io.*; import java.text.*; import java.util.*; public class ThumbnailStreamInitiationProvider - extends IqProvider + extends SafeParseIqProvider { private static final Logger logger = new LoggerImpl(ThumbnailStreamInitiationProvider.class.getName()); @@ -40,8 +37,8 @@ public class ThumbnailStreamInitiationProvider * @param parser the parser to parse */ @Override - public StreamInitiation parse(XmlPullParser parser, int initialDepth, IqData data, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException + protected StreamInitiation doParse(XmlPullParser parser) + throws Exception { boolean done = false; diff --git a/src/main/kotlin/org/jitsi/xmpp/extensions/visitors/VisitorsIq.kt b/src/main/kotlin/org/jitsi/xmpp/extensions/visitors/VisitorsIq.kt index ad20c732..530c7b9e 100644 --- a/src/main/kotlin/org/jitsi/xmpp/extensions/visitors/VisitorsIq.kt +++ b/src/main/kotlin/org/jitsi/xmpp/extensions/visitors/VisitorsIq.kt @@ -15,6 +15,7 @@ */ package org.jitsi.xmpp.extensions.visitors +import org.jitsi.xmpp.extensions.SafeParseIqProvider import org.jitsi.xmpp.extensions.colibri2.IqProviderUtils import org.jitsi.xmpp.extensions.jitsimeet.ConferenceIqProvider import org.jivesoftware.smack.XMPPConnection @@ -23,12 +24,9 @@ import org.jivesoftware.smack.packet.IqBuilder import org.jivesoftware.smack.packet.IqData import org.jivesoftware.smack.packet.XmlEnvironment import org.jivesoftware.smack.parsing.SmackParsingException -import org.jivesoftware.smack.provider.IqProvider import org.jivesoftware.smack.provider.ProviderManager import org.jivesoftware.smack.xml.XmlPullParser -import org.jivesoftware.smack.xml.XmlPullParserException import org.jxmpp.jid.EntityBareJid -import java.io.IOException import java.lang.IllegalArgumentException class VisitorsIq private constructor(b: Builder) : IQ(b, ELEMENT, NAMESPACE) { @@ -90,9 +88,9 @@ class VisitorsIq private constructor(b: Builder) : IQ(b, ELEMENT, NAMESPACE) { } } -class VisitorsIqProvider : IqProvider() { - @Throws(XmlPullParserException::class, IOException::class, SmackParsingException::class) - override fun parse( +class VisitorsIqProvider : SafeParseIqProvider() { + @Throws(Exception::class) + override fun doParse( parser: XmlPullParser, initialDepth: Int, data: IqData,