Package org.jivesoftware.smackx.ox.util
Class OpenPgpPubSubUtil
java.lang.Object
org.jivesoftware.smackx.ox.util.OpenPgpPubSubUtil
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name of the OX metadata node.static final String
Feature to be announced using theServiceDiscoveryManager
to subscribe to the OX metadata node.static final String
Name of the OX secret key node. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
changeAccessModelIfNecessary
(LeafNode node, AccessModel accessModel) Query the access model ofnode
.static boolean
deletePubkeysListNode
(PepManager pepManager) Delete our metadata node.static boolean
deletePublicKeyNode
(PepManager pepManager, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) Delete the public key node of the key with fingerprintfingerprint
.static boolean
deleteSecretKeyNode
(PepManager pepManager) Delete the private backup node.static void
depositSecretKey
(XMPPConnection connection, SecretkeyElement element) Publishes aSecretkeyElement
to the secret key node.static PubkeyElement
fetchPubkey
(XMPPConnection connection, BareJid contact, org.pgpainless.key.OpenPgpV4Fingerprint v4_fingerprint) Fetch the OpenPGP public key of acontact
, identified by its OpenPGPv4_fingerprint
.static PublicKeysListElement
fetchPubkeysList
(XMPPConnection connection) Consult the public key metadata node and fetch a list of all of our published OpenPGP public keys.static PublicKeysListElement
fetchPubkeysList
(XMPPConnection connection, BareJid contact) Consult the public key metadata node ofcontact
to fetch the list of their published OpenPGP public keys.static SecretkeyElement
fetchSecretKey
(PepManager pepManager) Fetch the latestSecretkeyElement
from the private backup node.static LeafNode
getOpenLeafNode
(PubSubManager pubSubManager, String nodeName) Use reflection magic to get aLeafNode
without doing a disco#info query.static String
PEP_NODE_PUBLIC_KEY
(org.pgpainless.key.OpenPgpV4Fingerprint id) Name of the OX public key node, which contains the key with idid
.static void
publishPublicKey
(PepManager pepManager, PubkeyElement pubkeyElement, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) Publish the users OpenPGP public key to the public key node if necessary.
-
Field Details
-
PEP_NODE_PUBLIC_KEYS
Name of the OX metadata node.- See Also:
-
PEP_NODE_SECRET_KEY
Name of the OX secret key node.- See Also:
-
PEP_NODE_PUBLIC_KEYS_NOTIFY
Feature to be announced using theServiceDiscoveryManager
to subscribe to the OX metadata node.- See Also:
-
-
Constructor Details
-
OpenPgpPubSubUtil
public OpenPgpPubSubUtil()
-
-
Method Details
-
PEP_NODE_PUBLIC_KEY
Name of the OX public key node, which contains the key with idid
.- Parameters:
id
- upper case hex encoded OpenPGP v4 fingerprint of the key.- Returns:
- PEP node name.
-
changeAccessModelIfNecessary
public static void changeAccessModelIfNecessary(LeafNode node, AccessModel accessModel) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException Query the access model ofnode
. If it is different fromaccessModel
, change the access model of the node toaccessModel
.- Parameters:
node
-LeafNode
whose PubSub access model we want to changeaccessModel
- new access model.- Throws:
XMPPException.XMPPErrorException
- in case of an XMPP protocol error.SmackException.NotConnectedException
- if we are not connected.InterruptedException
- if the thread is interrupted.SmackException.NoResponseException
- if the server doesn't respond.- See Also:
-
publishPublicKey
public static void publishPublicKey(PepManager pepManager, PubkeyElement pubkeyElement, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException Publish the users OpenPGP public key to the public key node if necessary. Also announce the key to other users by updating the metadata node.- Parameters:
pepManager
- The PEP manager.pubkeyElement
-PubkeyElement
containing the public keyfingerprint
- fingerprint of the public key- Throws:
InterruptedException
- if the thread gets interrupted.PubSubException.NotALeafNodeException
- if either the metadata node or the public key node is not aLeafNode
.XMPPException.XMPPErrorException
- in case of an XMPP protocol error.SmackException.NotConnectedException
- if we are not connected.SmackException.NoResponseException
- if the server doesn't respond.- See Also:
-
fetchPubkeysList
public static PublicKeysListElement fetchPubkeysList(XMPPConnection connection) throws InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException, PubSubException.NotALeafNodeException, SmackException.NotConnectedException, SmackException.NoResponseException Consult the public key metadata node and fetch a list of all of our published OpenPGP public keys.- Parameters:
connection
- XMPP connection- Returns:
- content of our metadata node.
- Throws:
InterruptedException
- if the thread gets interrupted.XMPPException.XMPPErrorException
- in case of an XMPP protocol exception.PubSubException.NotAPubSubNodeException
- in case the queried entity is not a PubSub nodePubSubException.NotALeafNodeException
- in case the queried node is not aLeafNode
SmackException.NotConnectedException
- in case we are not connectedSmackException.NoResponseException
- in case the server doesn't respond- See Also:
-
fetchPubkeysList
public static PublicKeysListElement fetchPubkeysList(XMPPConnection connection, BareJid contact) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException, PubSubException.NotALeafNodeException, SmackException.NotConnectedException, PubSubException.NotAPubSubNodeException Consult the public key metadata node ofcontact
to fetch the list of their published OpenPGP public keys.- Parameters:
connection
- XMPP connectioncontact
-BareJid
of the user we want to fetch the list from.- Returns:
- content of
contact
's metadata node. - Throws:
InterruptedException
- if the thread gets interrupted.XMPPException.XMPPErrorException
- in case of an XMPP protocol exception.SmackException.NoResponseException
- in case the server doesn't respondPubSubException.NotALeafNodeException
- in case the queried node is not aLeafNode
SmackException.NotConnectedException
- in case we are not connectedPubSubException.NotAPubSubNodeException
- in case the queried entity is not a PubSub node- See Also:
-
deletePubkeysListNode
public static boolean deletePubkeysListNode(PepManager pepManager) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException Delete our metadata node.- Parameters:
pepManager
- The PEP manager.- Returns:
true
if the node existed and was deleted,false
if the node did not exist.- Throws:
XMPPException.XMPPErrorException
- in case of an XMPP protocol error.SmackException.NotConnectedException
- if we are not connected.InterruptedException
- if the thread is interrupted.SmackException.NoResponseException
- if the server doesn't respond.
-
deletePublicKeyNode
public static boolean deletePublicKeyNode(PepManager pepManager, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException Delete the public key node of the key with fingerprintfingerprint
.- Parameters:
pepManager
- The PEP manager.fingerprint
- fingerprint of the key we want to delete- Returns:
true
if the node existed and was deleted,false
if the node did not exist.- Throws:
XMPPException.XMPPErrorException
- in case of an XMPP protocol error.SmackException.NotConnectedException
- if we are not connected.InterruptedException
- if the thread gets interrupted.SmackException.NoResponseException
- if the server doesn't respond.
-
fetchPubkey
public static PubkeyElement fetchPubkey(XMPPConnection connection, BareJid contact, org.pgpainless.key.OpenPgpV4Fingerprint v4_fingerprint) throws InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException, PubSubException.NotALeafNodeException, SmackException.NotConnectedException, SmackException.NoResponseException Fetch the OpenPGP public key of acontact
, identified by its OpenPGPv4_fingerprint
.- Parameters:
connection
- XMPP connectioncontact
-BareJid
of the contact we want to fetch a key from.v4_fingerprint
- upper case, hex encoded v4 fingerprint of the contacts key.- Returns:
PubkeyElement
containing the requested public key.- Throws:
InterruptedException
- if the thread gets interrupted.AXMPPException.XMPPErrorException
- in case of an XMPP protocol error.PubSubException.NotAPubSubNodeException
- in case the targeted entity is not a PubSub node.PubSubException.NotALeafNodeException
- in case the fetched node is not aLeafNode
.SmackException.NotConnectedException
- in case we are not connected.SmackException.NoResponseException
- if the server doesn't respond.- See Also:
-
depositSecretKey
public static void depositSecretKey(XMPPConnection connection, SecretkeyElement element) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, SmackException.FeatureNotSupportedException Publishes aSecretkeyElement
to the secret key node. The node will be configured to use the whitelist access model to prevent access from subscribers.- Parameters:
connection
-XMPPConnection
of the userelement
- aSecretkeyElement
containing the encrypted secret key of the user- Throws:
InterruptedException
- if the thread gets interrupted.PubSubException.NotALeafNodeException
- if something is wrong with the PubSub nodeXMPPException.XMPPErrorException
- in case of an protocol related errorSmackException.NotConnectedException
- if we are not connectedSmackException.NoResponseException
- /watch?v=0peBq89ZTrcSmackException.FeatureNotSupportedException
- if the Server doesn't support the whitelist access model- See Also:
-
fetchSecretKey
public static SecretkeyElement fetchSecretKey(PepManager pepManager) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException Fetch the latestSecretkeyElement
from the private backup node.- Parameters:
pepManager
- the PEP manager.- Returns:
- the secret key node or null, if it doesn't exist.
- Throws:
InterruptedException
- if the thread gets interruptedPubSubException.NotALeafNodeException
- if there is an issue with the PubSub nodeXMPPException.XMPPErrorException
- if there is an XMPP protocol related issueSmackException.NotConnectedException
- if we are not connectedSmackException.NoResponseException
- /watch?v=7U0FzQzJzyI- See Also:
-
deleteSecretKeyNode
public static boolean deleteSecretKeyNode(PepManager pepManager) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException Delete the private backup node.- Parameters:
pepManager
- the PEP manager.- Returns:
true
if the node existed and was deleted,false
if the node did not exist.- Throws:
XMPPException.XMPPErrorException
- if there is an XMPP protocol related issueSmackException.NotConnectedException
- if we are not connectedInterruptedException
- if the thread gets interruptedSmackException.NoResponseException
- if the server sends no response
-
getOpenLeafNode
public static LeafNode getOpenLeafNode(PubSubManager pubSubManager, String nodeName) throws PubSubException.NotALeafNodeException Use reflection magic to get aLeafNode
without doing a disco#info query. This method is useful for fetching nodes that are configured with the access model 'open', since some servers that announce support for that access model do not allow disco#info queries from contacts which are not subscribed to the node owner. Therefore this method fetches the node directly and puts it into thePubSubManager
s node map. Note: Due to the lack of a disco#info query, it might happen, that the node doesn't exist on the server, even though we add it to the node map.- Parameters:
pubSubManager
- pubsub managernodeName
- name of the node- Returns:
- leafNode TODO javadoc me please
- Throws:
PubSubException.NotALeafNodeException
- in case we already have the node cached, but it is not a LeafNode.- See Also:
-