private LeafNode getNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotALeafNodeException { return PubSubManager.getInstance(connection()).getOrCreateLeafNode(GeoLocation.NAMESPACE); }
/** * Fetch the latest {@link SecretkeyElement} from the private backup node. * * @see <a href="https://xmpp.org/extensions/xep-0373.html#synchro-pep"> * XEP-0373 §5. Synchronizing the Secret Key with a Private PEP Node</a> * * @param pepManager the PEP manager. * @return the secret key node or null, if it doesn't exist. * * @throws InterruptedException if the thread gets interrupted * @throws PubSubException.NotALeafNodeException if there is an issue with the PubSub node * @throws XMPPException.XMPPErrorException if there is an XMPP protocol related issue * @throws SmackException.NotConnectedException if we are not connected * @throws SmackException.NoResponseException /watch?v=7U0FzQzJzyI */ public static SecretkeyElement fetchSecretKey(PepManager pepManager) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { PubSubManager pm = pepManager.getPepPubSubManager(); LeafNode secretKeyNode = pm.getOrCreateLeafNode(PEP_NODE_SECRET_KEY); List<PayloadItem<SecretkeyElement>> list = secretKeyNode.getItems(1); if (list.size() == 0) { LOGGER.log(Level.INFO, "No secret key published!"); return null; } SecretkeyElement secretkeyElement = list.get(0).getPayload(); return secretkeyElement; }
LeafNode keyNode = pm.getOrCreateLeafNode(keyNodeName); changeAccessModelIfNecessary(keyNode, AccessModel.open); List<Item> items = keyNode.getItems(1); LeafNode metadataNode = pm.getOrCreateLeafNode(PEP_NODE_PUBLIC_KEYS); changeAccessModelIfNecessary(metadataNode, AccessModel.open); List<PayloadItem<PublicKeysListElement>> metadataItems = metadataNode.getItems(1);
private void publishMood(MoodElement moodElement) throws SmackException.NotLoggedInException, InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { if (pubSubManager == null) { pubSubManager = PubSubManager.getInstance(getAuthenticatedConnectionOrThrow(), connection().getUser().asBareJid()); } LeafNode node = pubSubManager.getOrCreateLeafNode(MOOD_NODE); node.publish(new PayloadItem<>(moodElement)); }
/** * Publishes a {@link SecretkeyElement} to the secret key node. * The node will be configured to use the whitelist access model to prevent access from subscribers. * * @see <a href="https://xmpp.org/extensions/xep-0373.html#synchro-pep"> * XEP-0373 §5. Synchronizing the Secret Key with a Private PEP Node</a> * * @param connection {@link XMPPConnection} of the user * @param element a {@link SecretkeyElement} containing the encrypted secret key of the user * * @throws InterruptedException if the thread gets interrupted. * @throws PubSubException.NotALeafNodeException if something is wrong with the PubSub node * @throws XMPPException.XMPPErrorException in case of an protocol related error * @throws SmackException.NotConnectedException if we are not connected * @throws SmackException.NoResponseException /watch?v=0peBq89ZTrc * @throws SmackException.FeatureNotSupportedException if the Server doesn't support the whitelist access model */ public static void depositSecretKey(XMPPConnection connection, SecretkeyElement element) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, SmackException.FeatureNotSupportedException { 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); OpenPgpPubSubUtil.changeAccessModelIfNecessary(secretKeyNode, AccessModel.whitelist); secretKeyNode.publish(new PayloadItem<>(element)); }