mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
OpenPgpPubSubUtil: Allow custom nodes for secret key backup
This commit is contained in:
parent
1ea73e38cf
commit
079e324fe0
1 changed files with 22 additions and 3 deletions
|
@ -344,11 +344,18 @@ public class OpenPgpPubSubUtil {
|
|||
throws InterruptedException, PubSubException.NotALeafNodeException,
|
||||
XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException,
|
||||
SmackException.FeatureNotSupportedException {
|
||||
depositSecretKey(connection, element, PEP_NODE_SECRET_KEY);
|
||||
}
|
||||
|
||||
public static void depositSecretKey(XMPPConnection connection, SecretkeyElement element, String nodeName)
|
||||
throws SmackException.FeatureNotSupportedException, XMPPException.XMPPErrorException,
|
||||
SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException,
|
||||
PubSubException.NotALeafNodeException {
|
||||
if (!OpenPgpManager.serverSupportsSecretKeyBackups(connection)) {
|
||||
throw new SmackException.FeatureNotSupportedException("http://jabber.org/protocol/pubsub#access-whitelist");
|
||||
}
|
||||
PubSubManager pm = PepManager.getInstanceFor(connection).getPepPubSubManager();
|
||||
LeafNode secretKeyNode = pm.getOrCreateLeafNode(PEP_NODE_SECRET_KEY);
|
||||
LeafNode secretKeyNode = pm.getOrCreateLeafNode(nodeName);
|
||||
OpenPgpPubSubUtil.changeAccessModelIfNecessary(secretKeyNode, AccessModel.whitelist);
|
||||
|
||||
secretKeyNode.publish(new PayloadItem<>(element));
|
||||
|
@ -372,8 +379,14 @@ public class OpenPgpPubSubUtil {
|
|||
public static SecretkeyElement fetchSecretKey(PepManager pepManager)
|
||||
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
|
||||
SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||
return fetchSecretKey(pepManager, PEP_NODE_SECRET_KEY);
|
||||
}
|
||||
|
||||
public static SecretkeyElement fetchSecretKey(PepManager pepManager, String nodeName)
|
||||
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
|
||||
SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||
PubSubManager pm = pepManager.getPepPubSubManager();
|
||||
LeafNode secretKeyNode = pm.getOrCreateLeafNode(PEP_NODE_SECRET_KEY);
|
||||
LeafNode secretKeyNode = pm.getOrCreateLeafNode(nodeName);
|
||||
List<PayloadItem<SecretkeyElement>> list = secretKeyNode.getItems(1);
|
||||
if (list.size() == 0) {
|
||||
LOGGER.log(Level.INFO, "No secret key published!");
|
||||
|
@ -397,8 +410,14 @@ public class OpenPgpPubSubUtil {
|
|||
public static boolean deleteSecretKeyNode(PepManager pepManager)
|
||||
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
|
||||
SmackException.NoResponseException {
|
||||
return deleteSecretKeyNode(pepManager, PEP_NODE_SECRET_KEY);
|
||||
}
|
||||
|
||||
public static boolean deleteSecretKeyNode(PepManager pepManager, String nodeName)
|
||||
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException,
|
||||
InterruptedException, SmackException.NoResponseException {
|
||||
PubSubManager pm = pepManager.getPepPubSubManager();
|
||||
return pm.deleteNode(PEP_NODE_SECRET_KEY);
|
||||
return pm.deleteNode(nodeName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue