Add method to delete pubkey node

This commit is contained in:
Paul Schaub 2018-06-22 15:27:25 +02:00
parent 70538ecc90
commit 7b222d8c58
1 changed files with 25 additions and 0 deletions

View File

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