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}. *