From 7b222d8c5838f276a362bb92a9c38e883f783d8d Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Fri, 22 Jun 2018 15:27:25 +0200 Subject: [PATCH] Add method to delete pubkey node --- .../smackx/ox/util/PubSubDelegate.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/PubSubDelegate.java b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/PubSubDelegate.java index a973788db..822844d57 100644 --- a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/PubSubDelegate.java +++ b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/PubSubDelegate.java @@ -218,6 +218,31 @@ public class PubSubDelegate { } } + /** + * Delete the public key node of the key with fingerprint {@code fingerprint}. + * + * @param connection + * @param fingerprint + * @throws XMPPException.XMPPErrorException + * @throws SmackException.NotConnectedException + * @throws InterruptedException + * @throws SmackException.NoResponseException + */ + public static void deletePublicKeyNode(XMPPConnection connection, OpenPgpV4Fingerprint fingerprint) + throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, + SmackException.NoResponseException { + PubSubManager pm = PubSubManager.getInstance(connection, connection.getUser().asBareJid()); + try { + pm.deleteNode(PEP_NODE_PUBLIC_KEY(fingerprint)); + } catch (XMPPException.XMPPErrorException e) { + if (e.getXMPPError().getCondition() == StanzaError.Condition.item_not_found) { + LOGGER.log(Level.FINE, "Node does not exist. No need to delete it."); + } else { + throw e; + } + } + } + /** * Fetch the OpenPGP public key of a {@code contact}, identified by its OpenPGP {@code v4_fingerprint}. *