Class OmemoManager


  • public final class OmemoManager
    extends org.jivesoftware.smack.Manager
    Manager that allows sending messages encrypted with OMEMO. This class also provides some methods useful for a client that implements OMEMO.
    • Method Detail

      • getInstanceFor

        public static OmemoManager getInstanceFor​(org.jivesoftware.smack.XMPPConnection connection,
                                                  java.lang.Integer deviceId)
        Return an OmemoManager instance for the given connection and deviceId. If there was an OmemoManager for the connection and id before, return it. Otherwise create a new OmemoManager instance and return it.
        Parameters:
        connection - XmppConnection.
        deviceId - MUST NOT be null and MUST be greater than 0.
        Returns:
        OmemoManager instance for the given connection and deviceId.
      • getInstanceFor

        public static OmemoManager getInstanceFor​(org.jivesoftware.smack.XMPPConnection connection)
        Returns an OmemoManager instance for the given connection. If there was one manager for the connection before, return it. If there were multiple managers before, return the one with the lowest deviceId. If there was no manager before, return a new one. As soon as the connection gets authenticated, the manager will look for local deviceIDs and select the lowest one as its id. If there are not local deviceIds, the manager will assign itself a random id.
        Parameters:
        connection - XmppConnection.
        Returns:
        OmemoManager instance for the given connection and a determined deviceId.
      • setTrustCallback

        public void setTrustCallback​(OmemoTrustCallback callback)
        Set a TrustCallback for this particular OmemoManager. TrustCallbacks are used to query and modify trust decisions.
        Parameters:
        callback - trustCallback.
      • initialize

        public void initialize()
                        throws org.jivesoftware.smack.SmackException.NotLoggedInException,
                               CorruptedOmemoKeyException,
                               java.lang.InterruptedException,
                               org.jivesoftware.smack.SmackException.NoResponseException,
                               org.jivesoftware.smack.SmackException.NotConnectedException,
                               org.jivesoftware.smack.XMPPException.XMPPErrorException,
                               org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException,
                               java.io.IOException
        Initializes the OmemoManager. This method must be called before the manager can be used.
        Throws:
        CorruptedOmemoKeyException - if the OMEMO key is corrupted.
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.
        org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - if a PubSub leaf node operation was attempted on a non-leaf node.
        java.io.IOException - if an I/O error occurred.
      • initializeAsync

        public void initializeAsync​(OmemoManager.InitializationFinishedCallback finishedCallback)
        Initialize the manager without blocking. Once the manager is successfully initialized, the finishedCallback will be notified. It will also get notified, if an error occurs.
        Parameters:
        finishedCallback - callback that gets called once the manager is initialized.
      • getDevicesOf

        public java.util.Set<OmemoDevice> getDevicesOf​(org.jxmpp.jid.BareJid contact)
                                                throws java.io.IOException
        Return a set of all OMEMO capable devices of a contact. Note, that this method does not explicitly refresh the device list of the contact, so it might be outdated.
        Parameters:
        contact - contact we want to get a set of device of.
        Returns:
        set of known devices of that contact.
        Throws:
        java.io.IOException - if an I/O error occurred.
        See Also:
        requestDeviceListUpdateFor(BareJid)
      • encrypt

        public OmemoMessage.Sent encrypt​(org.jxmpp.jid.BareJid recipient,
                                         java.lang.String message)
                                  throws CryptoFailedException,
                                         UndecidedOmemoIdentityException,
                                         java.lang.InterruptedException,
                                         org.jivesoftware.smack.SmackException.NotConnectedException,
                                         org.jivesoftware.smack.SmackException.NoResponseException,
                                         org.jivesoftware.smack.SmackException.NotLoggedInException,
                                         java.io.IOException
        OMEMO encrypt a cleartext message for a single recipient. Note that this method does NOT set the 'to' attribute of the message.
        Parameters:
        recipient - recipients bareJid
        message - text to encrypt
        Returns:
        encrypted message
        Throws:
        CryptoFailedException - when something crypto related fails
        UndecidedOmemoIdentityException - When there are undecided devices
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.
        java.io.IOException - if an I/O error occurred.
      • encrypt

        public OmemoMessage.Sent encrypt​(java.util.Set<org.jxmpp.jid.BareJid> recipients,
                                         java.lang.String message)
                                  throws CryptoFailedException,
                                         UndecidedOmemoIdentityException,
                                         java.lang.InterruptedException,
                                         org.jivesoftware.smack.SmackException.NotConnectedException,
                                         org.jivesoftware.smack.SmackException.NoResponseException,
                                         org.jivesoftware.smack.SmackException.NotLoggedInException,
                                         java.io.IOException
        OMEMO encrypt a cleartext message for multiple recipients.
        Parameters:
        recipients - recipients barejids
        message - text to encrypt
        Returns:
        encrypted message.
        Throws:
        CryptoFailedException - When something crypto related fails
        UndecidedOmemoIdentityException - When there are undecided devices.
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.
        java.io.IOException - if an I/O error occurred.
      • encrypt

        public OmemoMessage.Sent encrypt​(org.jivesoftware.smackx.muc.MultiUserChat muc,
                                         java.lang.String message)
                                  throws UndecidedOmemoIdentityException,
                                         CryptoFailedException,
                                         org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                         org.jivesoftware.smack.SmackException.NotConnectedException,
                                         java.lang.InterruptedException,
                                         org.jivesoftware.smack.SmackException.NoResponseException,
                                         NoOmemoSupportException,
                                         org.jivesoftware.smack.SmackException.NotLoggedInException,
                                         java.io.IOException
        Encrypt a message for all recipients in the MultiUserChat.
        Parameters:
        muc - multiUserChat
        message - message to send
        Returns:
        encrypted message
        Throws:
        UndecidedOmemoIdentityException - when there are undecided devices.
        CryptoFailedException - if the OMEMO cryptography failed.
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        NoOmemoSupportException - When the muc doesn't support OMEMO.
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.
        java.io.IOException - if an I/O error occurred.
      • decrypt

        public OmemoMessage.Received decrypt​(org.jxmpp.jid.BareJid sender,
                                             OmemoElement omemoElement)
                                      throws org.jivesoftware.smack.SmackException.NotLoggedInException,
                                             CorruptedOmemoKeyException,
                                             NoRawSessionException,
                                             CryptoFailedException,
                                             java.io.IOException
        Manually decrypt an OmemoElement. This method should only be used for use-cases, where the internal listeners don't pick up on an incoming message. (for example MAM query results).
        Parameters:
        sender - bareJid of the message sender (must be the jid of the contact who sent the message)
        omemoElement - omemoElement
        Returns:
        decrypted OmemoMessage
        Throws:
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the Manager is not authenticated
        CorruptedOmemoKeyException - if our or their key is corrupted
        NoRawSessionException - if the message was not a preKeyMessage, but we had no session with the contact
        CryptoFailedException - if decryption fails
        java.io.IOException - if an I/O error occurred.
      • decryptMamQueryResult

        public java.util.List<MessageOrOmemoMessage> decryptMamQueryResult​(org.jivesoftware.smackx.mam.MamManager.MamQuery mamQuery)
                                                                    throws org.jivesoftware.smack.SmackException.NotLoggedInException,
                                                                           java.io.IOException
        Decrypt messages from a MAM query.
        Parameters:
        mamQuery - The MAM query
        Returns:
        list of decrypted OmemoMessages
        Throws:
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the Manager is not authenticated.
        java.io.IOException - if an I/O error occurred.
      • trustOmemoIdentity

        public void trustOmemoIdentity​(OmemoDevice device,
                                       OmemoFingerprint fingerprint)
        Trust that a fingerprint belongs to an OmemoDevice. The fingerprint must be the lowercase, hexadecimal fingerprint of the identityKey of the device and must be of length 64.
        Parameters:
        device - device
        fingerprint - fingerprint
      • distrustOmemoIdentity

        public void distrustOmemoIdentity​(OmemoDevice device,
                                          OmemoFingerprint fingerprint)
        Distrust the fingerprint/OmemoDevice tuple. The fingerprint must be the lowercase, hexadecimal fingerprint of the identityKey of the device and must be of length 64.
        Parameters:
        device - device
        fingerprint - fingerprint
      • isTrustedOmemoIdentity

        public boolean isTrustedOmemoIdentity​(OmemoDevice device,
                                              OmemoFingerprint fingerprint)
        Returns true, if the fingerprint/OmemoDevice tuple is trusted, otherwise false. The fingerprint must be the lowercase, hexadecimal fingerprint of the identityKey of the device and must be of length 64.
        Parameters:
        device - device
        fingerprint - fingerprint
        Returns:
        true if this is a trusted OMEMO identity.
      • isDecidedOmemoIdentity

        public boolean isDecidedOmemoIdentity​(OmemoDevice device,
                                              OmemoFingerprint fingerprint)
        Returns true, if the fingerprint/OmemoDevice tuple is decided by the user. The fingerprint must be the lowercase, hexadecimal fingerprint of the identityKey of the device and must be of length 64.
        Parameters:
        device - device
        fingerprint - fingerprint
        Returns:
        true if the trust is decided for the identity.
      • sendRatchetUpdateMessage

        public void sendRatchetUpdateMessage​(OmemoDevice recipient)
                                      throws org.jivesoftware.smack.SmackException.NotLoggedInException,
                                             CorruptedOmemoKeyException,
                                             java.lang.InterruptedException,
                                             org.jivesoftware.smack.SmackException.NoResponseException,
                                             java.security.NoSuchAlgorithmException,
                                             org.jivesoftware.smack.SmackException.NotConnectedException,
                                             CryptoFailedException,
                                             CannotEstablishOmemoSessionException,
                                             java.io.IOException
        Send a ratchet update message. This can be used to advance the ratchet of a session in order to maintain forward secrecy.
        Parameters:
        recipient - recipient
        Throws:
        CorruptedOmemoKeyException - When the used identityKeys are corrupted
        CryptoFailedException - When something fails with the crypto
        CannotEstablishOmemoSessionException - When we can't establish a session with the recipient
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        java.security.NoSuchAlgorithmException - if no such algorithm is available.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.io.IOException - if an I/O error occurred.
      • contactSupportsOmemo

        public boolean contactSupportsOmemo​(org.jxmpp.jid.BareJid contact)
                                     throws java.lang.InterruptedException,
                                            org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException,
                                            org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                            org.jivesoftware.smack.SmackException.NotConnectedException,
                                            org.jivesoftware.smack.SmackException.NoResponseException,
                                            java.io.IOException
        Returns true, if the contact has any active devices published in a deviceList.
        Parameters:
        contact - contact
        Returns:
        true if contact has at least one OMEMO capable device.
        Throws:
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - if a PubSub leaf node operation was attempted on a non-leaf node.
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        java.io.IOException - if an I/O error occurred.
      • multiUserChatSupportsOmemo

        public boolean multiUserChatSupportsOmemo​(org.jivesoftware.smackx.muc.MultiUserChat multiUserChat)
                                           throws org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                                  org.jivesoftware.smack.SmackException.NotConnectedException,
                                                  java.lang.InterruptedException,
                                                  org.jivesoftware.smack.SmackException.NoResponseException
        Returns true, if the MUC with the EntityBareJid multiUserChat is non-anonymous and members only (prerequisite for OMEMO encryption in MUC).
        Parameters:
        multiUserChat - MUC
        Returns:
        true if chat supports OMEMO
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP protocol level error
        org.jivesoftware.smack.SmackException.NotConnectedException - if the connection is not connected
        java.lang.InterruptedException - if the thread is interrupted
        org.jivesoftware.smack.SmackException.NoResponseException - if the server does not respond
      • serverSupportsOmemo

        public static boolean serverSupportsOmemo​(org.jivesoftware.smack.XMPPConnection connection,
                                                  org.jxmpp.jid.DomainBareJid server)
                                           throws org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                                  org.jivesoftware.smack.SmackException.NotConnectedException,
                                                  java.lang.InterruptedException,
                                                  org.jivesoftware.smack.SmackException.NoResponseException
        Returns true, if the Server supports PEP.
        Parameters:
        connection - XMPPConnection
        server - domainBareJid of the server to test
        Returns:
        true if server supports pep
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
      • getOwnFingerprint

        public OmemoFingerprint getOwnFingerprint()
                                           throws org.jivesoftware.smack.SmackException.NotLoggedInException,
                                                  CorruptedOmemoKeyException,
                                                  java.io.IOException
        Return the fingerprint of our identity key.
        Returns:
        our own OMEMO fingerprint
        Throws:
        org.jivesoftware.smack.SmackException.NotLoggedInException - if we don't know our bareJid yet.
        CorruptedOmemoKeyException - if our identityKey is corrupted.
        java.io.IOException - if an I/O error occurred.
      • getFingerprint

        public OmemoFingerprint getFingerprint​(OmemoDevice device)
                                        throws CannotEstablishOmemoSessionException,
                                               org.jivesoftware.smack.SmackException.NotLoggedInException,
                                               CorruptedOmemoKeyException,
                                               org.jivesoftware.smack.SmackException.NotConnectedException,
                                               java.lang.InterruptedException,
                                               org.jivesoftware.smack.SmackException.NoResponseException,
                                               java.io.IOException
        Get the fingerprint of a contacts device.
        Parameters:
        device - contacts OmemoDevice
        Returns:
        fingerprint of the given OMEMO device.
        Throws:
        CannotEstablishOmemoSessionException - if we have no session yet, and are unable to create one.
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.
        CorruptedOmemoKeyException - if the copy of the fingerprint we have is corrupted.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        java.io.IOException - if an I/O error occurred.
      • getActiveFingerprints

        public java.util.HashMap<OmemoDevice,​OmemoFingerprint> getActiveFingerprints​(org.jxmpp.jid.BareJid contact)
                                                                                    throws org.jivesoftware.smack.SmackException.NotLoggedInException,
                                                                                           CorruptedOmemoKeyException,
                                                                                           CannotEstablishOmemoSessionException,
                                                                                           org.jivesoftware.smack.SmackException.NotConnectedException,
                                                                                           java.lang.InterruptedException,
                                                                                           org.jivesoftware.smack.SmackException.NoResponseException,
                                                                                           java.io.IOException
        Return all OmemoFingerprints of active devices of a contact. TODO: Make more fail-safe
        Parameters:
        contact - contact
        Returns:
        Map of all active devices of the contact and their fingerprints.
        Throws:
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.
        CorruptedOmemoKeyException - if the OMEMO key is corrupted.
        CannotEstablishOmemoSessionException - if no OMEMO session could be established.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        java.io.IOException - if an I/O error occurred.
      • addOmemoMessageListener

        public void addOmemoMessageListener​(OmemoMessageListener listener)
        Add an OmemoMessageListener. This listener will be informed about incoming OMEMO messages (as well as KeyTransportMessages) and OMEMO encrypted message carbons.
        Parameters:
        listener - OmemoMessageListener
      • removeOmemoMessageListener

        public void removeOmemoMessageListener​(OmemoMessageListener listener)
        Remove an OmemoMessageListener.
        Parameters:
        listener - OmemoMessageListener
      • addOmemoMucMessageListener

        public void addOmemoMucMessageListener​(OmemoMucMessageListener listener)
        Add an OmemoMucMessageListener. This listener will be informed about incoming OMEMO encrypted MUC messages.
        Parameters:
        listener - OmemoMessageListener.
      • removeOmemoMucMessageListener

        public void removeOmemoMucMessageListener​(OmemoMucMessageListener listener)
        Remove an OmemoMucMessageListener.
        Parameters:
        listener - OmemoMucMessageListener
      • requestDeviceListUpdateFor

        public void requestDeviceListUpdateFor​(org.jxmpp.jid.BareJid contact)
                                        throws java.lang.InterruptedException,
                                               org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException,
                                               org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                               org.jivesoftware.smack.SmackException.NotConnectedException,
                                               org.jivesoftware.smack.SmackException.NoResponseException,
                                               java.io.IOException
        Request a deviceList update from contact contact.
        Parameters:
        contact - contact we want to obtain the deviceList from.
        Throws:
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - if a PubSub leaf node operation was attempted on a non-leaf node.
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        java.io.IOException - if an I/O error occurred.
      • purgeDeviceList

        public void purgeDeviceList()
                             throws org.jivesoftware.smack.SmackException.NotLoggedInException,
                                    java.lang.InterruptedException,
                                    org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                    org.jivesoftware.smack.SmackException.NotConnectedException,
                                    org.jivesoftware.smack.SmackException.NoResponseException,
                                    java.io.IOException,
                                    org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException
        Publish a new device list with just our own deviceId in it.
        Throws:
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        java.io.IOException - if an I/O error occurred.
        org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - if a PubSub leaf node operation was attempted on a non-leaf node.
      • rotateSignedPreKey

        public void rotateSignedPreKey()
                                throws CorruptedOmemoKeyException,
                                       org.jivesoftware.smack.SmackException.NotLoggedInException,
                                       org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                       org.jivesoftware.smack.SmackException.NotConnectedException,
                                       java.lang.InterruptedException,
                                       org.jivesoftware.smack.SmackException.NoResponseException,
                                       java.io.IOException,
                                       org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException
        Rotate the signedPreKey published in our OmemoBundle and republish it. This should be done every now and then (7-14 days). The old signedPreKey should be kept for some more time (a month or so) to enable decryption of messages that have been sent since the key was changed.
        Throws:
        CorruptedOmemoKeyException - When the IdentityKeyPair is damaged.
        java.lang.InterruptedException - XMPP error
        org.jivesoftware.smack.XMPPException.XMPPErrorException - XMPP error
        org.jivesoftware.smack.SmackException.NotConnectedException - XMPP error
        org.jivesoftware.smack.SmackException.NoResponseException - XMPP error
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.
        java.io.IOException - if an I/O error occurred.
        org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException - if a PubSub leaf node operation was attempted on a non-leaf node.
      • randomDeviceId

        public static int randomDeviceId()
        Returns a pseudo random number from the interval [1, Integer.MAX_VALUE].
        Returns:
        a random deviceId.
      • getOwnJid

        public org.jxmpp.jid.BareJid getOwnJid()
        Return the BareJid of the user.
        Returns:
        our own bare JID.
      • getDeviceId

        public java.lang.Integer getDeviceId()
        Return the deviceId of this OmemoManager.
        Returns:
        this OmemoManagers deviceId.
      • getOwnDevice

        public OmemoDevice getOwnDevice()
        Return the OmemoDevice of the user.
        Returns:
        our own OmemoDevice
      • resumeStanzaAndPEPListeners

        public void resumeStanzaAndPEPListeners()
        Register stanza listeners needed for OMEMO. This method is called automatically in the constructor and should only be used to restore the previous state after stopStanzaAndPEPListeners() was called.
      • stopStanzaAndPEPListeners

        public void stopStanzaAndPEPListeners()
        Remove active stanza listeners needed for OMEMO.
      • rebuildSessionWith

        public void rebuildSessionWith​(OmemoDevice contactsDevice)
                                throws java.lang.InterruptedException,
                                       org.jivesoftware.smack.SmackException.NoResponseException,
                                       CorruptedOmemoKeyException,
                                       org.jivesoftware.smack.SmackException.NotConnectedException,
                                       CannotEstablishOmemoSessionException,
                                       org.jivesoftware.smack.SmackException.NotLoggedInException
        Build a fresh session with a contacts device. This might come in handy if a session is broken.
        Parameters:
        contactsDevice - OmemoDevice of a contact.
        Throws:
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        CorruptedOmemoKeyException - if our or their identityKey is corrupted.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        CannotEstablishOmemoSessionException - if no new session can be established.
        org.jivesoftware.smack.SmackException.NotLoggedInException - if the connection is not authenticated.