From 48a46e43ab73e4ee68894bcc23f0c2ed967b51a1 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 5 Nov 2016 18:26:44 +0100 Subject: [PATCH] Use bare JID when using FriendshipDeniedCache As it only contains bare JIDs. --- .../iot/provisioning/IoTProvisioningManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java index 1ef6a6811..349296379 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java @@ -142,7 +142,9 @@ public final class IoTProvisioningManager extends Manager { } }, UNFRIEND_MESSAGE); - // Stanza listener for XEP-0324 § 3.2.4. + // Stanza listener for XEP-0324 § 3.2.4 "Recommending Friendships". + // Also includes business logic for thing-to-thing friendship recommendations, which is not + // (yet) part of the XEP. connection.addAsyncStanzaListener(new StanzaListener() { @Override public void processPacket(final Stanza stanza) throws NotConnectedException, InterruptedException { @@ -163,12 +165,14 @@ public final class IoTProvisioningManager extends Manager { // tried to become friends with. If this is the case, then // thing is likely telling us that we can become now // friends. - Jid from = friendMessage.getFrom(); - if (!friendshipDeniedCache.containsKey(from)) { + BareJid bareFrom = friendMessage.getFrom().asBareJid(); + if (!friendshipDeniedCache.containsKey(bareFrom)) { + LOGGER.log(Level.WARNING, "Ignoring friendship recommendation " + + friendMessage + + " because friendship to this JID was not previously denied."); return; } - BareJid bareFrom = from.asBareJid(); // Sanity check: If a thing recommends us itself as friend, // which should be the case once we reach this code, then // the bare 'from' JID should be equals to the JID of the