Class OpenPgpPubSubUtil

java.lang.Object
org.jivesoftware.smackx.ox.util.OpenPgpPubSubUtil

public class OpenPgpPubSubUtil extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Name of the OX metadata node.
    static final String
    Feature to be announced using the ServiceDiscoveryManager to subscribe to the OX metadata node.
    static final String
    Name of the OX secret key node.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    changeAccessModelIfNecessary(org.jivesoftware.smackx.pubsub.LeafNode node, org.jivesoftware.smackx.pubsub.AccessModel accessModel)
    Query the access model of node.
    static boolean
    deletePubkeysListNode(org.jivesoftware.smackx.pep.PepManager pepManager)
    Delete our metadata node.
    static boolean
    deletePublicKeyNode(org.jivesoftware.smackx.pep.PepManager pepManager, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
    Delete the public key node of the key with fingerprint fingerprint.
    static boolean
    deleteSecretKeyNode(org.jivesoftware.smackx.pep.PepManager pepManager)
    Delete the private backup node.
    static void
    depositSecretKey(org.jivesoftware.smack.XMPPConnection connection, SecretkeyElement element)
    Publishes a SecretkeyElement to the secret key node.
    fetchPubkey(org.jivesoftware.smack.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.
    fetchPubkeysList(org.jivesoftware.smack.XMPPConnection connection)
    Consult the public key metadata node and fetch a list of all of our published OpenPGP public keys.
    fetchPubkeysList(org.jivesoftware.smack.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.
    fetchSecretKey(org.jivesoftware.smackx.pep.PepManager pepManager)
    Fetch the latest SecretkeyElement from the private backup node.
    static org.jivesoftware.smackx.pubsub.LeafNode
    getOpenLeafNode(org.jivesoftware.smackx.pubsub.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(org.jivesoftware.smackx.pep.PepManager pepManager, PubkeyElement pubkeyElement, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
    Publish the users OpenPGP public key to the public key node if necessary.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • OpenPgpPubSubUtil

      public OpenPgpPubSubUtil()
  • Method Details

    • PEP_NODE_PUBLIC_KEY

      public 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.
      Parameters:
      id - upper case hex encoded OpenPGP v4 fingerprint of the key.
      Returns:
      PEP node name.
    • changeAccessModelIfNecessary

      public static void changeAccessModelIfNecessary(org.jivesoftware.smackx.pubsub.LeafNode node, org.jivesoftware.smackx.pubsub.AccessModel accessModel) throws org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.SmackException.NoResponseException
      Query the access model of node. If it is different from accessModel, change the access model of the node to accessModel.
      Parameters:
      node - LeafNode whose PubSub access model we want to change
      accessModel - new access model.
      Throws:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - in case of an XMPP protocol error.
      org.jivesoftware.smack.SmackException.NotConnectedException - if we are not connected.
      InterruptedException - if the thread is interrupted.
      org.jivesoftware.smack.SmackException.NoResponseException - if the server doesn't respond.
      See Also:
    • publishPublicKey

      public static void publishPublicKey(org.jivesoftware.smackx.pep.PepManager pepManager, PubkeyElement pubkeyElement, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws InterruptedException, org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.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 key
      fingerprint - fingerprint of the public key
      Throws:
      InterruptedException - if the thread gets interrupted.
      org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - if either the metadata node or the public key node is not a LeafNode.
      org.jivesoftware.smack.XMPPException.XMPPErrorException - in case of an XMPP protocol error.
      org.jivesoftware.smack.SmackException.NotConnectedException - if we are not connected.
      org.jivesoftware.smack.SmackException.NoResponseException - if the server doesn't respond.
      See Also:
    • fetchPubkeysList

      public static PublicKeysListElement fetchPubkeysList(org.jivesoftware.smack.XMPPConnection connection) throws InterruptedException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException, org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.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.
      org.jivesoftware.smack.XMPPException.XMPPErrorException - in case of an XMPP protocol exception.
      org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException - in case the queried entity is not a PubSub node
      org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - in case the queried node is not a LeafNode
      org.jivesoftware.smack.SmackException.NotConnectedException - in case we are not connected
      org.jivesoftware.smack.SmackException.NoResponseException - in case the server doesn't respond
      See Also:
    • fetchPubkeysList

      public static PublicKeysListElement fetchPubkeysList(org.jivesoftware.smack.XMPPConnection connection, org.jxmpp.jid.BareJid contact) throws InterruptedException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException
      Consult the public key metadata node of contact to fetch the list of their published OpenPGP public keys.
      Parameters:
      connection - XMPP connection
      contact - 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.
      org.jivesoftware.smack.XMPPException.XMPPErrorException - in case of an XMPP protocol exception.
      org.jivesoftware.smack.SmackException.NoResponseException - in case the server doesn't respond
      org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - in case the queried node is not a LeafNode
      org.jivesoftware.smack.SmackException.NotConnectedException - in case we are not connected
      org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException - in case the queried entity is not a PubSub node
      See Also:
    • deletePubkeysListNode

      public static boolean deletePubkeysListNode(org.jivesoftware.smackx.pep.PepManager pepManager) throws org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.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:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - in case of an XMPP protocol error.
      org.jivesoftware.smack.SmackException.NotConnectedException - if we are not connected.
      InterruptedException - if the thread is interrupted.
      org.jivesoftware.smack.SmackException.NoResponseException - if the server doesn't respond.
    • deletePublicKeyNode

      public static boolean deletePublicKeyNode(org.jivesoftware.smackx.pep.PepManager pepManager, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.SmackException.NoResponseException
      Delete the public key node of the key with fingerprint fingerprint.
      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:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - in case of an XMPP protocol error.
      org.jivesoftware.smack.SmackException.NotConnectedException - if we are not connected.
      InterruptedException - if the thread gets interrupted.
      org.jivesoftware.smack.SmackException.NoResponseException - if the server doesn't respond.
    • fetchPubkey

      public static PubkeyElement fetchPubkey(org.jivesoftware.smack.XMPPConnection connection, org.jxmpp.jid.BareJid contact, org.pgpainless.key.OpenPgpV4Fingerprint v4_fingerprint) throws InterruptedException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException, org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NoResponseException
      Fetch the OpenPGP public key of a contact, identified by its OpenPGP v4_fingerprint.
      Parameters:
      connection - XMPP connection
      contact - 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.A
      org.jivesoftware.smack.XMPPException.XMPPErrorException - in case of an XMPP protocol error.
      org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException - in case the targeted entity is not a PubSub node.
      org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - in case the fetched node is not a LeafNode.
      org.jivesoftware.smack.SmackException.NotConnectedException - in case we are not connected.
      org.jivesoftware.smack.SmackException.NoResponseException - if the server doesn't respond.
      See Also:
    • depositSecretKey

      public static void depositSecretKey(org.jivesoftware.smack.XMPPConnection connection, SecretkeyElement element) throws InterruptedException, org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.SmackException.FeatureNotSupportedException
      Publishes a SecretkeyElement 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 user
      element - a SecretkeyElement containing the encrypted secret key of the user
      Throws:
      InterruptedException - if the thread gets interrupted.
      org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - if something is wrong with the PubSub node
      org.jivesoftware.smack.XMPPException.XMPPErrorException - in case of an protocol related error
      org.jivesoftware.smack.SmackException.NotConnectedException - if we are not connected
      org.jivesoftware.smack.SmackException.NoResponseException - /watch?v=0peBq89ZTrc
      org.jivesoftware.smack.SmackException.FeatureNotSupportedException - if the Server doesn't support the whitelist access model
      See Also:
    • fetchSecretKey

      public static SecretkeyElement fetchSecretKey(org.jivesoftware.smackx.pep.PepManager pepManager) throws InterruptedException, org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NoResponseException
      Fetch the latest SecretkeyElement 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 interrupted
      org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - if there is an issue with the PubSub node
      org.jivesoftware.smack.XMPPException.XMPPErrorException - if there is an XMPP protocol related issue
      org.jivesoftware.smack.SmackException.NotConnectedException - if we are not connected
      org.jivesoftware.smack.SmackException.NoResponseException - /watch?v=7U0FzQzJzyI
      See Also:
    • deleteSecretKeyNode

      public static boolean deleteSecretKeyNode(org.jivesoftware.smackx.pep.PepManager pepManager) throws org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.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:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - if there is an XMPP protocol related issue
      org.jivesoftware.smack.SmackException.NotConnectedException - if we are not connected
      InterruptedException - if the thread gets interrupted
      org.jivesoftware.smack.SmackException.NoResponseException - if the server sends no response
    • getOpenLeafNode

      public static org.jivesoftware.smackx.pubsub.LeafNode getOpenLeafNode(org.jivesoftware.smackx.pubsub.PubSubManager pubSubManager, String nodeName) throws org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException
      Use reflection magic to get a 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 PubSubManagers 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 manager
      nodeName - name of the node
      Returns:
      leafNode TODO javadoc me please
      Throws:
      org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - in case we already have the node cached, but it is not a LeafNode.
      See Also: