mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
Introduce NotAPubSubNodeException
Fixes SMACK-759.
This commit is contained in:
parent
b9ed22c732
commit
772e45da92
8 changed files with 86 additions and 80 deletions
|
@ -39,6 +39,7 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.pubsub.EventElement;
|
import org.jivesoftware.smackx.pubsub.EventElement;
|
||||||
import org.jivesoftware.smackx.pubsub.Item;
|
import org.jivesoftware.smackx.pubsub.Item;
|
||||||
import org.jivesoftware.smackx.pubsub.LeafNode;
|
import org.jivesoftware.smackx.pubsub.LeafNode;
|
||||||
|
import org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException;
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubFeature;
|
import org.jivesoftware.smackx.pubsub.PubSubFeature;
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubManager;
|
import org.jivesoftware.smackx.pubsub.PubSubManager;
|
||||||
import org.jivesoftware.smackx.pubsub.filter.EventExtensionFilter;
|
import org.jivesoftware.smackx.pubsub.filter.EventExtensionFilter;
|
||||||
|
@ -137,9 +138,10 @@ public final class PEPManager extends Manager {
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws XMPPErrorException
|
* @throws XMPPErrorException
|
||||||
* @throws NoResponseException
|
* @throws NoResponseException
|
||||||
|
* @throws NotAPubSubNodeException
|
||||||
*/
|
*/
|
||||||
public void publish(Item item, String node) throws NotConnectedException, InterruptedException,
|
public void publish(Item item, String node) throws NotConnectedException, InterruptedException,
|
||||||
NoResponseException, XMPPErrorException {
|
NoResponseException, XMPPErrorException, NotAPubSubNodeException {
|
||||||
XMPPConnection connection = connection();
|
XMPPConnection connection = connection();
|
||||||
PubSubManager pubSubManager = PubSubManager.getInstance(connection, connection.getUser().asEntityBareJid());
|
PubSubManager pubSubManager = PubSubManager.getInstance(connection, connection.getUser().asEntityBareJid());
|
||||||
LeafNode pubSubNode = pubSubManager.getNode(node);
|
LeafNode pubSubNode = pubSubManager.getNode(node);
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2017 Florian Schmaus
|
|
||||||
*
|
|
||||||
* 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.pubsub;
|
|
||||||
|
|
||||||
import org.jxmpp.jid.BareJid;
|
|
||||||
|
|
||||||
public abstract class PubSubAssertionError extends AssertionError {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
protected PubSubAssertionError(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DiscoInfoNodeAssertionError extends PubSubAssertionError {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
DiscoInfoNodeAssertionError(BareJid pubSubService, String nodeId) {
|
|
||||||
super("PubSub service '" + pubSubService + "' returned disco info result for node '" + nodeId
|
|
||||||
+ "', but it did not contain an Identity of type 'leaf' or 'collection' (and category 'pubsub'), which is not allowed according to XEP-60 5.3.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.pubsub;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||||
|
|
||||||
import org.jxmpp.jid.BareJid;
|
import org.jxmpp.jid.BareJid;
|
||||||
|
|
||||||
public abstract class PubSubException extends SmackException {
|
public abstract class PubSubException extends SmackException {
|
||||||
|
@ -27,6 +29,16 @@ public abstract class PubSubException extends SmackException {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final String nodeId;
|
||||||
|
|
||||||
|
protected PubSubException(String nodeId) {
|
||||||
|
this.nodeId = nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNodeId() {
|
||||||
|
return nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
public static class NotALeafNodeException extends PubSubException {
|
public static class NotALeafNodeException extends PubSubException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,21 +46,35 @@ public abstract class PubSubException extends SmackException {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final String nodeId;
|
|
||||||
private final BareJid pubSubService;
|
private final BareJid pubSubService;
|
||||||
|
|
||||||
NotALeafNodeException(String nodeId, BareJid pubSubService) {
|
NotALeafNodeException(String nodeId, BareJid pubSubService) {
|
||||||
this.nodeId = nodeId;
|
super(nodeId);
|
||||||
this.pubSubService = pubSubService;
|
this.pubSubService = pubSubService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNodeId() {
|
|
||||||
return nodeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BareJid getPubSubService() {
|
public BareJid getPubSubService() {
|
||||||
return pubSubService;
|
return pubSubService;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class NotAPubSubNodeException extends PubSubException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final DiscoverInfo discoverInfo;
|
||||||
|
|
||||||
|
NotAPubSubNodeException(String nodeId, DiscoverInfo discoverInfo) {
|
||||||
|
super(nodeId);
|
||||||
|
this.discoverInfo = discoverInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiscoverInfo getDiscoverInfo() {
|
||||||
|
return discoverInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException;
|
import org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException;
|
||||||
|
import org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException;
|
||||||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||||
import org.jivesoftware.smackx.pubsub.util.NodeUtils;
|
import org.jivesoftware.smackx.pubsub.util.NodeUtils;
|
||||||
|
@ -229,8 +230,9 @@ public final class PubSubManager extends Manager {
|
||||||
* @throws NoResponseException if there was no response from the server.
|
* @throws NoResponseException if there was no response from the server.
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @throws NotAPubSubNodeException
|
||||||
*/
|
*/
|
||||||
public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAPubSubNodeException
|
||||||
{
|
{
|
||||||
Node node = nodeMap.get(id);
|
Node node = nodeMap.get(id);
|
||||||
|
|
||||||
|
@ -249,10 +251,7 @@ public final class PubSubManager extends Manager {
|
||||||
node = new CollectionNode(this, id);
|
node = new CollectionNode(this, id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// XEP-60 5.3 states that
|
throw new PubSubException.NotAPubSubNodeException(id, infoReply);
|
||||||
// "The 'disco#info' result MUST include an identity with a category of 'pubsub' and a type of either 'leaf' or 'collection'."
|
|
||||||
// If this is not the case, then we are dealing with an PubSub implementation that doesn't follow the specification.
|
|
||||||
throw new PubSubAssertionError.DiscoInfoNodeAssertionError(pubSubService, id);
|
|
||||||
}
|
}
|
||||||
nodeMap.put(id, node);
|
nodeMap.put(id, node);
|
||||||
}
|
}
|
||||||
|
@ -278,6 +277,9 @@ public final class PubSubManager extends Manager {
|
||||||
try {
|
try {
|
||||||
return getNode(id);
|
return getNode(id);
|
||||||
}
|
}
|
||||||
|
catch (NotAPubSubNodeException e) {
|
||||||
|
return createNode(id);
|
||||||
|
}
|
||||||
catch (XMPPErrorException e1) {
|
catch (XMPPErrorException e1) {
|
||||||
if (e1.getXMPPError().getCondition() == Condition.item_not_found) {
|
if (e1.getXMPPError().getCondition() == Condition.item_not_found) {
|
||||||
try {
|
try {
|
||||||
|
@ -286,7 +288,13 @@ public final class PubSubManager extends Manager {
|
||||||
catch (XMPPErrorException e2) {
|
catch (XMPPErrorException e2) {
|
||||||
if (e2.getXMPPError().getCondition() == Condition.conflict) {
|
if (e2.getXMPPError().getCondition() == Condition.conflict) {
|
||||||
// The node was created in the meantime, re-try getNode(). Note that this case should be rare.
|
// The node was created in the meantime, re-try getNode(). Note that this case should be rare.
|
||||||
return getNode(id);
|
try {
|
||||||
|
return getNode(id);
|
||||||
|
}
|
||||||
|
catch (NotAPubSubNodeException e) {
|
||||||
|
// Should not happen
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw e2;
|
throw e2;
|
||||||
}
|
}
|
||||||
|
@ -313,10 +321,11 @@ public final class PubSubManager extends Manager {
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws XMPPErrorException
|
* @throws XMPPErrorException
|
||||||
|
* @throws NotAPubSubNodeException
|
||||||
* @since 4.2.1
|
* @since 4.2.1
|
||||||
*/
|
*/
|
||||||
public LeafNode getLeafNode(String id) throws NotALeafNodeException, NoResponseException, NotConnectedException,
|
public LeafNode getLeafNode(String id) throws NotALeafNodeException, NoResponseException, NotConnectedException,
|
||||||
InterruptedException, XMPPErrorException {
|
InterruptedException, XMPPErrorException, NotAPubSubNodeException {
|
||||||
Node node;
|
Node node;
|
||||||
try {
|
try {
|
||||||
node = getNode(id);
|
node = getNode(id);
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||||
import org.jivesoftware.smackx.omemo.util.OmemoConstants;
|
import org.jivesoftware.smackx.omemo.util.OmemoConstants;
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubException;
|
import org.jivesoftware.smackx.pubsub.PubSubException;
|
||||||
|
import org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException;
|
||||||
|
|
||||||
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
||||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||||
|
@ -52,9 +53,10 @@ public class OmemoInitializationTest extends AbstractOmemoIntegrationTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests, if the initialization is done properly.
|
* Tests, if the initialization is done properly.
|
||||||
|
* @throws NotAPubSubNodeException
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@SmackIntegrationTest
|
||||||
public void initializationTest() throws XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, SmackException.NotLoggedInException, CorruptedOmemoKeyException {
|
public void initializationTest() throws XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, SmackException.NotLoggedInException, CorruptedOmemoKeyException, NotAPubSubNodeException {
|
||||||
//test keys.
|
//test keys.
|
||||||
setUpOmemoManager(alice);
|
setUpOmemoManager(alice);
|
||||||
assertNotNull("IdentityKey must not be null after initialization.", store.loadOmemoIdentityKeyPair(alice));
|
assertNotNull("IdentityKey must not be null after initialization.", store.loadOmemoIdentityKeyPair(alice));
|
||||||
|
|
|
@ -34,8 +34,8 @@ import org.jivesoftware.smackx.omemo.exceptions.CannotEstablishOmemoSessionExcep
|
||||||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||||
import org.jivesoftware.smackx.omemo.internal.CachedDeviceList;
|
import org.jivesoftware.smackx.omemo.internal.CachedDeviceList;
|
||||||
import org.jivesoftware.smackx.omemo.util.OmemoConstants;
|
import org.jivesoftware.smackx.omemo.util.OmemoConstants;
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubAssertionError;
|
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubException;
|
import org.jivesoftware.smackx.pubsub.PubSubException;
|
||||||
|
import org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException;
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubManager;
|
import org.jivesoftware.smackx.pubsub.PubSubManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,26 +70,26 @@ final class OmemoIntegrationTestHelper {
|
||||||
for (int id : deviceList.getAllDevices()) {
|
for (int id : deviceList.getAllDevices()) {
|
||||||
try {
|
try {
|
||||||
pm.getLeafNode(OmemoConstants.PEP_NODE_BUNDLE_FROM_DEVICE_ID(id)).deleteAllItems();
|
pm.getLeafNode(OmemoConstants.PEP_NODE_BUNDLE_FROM_DEVICE_ID(id)).deleteAllItems();
|
||||||
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | PubSubException.NotALeafNodeException | XMPPException.XMPPErrorException | PubSubAssertionError.DiscoInfoNodeAssertionError e) {
|
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | PubSubException.NotALeafNodeException | XMPPException.XMPPErrorException | NotAPubSubNodeException e) {
|
||||||
//Silent
|
//Silent
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pm.deleteNode(OmemoConstants.PEP_NODE_BUNDLE_FROM_DEVICE_ID(id));
|
pm.deleteNode(OmemoConstants.PEP_NODE_BUNDLE_FROM_DEVICE_ID(id));
|
||||||
} catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException | XMPPException.XMPPErrorException | PubSubAssertionError e) {
|
} catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) {
|
||||||
//Silent
|
//Silent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pm.getLeafNode(OmemoConstants.PEP_NODE_DEVICE_LIST).deleteAllItems();
|
pm.getLeafNode(OmemoConstants.PEP_NODE_DEVICE_LIST).deleteAllItems();
|
||||||
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | PubSubException.NotALeafNodeException | XMPPException.XMPPErrorException | PubSubAssertionError.DiscoInfoNodeAssertionError e) {
|
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | PubSubException.NotALeafNodeException | XMPPException.XMPPErrorException | NotAPubSubNodeException e) {
|
||||||
//Silent
|
//Silent
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pm.deleteNode(OmemoConstants.PEP_NODE_DEVICE_LIST);
|
pm.deleteNode(OmemoConstants.PEP_NODE_DEVICE_LIST);
|
||||||
} catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException | XMPPException.XMPPErrorException | PubSubAssertionError e) {
|
} catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) {
|
||||||
//Silent
|
//Silent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ final class OmemoIntegrationTestHelper {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setUpOmemoManager(OmemoManager omemoManager) throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, SmackException.NotLoggedInException, PubSubException.NotALeafNodeException {
|
static void setUpOmemoManager(OmemoManager omemoManager) throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, SmackException.NotLoggedInException, PubSubException.NotALeafNodeException, NotAPubSubNodeException {
|
||||||
omemoManager.initialize();
|
omemoManager.initialize();
|
||||||
OmemoBundleElement bundle = OmemoService.fetchBundle(omemoManager, omemoManager.getOwnDevice());
|
OmemoBundleElement bundle = OmemoService.fetchBundle(omemoManager, omemoManager.getOwnDevice());
|
||||||
assertNotNull("Bundle must not be null.", bundle);
|
assertNotNull("Bundle must not be null.", bundle);
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.jivesoftware.smackx.omemo.internal.CipherAndAuthTag;
|
||||||
import org.jivesoftware.smackx.omemo.internal.OmemoMessageInformation;
|
import org.jivesoftware.smackx.omemo.internal.OmemoMessageInformation;
|
||||||
import org.jivesoftware.smackx.omemo.listener.OmemoMessageListener;
|
import org.jivesoftware.smackx.omemo.listener.OmemoMessageListener;
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubException;
|
import org.jivesoftware.smackx.pubsub.PubSubException;
|
||||||
|
import org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
||||||
|
@ -85,9 +86,15 @@ public class OmemoMessageSendingTest extends AbstractOmemoIntegrationTest {
|
||||||
* @throws UndecidedOmemoIdentityException
|
* @throws UndecidedOmemoIdentityException
|
||||||
* @throws NoSuchAlgorithmException
|
* @throws NoSuchAlgorithmException
|
||||||
* @throws CryptoFailedException
|
* @throws CryptoFailedException
|
||||||
|
* @throws NotAPubSubNodeException
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@SmackIntegrationTest
|
||||||
public void messageSendingTest() throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, SmackException.NotLoggedInException, PubSubException.NotALeafNodeException, CannotEstablishOmemoSessionException, UndecidedOmemoIdentityException, NoSuchAlgorithmException, CryptoFailedException {
|
public void messageSendingTest()
|
||||||
|
throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException,
|
||||||
|
SmackException.NotConnectedException, XMPPException.XMPPErrorException,
|
||||||
|
SmackException.NotLoggedInException, PubSubException.NotALeafNodeException,
|
||||||
|
CannotEstablishOmemoSessionException, UndecidedOmemoIdentityException, NoSuchAlgorithmException,
|
||||||
|
CryptoFailedException, PubSubException.NotAPubSubNodeException {
|
||||||
final String alicesSecret = "Hey Bob! I love you!";
|
final String alicesSecret = "Hey Bob! I love you!";
|
||||||
final String bobsSecret = "I love you too, Alice."; //aww <3
|
final String bobsSecret = "I love you too, Alice."; //aww <3
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,8 @@ import org.jivesoftware.smackx.omemo.util.OmemoMessageBuilder;
|
||||||
import org.jivesoftware.smackx.pep.PEPManager;
|
import org.jivesoftware.smackx.pep.PEPManager;
|
||||||
import org.jivesoftware.smackx.pubsub.LeafNode;
|
import org.jivesoftware.smackx.pubsub.LeafNode;
|
||||||
import org.jivesoftware.smackx.pubsub.PayloadItem;
|
import org.jivesoftware.smackx.pubsub.PayloadItem;
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubAssertionError;
|
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubException;
|
import org.jivesoftware.smackx.pubsub.PubSubException;
|
||||||
|
import org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException;
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubManager;
|
import org.jivesoftware.smackx.pubsub.PubSubManager;
|
||||||
|
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
@ -428,11 +428,11 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
||||||
* @throws XMPPException.XMPPErrorException
|
* @throws XMPPException.XMPPErrorException
|
||||||
* @throws SmackException.NotConnectedException
|
* @throws SmackException.NotConnectedException
|
||||||
* @throws SmackException.NoResponseException
|
* @throws SmackException.NoResponseException
|
||||||
* @throws PubSubAssertionError.DiscoInfoNodeAssertionError ejabberd bug: https://github.com/processone/ejabberd/issues/1717
|
* @throws NotAPubSubNodeException
|
||||||
*/
|
*/
|
||||||
static LeafNode fetchDeviceListNode(OmemoManager omemoManager, BareJid contact)
|
static LeafNode fetchDeviceListNode(OmemoManager omemoManager, BareJid contact)
|
||||||
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
|
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
|
||||||
SmackException.NotConnectedException, SmackException.NoResponseException, PubSubAssertionError.DiscoInfoNodeAssertionError {
|
SmackException.NotConnectedException, SmackException.NoResponseException, NotAPubSubNodeException {
|
||||||
return PubSubManager.getInstance(omemoManager.getConnection(), contact).getLeafNode(PEP_NODE_DEVICE_LIST);
|
return PubSubManager.getInstance(omemoManager.getConnection(), contact).getLeafNode(PEP_NODE_DEVICE_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,9 +447,11 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
||||||
* @throws InterruptedException goes
|
* @throws InterruptedException goes
|
||||||
* @throws SmackException.NoResponseException wrong
|
* @throws SmackException.NoResponseException wrong
|
||||||
* @throws PubSubException.NotALeafNodeException when the device lists node is not a LeafNode
|
* @throws PubSubException.NotALeafNodeException when the device lists node is not a LeafNode
|
||||||
* @throws PubSubAssertionError.DiscoInfoNodeAssertionError ejabberd bug: https://github.com/processone/ejabberd/issues/1717
|
* @throws NotAPubSubNodeException
|
||||||
*/
|
*/
|
||||||
static OmemoDeviceListElement fetchDeviceList(OmemoManager omemoManager, BareJid contact) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, PubSubException.NotALeafNodeException, PubSubAssertionError.DiscoInfoNodeAssertionError {
|
static OmemoDeviceListElement fetchDeviceList(OmemoManager omemoManager, BareJid contact)
|
||||||
|
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
|
||||||
|
SmackException.NoResponseException, PubSubException.NotALeafNodeException, NotAPubSubNodeException {
|
||||||
return extractDeviceListFrom(fetchDeviceListNode(omemoManager, contact));
|
return extractDeviceListFrom(fetchDeviceListNode(omemoManager, contact));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,9 +485,9 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
||||||
e.getMessage());
|
e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (PubSubAssertionError.DiscoInfoNodeAssertionError bug) {
|
catch (PubSubException.NotAPubSubNodeException e) {
|
||||||
LOGGER.log(Level.WARNING, "Caught a PubSubAssertionError when fetching a deviceList node. " +
|
LOGGER.log(Level.WARNING, "Caught a PubSubAssertionError when fetching a deviceList node. " +
|
||||||
"This probably means that we're dealing with an ejabberd server and the LeafNode does not exist.");
|
"This probably means that we're dealing with an ejabberd server and the LeafNode does not exist.", e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -507,9 +509,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
||||||
LOGGER.log(Level.WARNING, "Could not fetch device list of " + contact + ": " + e, e);
|
LOGGER.log(Level.WARNING, "Could not fetch device list of " + contact + ": " + e, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (PubSubAssertionError.DiscoInfoNodeAssertionError bug) {
|
catch (NotAPubSubNodeException e) {
|
||||||
LOGGER.log(Level.WARNING, "Caught a PubSubAssertionError when fetching a deviceList node. " +
|
LOGGER.log(Level.WARNING, "Could not fetch device list of " + contact ,e);
|
||||||
"This probably means that the LeafNode does not exist.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,9 +528,13 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
||||||
* @throws InterruptedException goes
|
* @throws InterruptedException goes
|
||||||
* @throws SmackException.NoResponseException wrong
|
* @throws SmackException.NoResponseException wrong
|
||||||
* @throws PubSubException.NotALeafNodeException when the bundles node is not a LeafNode
|
* @throws PubSubException.NotALeafNodeException when the bundles node is not a LeafNode
|
||||||
|
* @throws NotAPubSubNodeException
|
||||||
*/
|
*/
|
||||||
static OmemoBundleVAxolotlElement fetchBundle(OmemoManager omemoManager, OmemoDevice contact) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, PubSubException.NotALeafNodeException, PubSubAssertionError.DiscoInfoNodeAssertionError {
|
static OmemoBundleVAxolotlElement fetchBundle(OmemoManager omemoManager, OmemoDevice contact)
|
||||||
LeafNode node = PubSubManager.getInstance(omemoManager.getConnection(), contact.getJid()).getLeafNode(PEP_NODE_BUNDLE_FROM_DEVICE_ID(contact.getDeviceId()));
|
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
|
||||||
|
SmackException.NoResponseException, PubSubException.NotALeafNodeException, NotAPubSubNodeException {
|
||||||
|
LeafNode node = PubSubManager.getInstance(omemoManager.getConnection(), contact.getJid()).getLeafNode(
|
||||||
|
PEP_NODE_BUNDLE_FROM_DEVICE_ID(contact.getDeviceId()));
|
||||||
return extractBundleFrom(node);
|
return extractBundleFrom(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +671,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
||||||
OmemoBundleVAxolotlElement bundle;
|
OmemoBundleVAxolotlElement bundle;
|
||||||
try {
|
try {
|
||||||
bundle = fetchBundle(omemoManager, device);
|
bundle = fetchBundle(omemoManager, device);
|
||||||
} catch (SmackException | XMPPException.XMPPErrorException | InterruptedException | PubSubAssertionError e) {
|
} catch (SmackException | XMPPException.XMPPErrorException | InterruptedException e) {
|
||||||
throw new CannotEstablishOmemoSessionException(device, e);
|
throw new CannotEstablishOmemoSessionException(device, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue