public class OpenPgpPubSubUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
PEP_NODE_PUBLIC_KEYS
Name of the OX metadata node.
|
static String |
PEP_NODE_PUBLIC_KEYS_NOTIFY
Feature to be announced using the
ServiceDiscoveryManager to subscribe to the OX metadata node. |
static String |
PEP_NODE_SECRET_KEY
Name of the OX secret key node.
|
Constructor and Description |
---|
OpenPgpPubSubUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
changeAccessModelIfNecessary(LeafNode node,
AccessModel accessModel)
Query the access model of
node . |
static void |
deletePubkeysListNode(XMPPConnection connection)
Delete our metadata node.
|
static void |
deletePublicKeyNode(XMPPConnection connection,
org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
Delete the public key node of the key with fingerprint
fingerprint . |
static void |
deleteSecretKeyNode(XMPPConnection connection)
Delete the private backup node.
|
static void |
depositSecretKey(XMPPConnection connection,
SecretkeyElement element)
Publishes a
SecretkeyElement to the secret key node. |
static PubkeyElement |
fetchPubkey(XMPPConnection connection,
org.jxmpp.jid.BareJid contact,
org.pgpainless.key.OpenPgpV4Fingerprint v4_fingerprint)
Fetch the OpenPGP public key of a
contact , identified by its OpenPGP v4_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,
org.jxmpp.jid.BareJid contact)
Consult the public key metadata node of
contact to fetch the list of their published OpenPGP public keys. |
static SecretkeyElement |
fetchSecretKey(XMPPConnection connection)
Fetch the latest
SecretkeyElement from the private backup node. |
static LeafNode |
getOpenLeafNode(PubSubManager pubSubManager,
String nodeName)
Use reflection magic to get a
LeafNode 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 id
id . |
static void |
publishPublicKey(XMPPConnection connection,
PubkeyElement pubkeyElement,
org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
Publish the users OpenPGP public key to the public key node if necessary.
|
public static final String PEP_NODE_PUBLIC_KEYS
public static final String PEP_NODE_SECRET_KEY
public static final String PEP_NODE_PUBLIC_KEYS_NOTIFY
ServiceDiscoveryManager
to subscribe to the OX metadata node.public OpenPgpPubSubUtil()
public static String PEP_NODE_PUBLIC_KEY(org.pgpainless.key.OpenPgpV4Fingerprint id)
id
.id
- upper case hex encoded OpenPGP v4 fingerprint of the key.public static void changeAccessModelIfNecessary(LeafNode node, AccessModel accessModel) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException
node
. If it is different from accessModel
, change the access model
of the node to accessModel
.node
- LeafNode
whose PubSub access model we want to changeaccessModel
- new access model.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.public static void publishPublicKey(XMPPConnection connection, PubkeyElement pubkeyElement, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException
connection
- XMPP connectionpubkeyElement
- PubkeyElement
containing the public keyfingerprint
- fingerprint of the public keyInterruptedException
- if the thread gets interrupted.PubSubException.NotALeafNodeException
- if either the metadata node or the public key node is not a
LeafNode
.XMPPException.XMPPErrorException
- in case of an XMPP protocol error.SmackException.NotConnectedException
- if we are not connected.SmackException.NoResponseException
- if the server doesn't respond.public static PublicKeysListElement fetchPubkeysList(XMPPConnection connection) throws InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException, PubSubException.NotALeafNodeException, SmackException.NotConnectedException, SmackException.NoResponseException
connection
- XMPP connectionInterruptedException
- 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 a LeafNode
SmackException.NotConnectedException
- in case we are not connectedSmackException.NoResponseException
- in case the server doesn't respondpublic static PublicKeysListElement fetchPubkeysList(XMPPConnection connection, org.jxmpp.jid.BareJid contact) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException, PubSubException.NotALeafNodeException, SmackException.NotConnectedException, PubSubException.NotAPubSubNodeException
contact
to fetch the list of their published OpenPGP public keys.connection
- XMPP connectioncontact
- BareJid
of the user we want to fetch the list from.contact
's metadata node.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 a LeafNode
SmackException.NotConnectedException
- in case we are not connectedPubSubException.NotAPubSubNodeException
- in case the queried entity is not a PubSub nodepublic static void deletePubkeysListNode(XMPPConnection connection) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException
connection
- XMPP connectionXMPPException.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.public static void deletePublicKeyNode(XMPPConnection connection, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException
fingerprint
.connection
- XMPP connectionfingerprint
- fingerprint of the key we want to deleteXMPPException.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.public static PubkeyElement fetchPubkey(XMPPConnection connection, org.jxmpp.jid.BareJid contact, org.pgpainless.key.OpenPgpV4Fingerprint v4_fingerprint) throws InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException, PubSubException.NotALeafNodeException, SmackException.NotConnectedException, SmackException.NoResponseException
contact
, identified by its OpenPGP v4_fingerprint
.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.PubkeyElement
containing the requested public key.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 a LeafNode
.SmackException.NotConnectedException
- in case we are not connected.SmackException.NoResponseException
- if the server doesn't respond.public static void depositSecretKey(XMPPConnection connection, SecretkeyElement element) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, SmackException.FeatureNotSupportedException
SecretkeyElement
to the secret key node.
The node will be configured to use the whitelist access model to prevent access from subscribers.connection
- XMPPConnection
of the userelement
- a SecretkeyElement
containing the encrypted secret key of the userInterruptedException
- 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 modelpublic static SecretkeyElement fetchSecretKey(XMPPConnection connection) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException
SecretkeyElement
from the private backup node.connection
- XMPPConnection
of the user.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=7U0FzQzJzyIpublic static void deleteSecretKeyNode(XMPPConnection connection) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException
connection
- XMPPConnection
of the user.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 responsepublic static LeafNode getOpenLeafNode(PubSubManager pubSubManager, String nodeName) throws PubSubException.NotALeafNodeException
LeafNode
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 the PubSubManager
s node map.
Note: Due to the alck 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.pubSubManager
- pubsub managernodeName
- name of the nodePubSubException.NotALeafNodeException
- in case we already have the node cached, but it is not a LeafNode.