diff --git a/build.gradle b/build.gradle index dd3e1bf57..76cf80d61 100644 --- a/build.gradle +++ b/build.gradle @@ -116,7 +116,6 @@ allprojects { ].collect { project(it) } junitVersion = '5.6.0' commonsIoVersion = '2.6' - bouncyCastleVersion = '1.65' if (project.hasProperty("useSonatype")) { useSonatype = project.getProperty("useSonatype").toBoolean() } else { diff --git a/documentation/connection-modules.md b/documentation/connection-modules.md index ef9a40c48..50110e6f7 100644 --- a/documentation/connection-modules.md +++ b/documentation/connection-modules.md @@ -5,7 +5,7 @@ Smack's Modular Connection Architecture **Note: Everything related to the modular connection architecture is currently considered experimental and should not be used in production. Use the mature `XMPPTCPConnection` if you do not feel adventurous. -Smack's modular connection architecture allows to extend a XMPP c2s (client-to-server) connection with additional functionality by adding modules. +Smack's modular connection architecture allows to extend a XMPP c2s (client-to-server) connection with additional functionalty by adding modules. Those modules extend the Finite State Machine (FSM) within the `ModularXmppClientToServerConnection` with new states. Connection modules can either be @@ -32,4 +32,4 @@ Connection modules are plugged into the the modular connection via their constru Modules and states always have an accompanying *descriptor* type. `ModuleDescriptor` and `StateDescriptor` exist without an connection instance. -They describe the module and state metadata, while their modules and states are instanciated once a modular connection is instanciated. +They describe the module and state metadata, while their modules are states are instanciated once a modular connection is instanciated. diff --git a/documentation/extensions/index.md b/documentation/extensions/index.md index 00a9680a7..91f291ca4 100644 --- a/documentation/extensions/index.md +++ b/documentation/extensions/index.md @@ -122,7 +122,6 @@ Experimental Smack Extensions and currently supported XEPs of smack-experimental | [Message Markup](messagemarkup.md) | [XEP-0394](https://xmpp.org/extensions/xep-0394.html) | 0.1.0 | Style message bodies while keeping body and markup information separated. | | DNS Queries over XMPP (DoX) | [XEP-0418](https://xmpp.org/extensions/xep-0418.html) | 0.1.0 | Send DNS queries and responses over XMPP. | | Message Fastening | [XEP-0422](https://xmpp.org/extensions/xep-0422.html) | 0.1.1 | Mark payloads on a message to be logistically fastened to a previous message. | -| Fallback Indication | [XEP-0428](https://xmpp.org/extensions/xep-0428.html) | 0.1.0 | Declare body elements of a message as ignorable fallback for naive legacy clients. | Unofficial XMPP Extensions -------------------------- diff --git a/smack-core/build.gradle b/smack-core/build.gradle index 9a8bd757d..acbbba065 100644 --- a/smack-core/build.gradle +++ b/smack-core/build.gradle @@ -18,7 +18,7 @@ dependencies { // 'implementation' here since there is no need to shadow it // outside of the fixtures compilation classpath. That is, no test // should ever setup Bouncy Castle as security provider explicitly. - testFixturesImplementation "org.bouncycastle:bcprov-jdk15on:${bouncyCastleVersion}" + testFixturesImplementation 'org.bouncycastle:bcprov-jdk15on:1.64' testFixturesImplementation 'org.apache.commons:commons-lang3:3.10' testFixturesApi "org.jxmpp:jxmpp-jid:$jxmppVersion:tests" diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java index ee9377d1a..15c82127e 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java @@ -380,7 +380,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement { * @param elementName the XML element name of the extension. (May be null) * @param namespace the XML element namespace of the extension. * @return the extension, or null if it doesn't exist. - * @deprecated use {@link #getExtension(Class)} or {@link #getExtensionElement(String, String)} instead. + * @deprecated use {@link #getExtension(Class)} or {@link #getExtensionElement(String, String)} isntead. */ // TODO: Remove in Smack 4.5. @SuppressWarnings("unchecked") diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/FallbackIndicationListener.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/FallbackIndicationListener.java deleted file mode 100644 index b7ef22525..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/FallbackIndicationListener.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * - * Copyright 2020 Paul Schaub - * - * 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.jivesoftware.smackx.fallback_indication; - -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement; - -public interface FallbackIndicationListener { - - /** - * Listener method that gets called when a {@link Message} containing a {@link FallbackIndicationElement} is received. - * - * @param message message - * @param indicator Fallback Indication - * @param fallbackBody body that is marked as fallback - */ - void onFallbackIndicationReceived(Message message, FallbackIndicationElement indicator, String fallbackBody); - -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/FallbackIndicationManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/FallbackIndicationManager.java deleted file mode 100644 index da58e6ae9..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/FallbackIndicationManager.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * - * Copyright 2020 Paul Schaub - * - * 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.jivesoftware.smackx.fallback_indication; - -import java.util.Map; -import java.util.Set; -import java.util.WeakHashMap; -import java.util.concurrent.CopyOnWriteArraySet; - -import org.jivesoftware.smack.AsyncButOrdered; -import org.jivesoftware.smack.ConnectionCreationListener; -import org.jivesoftware.smack.Manager; -import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.StanzaListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPConnectionRegistry; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.filter.AndFilter; -import org.jivesoftware.smack.filter.StanzaExtensionFilter; -import org.jivesoftware.smack.filter.StanzaFilter; -import org.jivesoftware.smack.filter.StanzaTypeFilter; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.MessageBuilder; -import org.jivesoftware.smack.packet.Stanza; -import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; -import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement; - -import org.jxmpp.jid.BareJid; -import org.jxmpp.jid.EntityBareJid; - -/** - * Smacks API for XEP-0428: Fallback Indication. - * In some scenarios it might make sense to mark the body of a message as fallback for legacy clients. - * Examples are encryption mechanisms where the sender might include a hint for legacy clients stating that the - * body (eg. "This message is encrypted") should be ignored. - * - * @see XEP-0428: Fallback Indication - */ -public final class FallbackIndicationManager extends Manager { - - private static final Map INSTANCES = new WeakHashMap<>(); - - static { - XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() { - @Override - public void connectionCreated(XMPPConnection connection) { - getInstanceFor(connection); - } - }); - } - - private final Set listeners = new CopyOnWriteArraySet<>(); - private final AsyncButOrdered asyncButOrdered = new AsyncButOrdered<>(); - private final StanzaFilter fallbackIndicationElementFilter = new AndFilter(StanzaTypeFilter.MESSAGE, - new StanzaExtensionFilter(FallbackIndicationElement.ELEMENT, FallbackIndicationElement.NAMESPACE)); - - private final StanzaListener fallbackIndicationElementListener = new StanzaListener() { - @Override - public void processStanza(Stanza packet) { - Message message = (Message) packet; - FallbackIndicationElement indicator = FallbackIndicationElement.fromMessage(message); - String body = message.getBody(); - asyncButOrdered.performAsyncButOrdered(message.getFrom().asBareJid(), () -> { - for (FallbackIndicationListener l : listeners) { - l.onFallbackIndicationReceived(message, indicator, body); - } - }); - } - }; - - private FallbackIndicationManager(XMPPConnection connection) { - super(connection); - connection.addAsyncStanzaListener(fallbackIndicationElementListener, fallbackIndicationElementFilter); - ServiceDiscoveryManager.getInstanceFor(connection).addFeature(FallbackIndicationElement.NAMESPACE); - } - - public static synchronized FallbackIndicationManager getInstanceFor(XMPPConnection connection) { - FallbackIndicationManager manager = INSTANCES.get(connection); - if (manager == null) { - manager = new FallbackIndicationManager(connection); - INSTANCES.put(connection, manager); - } - return manager; - } - - /** - * Determine, whether or not a user supports Fallback Indications. - * - * @param jid BareJid of the user. - * @return feature support - * - * @throws XMPPException.XMPPErrorException if a protocol level error happens - * @throws SmackException.NotConnectedException if the connection is not connected - * @throws InterruptedException if the thread is being interrupted - * @throws SmackException.NoResponseException if the server doesn't send a response in time - */ - public boolean userSupportsFallbackIndications(EntityBareJid jid) - throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, - SmackException.NoResponseException { - return ServiceDiscoveryManager.getInstanceFor(connection()) - .supportsFeature(jid, FallbackIndicationElement.NAMESPACE); - } - - /** - * Determine, whether or not the server supports Fallback Indications. - * - * @return server side feature support - * - * @throws XMPPException.XMPPErrorException if a protocol level error happens - * @throws SmackException.NotConnectedException if the connection is not connected - * @throws InterruptedException if the thread is being interrupted - * @throws SmackException.NoResponseException if the server doesn't send a response in time - */ - public boolean serverSupportsFallbackIndications() - throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, - SmackException.NoResponseException { - return ServiceDiscoveryManager.getInstanceFor(connection()) - .serverSupportsFeature(FallbackIndicationElement.NAMESPACE); - } - - /** - * Set the body of the message to the provided fallback message and add a {@link FallbackIndicationElement}. - * - * @param messageBuilder message builder - * @param fallbackMessageBody fallback message body - * @return builder with set body and added fallback element - */ - public MessageBuilder addFallbackIndicationWithBody(MessageBuilder messageBuilder, String fallbackMessageBody) { - return addFallbackIndication(messageBuilder).setBody(fallbackMessageBody); - } - - /** - * Add a {@link FallbackIndicationElement} to the provided message builder. - * - * @param messageBuilder message builder - * @return message builder with added fallback element - */ - public MessageBuilder addFallbackIndication(MessageBuilder messageBuilder) { - return messageBuilder.addExtension(new FallbackIndicationElement()); - } - - /** - * Register a {@link FallbackIndicationListener} that gets notified whenever a message that contains a - * {@link FallbackIndicationElement} is received. - * - * @param listener listener to be registered. - */ - public synchronized void addFallbackIndicationListener(FallbackIndicationListener listener) { - listeners.add(listener); - } - - /** - * Unregister a {@link FallbackIndicationListener}. - * - * @param listener listener to be unregistered. - */ - public synchronized void removeFallbackIndicationListener(FallbackIndicationListener listener) { - listeners.remove(listener); - } -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/element/FallbackIndicationElement.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/element/FallbackIndicationElement.java deleted file mode 100644 index 96b06fc99..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/element/FallbackIndicationElement.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * - * Copyright 2020 Paul Schaub - * - * 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.jivesoftware.smackx.fallback_indication.element; - -import org.jivesoftware.smack.packet.ExtensionElement; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.XmlEnvironment; -import org.jivesoftware.smack.util.XmlStringBuilder; - -public class FallbackIndicationElement implements ExtensionElement { - - public static final String NAMESPACE = "urn:xmpp:fallback:0"; - public static final String ELEMENT = "fallback"; - - public static final FallbackIndicationElement INSTANCE = new FallbackIndicationElement(); - - @Override - public String getNamespace() { - return NAMESPACE; - } - - @Override - public String getElementName() { - return ELEMENT; - } - - @Override - public XmlStringBuilder toXML(XmlEnvironment xmlEnvironment) { - return new XmlStringBuilder(this).closeEmptyElement(); - } - - public static boolean hasFallbackIndication(Message message) { - return message.hasExtension(ELEMENT, NAMESPACE); - } - - public static FallbackIndicationElement fromMessage(Message message) { - return message.getExtension(FallbackIndicationElement.class); - } -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/element/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/element/package-info.java deleted file mode 100644 index 192654509..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/element/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * - * Copyright 2020 Paul Schaub - * - * 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. - */ - -/** - * Smack's API for XEP-0428: Fallback Indication. - * Extension Elements. - */ -package org.jivesoftware.smackx.fallback_indication.element; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/provider/FallbackIndicationElementProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/provider/FallbackIndicationElementProvider.java deleted file mode 100644 index 66bc9fb9e..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/provider/FallbackIndicationElementProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * - * Copyright 2020 Paul Schaub - * - * 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.jivesoftware.smackx.fallback_indication.provider; - -import java.io.IOException; - -import org.jivesoftware.smack.packet.XmlEnvironment; -import org.jivesoftware.smack.parsing.SmackParsingException; -import org.jivesoftware.smack.provider.ExtensionElementProvider; -import org.jivesoftware.smack.xml.XmlPullParser; -import org.jivesoftware.smack.xml.XmlPullParserException; -import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement; - -public class FallbackIndicationElementProvider extends ExtensionElementProvider { - - @Override - public FallbackIndicationElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) - throws XmlPullParserException, IOException, SmackParsingException { - return FallbackIndicationElement.INSTANCE; - } -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/provider/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/provider/package-info.java deleted file mode 100644 index ea9827989..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/provider/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * - * Copyright 2020 Paul Schaub - * - * 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. - */ - -/** - * Smack's API for XEP-0428: Fallback Indication. - * Element Providers. - */ -package org.jivesoftware.smackx.fallback_indication.provider; diff --git a/smack-experimental/src/main/resources/org.jivesoftware.smack.experimental/experimental.providers b/smack-experimental/src/main/resources/org.jivesoftware.smack.experimental/experimental.providers index d97f52ce5..d594578a4 100644 --- a/smack-experimental/src/main/resources/org.jivesoftware.smack.experimental/experimental.providers +++ b/smack-experimental/src/main/resources/org.jivesoftware.smack.experimental/experimental.providers @@ -299,13 +299,6 @@ org.jivesoftware.smackx.message_fastening.provider.FasteningElementProvider - - - fallback - urn:xmpp:fallback:0 - org.jivesoftware.smackx.fallback_indication.provider.FallbackIndicationElementProvider - - query diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/fallback_indication/FallbackIndicationTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/fallback_indication/FallbackIndicationTest.java deleted file mode 100644 index 342e783b5..000000000 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/fallback_indication/FallbackIndicationTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * Copyright 2020 Paul Schaub - * - * 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.jivesoftware.smackx.fallback_indication; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; - -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.MessageBuilder; - -import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement; - -import org.junit.jupiter.api.Test; - -public class FallbackIndicationTest { - - @Test - public void testFallbackIndicationElementFromMessageTest() { - Message messageWithoutFallback = MessageBuilder.buildMessage() - .build(); - assertNull(FallbackIndicationElement.fromMessage(messageWithoutFallback)); - - Message messageWithFallback = MessageBuilder.buildMessage() - .addExtension(new FallbackIndicationElement()) - .build(); - assertNotNull(FallbackIndicationElement.fromMessage(messageWithFallback)); - } -} diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/ConfigureFormReader.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/ConfigureFormReader.java index 865c3e834..0184c41d8 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/ConfigureFormReader.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/ConfigureFormReader.java @@ -90,7 +90,7 @@ public interface ConfigureFormReader extends FormReader { * @return List of the whitelist */ default List getChildrenAssociationWhitelist() { - FormField formField = getField(ConfigureNodeFields.children_association_whitelist.getFieldName()); + FormField formField = read(ConfigureNodeFields.children_association_whitelist.getFieldName()); if (formField == null) { Collections.emptyList(); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FillableForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FillableForm.java index 62fd32540..be562689f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FillableForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FillableForm.java @@ -39,7 +39,7 @@ import org.jxmpp.jid.util.JidUtil; import org.jxmpp.stringprep.XmppStringprepException; import org.jxmpp.util.XmppDateTime; -public class FillableForm extends FilledForm { +public class FillableForm extends FilledForm implements FormWriter { private final Set requiredFields; @@ -212,6 +212,7 @@ public class FillableForm extends FilledForm { write(filledFormField); } + @Override public final void write(FormField filledFormField) { if (filledFormField.getType() == FormField.Type.fixed) { throw new IllegalArgumentException(); @@ -243,13 +244,13 @@ public class FillableForm extends FilledForm { } @Override - public FormField getField(String fieldName) { + public FormField read(String fieldName) { FormField filledField = filledFields.get(fieldName); if (filledField != null) { return filledField; } - return super.getField(fieldName); + return super.read(fieldName); } public DataForm getDataFormToSubmit() { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FilledForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FilledForm.java index 7624eab80..baa768f39 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FilledForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FilledForm.java @@ -43,7 +43,7 @@ public abstract class FilledForm implements FormReader { } @Override - public FormField getField(String fieldName) { + public FormField read(String fieldName) { return dataForm.getField(fieldName); } @@ -74,6 +74,10 @@ public abstract class FilledForm implements FormReader { return dataForm.hasField(fieldName); } + public FormField getField(String fieldName) { + return dataForm.getField(fieldName); + } + protected FormField getFieldOrThrow(String fieldName) { FormField formField = getField(fieldName); if (formField == null) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FormReader.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FormReader.java index 493abd25a..6a04fff46 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FormReader.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FormReader.java @@ -30,10 +30,10 @@ import org.jxmpp.util.XmppDateTime; public interface FormReader { - FormField getField(String fieldName); + FormField read(String fieldName); default String readFirstValue(String fieldName) { - FormField formField = getField(fieldName); + FormField formField = read(fieldName); if (formField == null) { return null; } @@ -41,7 +41,7 @@ public interface FormReader { } default List readValues(String fieldName) { - FormField formField = getField(fieldName); + FormField formField = read(fieldName); if (formField == null) { return Collections.emptyList(); } @@ -49,7 +49,7 @@ public interface FormReader { } default List readStringValues(String fieldName) { - FormField formField = getField(fieldName); + FormField formField = read(fieldName); if (formField == null) { return Collections.emptyList(); } @@ -58,7 +58,7 @@ public interface FormReader { } default Boolean readBoolean(String fieldName) { - FormField formField = getField(fieldName); + FormField formField = read(fieldName); if (formField == null) { return null; } @@ -67,7 +67,7 @@ public interface FormReader { } default Integer readInteger(String fieldName) { - FormField formField = getField(fieldName); + FormField formField = read(fieldName); if (formField == null) { return null; } @@ -76,7 +76,7 @@ public interface FormReader { } default Date readDate(String fieldName) throws ParseException { - FormField formField = getField(fieldName); + FormField formField = read(fieldName); if (formField == null) { return null; } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/package-info.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FormWriter.java similarity index 74% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/package-info.java rename to smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FormWriter.java index 11dfe6e80..5e4e97cb1 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/fallback_indication/package-info.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FormWriter.java @@ -1,6 +1,6 @@ /** * - * Copyright 2020 Paul Schaub + * Copyright 2020 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.jivesoftware.smackx.xdata.form; -/** - * Smack's API for XEP-0428: Fallback Indication. - */ -package org.jivesoftware.smackx.fallback_indication; +import org.jivesoftware.smackx.xdata.FormField; + +public interface FormWriter { + + void write(FormField field); + +} diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java index f350bb1ab..320acba82 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java @@ -79,25 +79,23 @@ public class ConfigureFormTest extends SmackTestSuite { } @Test - public void getConfigFormWithTimeout() throws XMPPException, InterruptedException, SmackException, IOException { - ThreadedDummyConnection con = ThreadedDummyConnection.newInstance(); + public void getConfigFormWithTimeout() throws XMPPException, InterruptedException { + ThreadedDummyConnection con = new ThreadedDummyConnection(); PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE); - DiscoverInfoBuilder info = DiscoverInfo.builder("disco-result") - .ofType(IQ.Type.result) - .from(PubSubManagerTest.DUMMY_PUBSUB_SERVICE); - + DiscoverInfoBuilder info = DiscoverInfo.builder("disco-result"); Identity ident = new Identity("pubsub", null, "leaf"); info.addIdentity(ident); DiscoverInfo discoverInfo = info.build(); con.addIQReply(discoverInfo); - Node node = mgr.getNode("princely_musings"); - - SmackConfiguration.setDefaultReplyTimeout(100); - con.setTimeout(); - assertThrows(SmackException.class, () -> { + // TODO: This method should not throw any exception but currently does. + Node node = mgr.getNode("princely_musings"); + + SmackConfiguration.setDefaultReplyTimeout(100); + con.setTimeout(); + node.getNodeConfiguration(); }); } diff --git a/smack-openpgp/build.gradle b/smack-openpgp/build.gradle index 23d15a366..b9e90d9c0 100644 --- a/smack-openpgp/build.gradle +++ b/smack-openpgp/build.gradle @@ -10,7 +10,7 @@ dependencies { api 'org.pgpainless:pgpainless-core:0.0.1-alpha11' - testImplementation "org.bouncycastle:bcprov-jdk15on:${bouncyCastleVersion}" + testImplementation "org.bouncycastle:bcprov-jdk15on:1.65" testFixturesApi(testFixtures(project(":smack-core"))) testCompile group: 'commons-io', name: 'commons-io', version: "$commonsIoVersion"