public final class OmemoManager
extends org.jivesoftware.smack.Manager
| Modifier and Type | Class and Description |
|---|---|
static interface |
OmemoManager.InitializationFinishedCallback
Callback which can be used to get notified, when the OmemoManager finished initializing.
|
static class |
OmemoManager.LoggedInOmemoManager
Guard class which ensures that the wrapped OmemoManager knows its BareJid.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addOmemoMessageListener(OmemoMessageListener listener)
Add an OmemoMessageListener.
|
void |
addOmemoMucMessageListener(OmemoMucMessageListener listener)
Add an OmemoMucMessageListener.
|
boolean |
contactSupportsOmemo(org.jxmpp.jid.BareJid contact)
Returns true, if the contact has any active devices published in a deviceList.
|
OmemoMessage.Received |
decrypt(org.jxmpp.jid.BareJid sender,
OmemoElement omemoElement)
Manually decrypt an OmemoElement.
|
java.util.List<MessageOrOmemoMessage> |
decryptMamQueryResult(org.jivesoftware.smackx.mam.MamManager.MamQuery mamQuery)
Decrypt messages from a MAM query.
|
void |
distrustOmemoIdentity(OmemoDevice device,
OmemoFingerprint fingerprint)
Distrust the fingerprint/OmemoDevice tuple.
|
OmemoMessage.Sent |
encrypt(org.jxmpp.jid.BareJid recipient,
java.lang.String message)
OMEMO encrypt a cleartext message for a single recipient.
|
OmemoMessage.Sent |
encrypt(org.jivesoftware.smackx.muc.MultiUserChat muc,
java.lang.String message)
Encrypt a message for all recipients in the MultiUserChat.
|
OmemoMessage.Sent |
encrypt(java.util.Set<org.jxmpp.jid.BareJid> recipients,
java.lang.String message)
OMEMO encrypt a cleartext message for multiple recipients.
|
java.util.HashMap<OmemoDevice,OmemoFingerprint> |
getActiveFingerprints(org.jxmpp.jid.BareJid contact)
Return all OmemoFingerprints of active devices of a contact.
|
java.lang.Integer |
getDeviceId()
Return the deviceId of this OmemoManager.
|
java.util.Set<OmemoDevice> |
getDevicesOf(org.jxmpp.jid.BareJid contact)
Return a set of all OMEMO capable devices of a contact.
|
OmemoFingerprint |
getFingerprint(OmemoDevice device)
Get the fingerprint of a contacts device.
|
static OmemoManager |
getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
Returns an OmemoManager instance for the given connection.
|
static OmemoManager |
getInstanceFor(org.jivesoftware.smack.XMPPConnection connection,
java.lang.Integer deviceId)
Return an OmemoManager instance for the given connection and deviceId.
|
OmemoDevice |
getOwnDevice()
Return the OmemoDevice of the user.
|
OmemoFingerprint |
getOwnFingerprint()
Return the fingerprint of our identity key.
|
org.jxmpp.jid.BareJid |
getOwnJid()
Return the BareJid of the user.
|
void |
initialize()
Initializes the OmemoManager.
|
void |
initializeAsync(OmemoManager.InitializationFinishedCallback finishedCallback)
Initialize the manager without blocking.
|
boolean |
isDecidedOmemoIdentity(OmemoDevice device,
OmemoFingerprint fingerprint)
Returns true, if the fingerprint/OmemoDevice tuple is decided by the user.
|
boolean |
isTrustedOmemoIdentity(OmemoDevice device,
OmemoFingerprint fingerprint)
Returns true, if the fingerprint/OmemoDevice tuple is trusted, otherwise false.
|
boolean |
multiUserChatSupportsOmemo(org.jivesoftware.smackx.muc.MultiUserChat multiUserChat)
Returns true, if the MUC with the EntityBareJid multiUserChat is non-anonymous and members only (prerequisite
for OMEMO encryption in MUC).
|
void |
purgeDeviceList()
Publish a new device list with just our own deviceId in it.
|
static int |
randomDeviceId()
Returns a pseudo random number from the interval [1, Integer.MAX_VALUE].
|
void |
rebuildSessionWith(OmemoDevice contactsDevice)
Build a fresh session with a contacts device.
|
void |
removeOmemoMessageListener(OmemoMessageListener listener)
Remove an OmemoMessageListener.
|
void |
removeOmemoMucMessageListener(OmemoMucMessageListener listener)
Remove an OmemoMucMessageListener.
|
void |
requestDeviceListUpdateFor(org.jxmpp.jid.BareJid contact)
Request a deviceList update from contact contact.
|
void |
resumeStanzaAndPEPListeners()
Register stanza listeners needed for OMEMO.
|
void |
rotateSignedPreKey()
Rotate the signedPreKey published in our OmemoBundle and republish it.
|
void |
sendRatchetUpdateMessage(OmemoDevice recipient)
Send a ratchet update message.
|
static boolean |
serverSupportsOmemo(org.jivesoftware.smack.XMPPConnection connection,
org.jxmpp.jid.DomainBareJid server)
Returns true, if the Server supports PEP.
|
void |
setTrustCallback(OmemoTrustCallback callback)
Set a TrustCallback for this particular OmemoManager.
|
void |
stopStanzaAndPEPListeners()
Remove active stanza listeners needed for OMEMO.
|
void |
trustOmemoIdentity(OmemoDevice device,
OmemoFingerprint fingerprint)
Trust that a fingerprint belongs to an OmemoDevice.
|
public static OmemoManager getInstanceFor(org.jivesoftware.smack.XMPPConnection connection, java.lang.Integer deviceId)
connection - XmppConnection.deviceId - MUST NOT be null and MUST be greater than 0.public static OmemoManager getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
connection - XmppConnection.public void setTrustCallback(OmemoTrustCallback callback)
callback - trustCallback.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
CorruptedOmemoKeyExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionXMPPException.XMPPErrorExceptionSmackException.NotLoggedInExceptionPubSubException.NotALeafNodeExceptionpublic void initializeAsync(OmemoManager.InitializationFinishedCallback finishedCallback)
finishedCallback - callback that gets called once the manager is initialized.public java.util.Set<OmemoDevice> getDevicesOf(org.jxmpp.jid.BareJid contact)
contact - contact we want to get a set of device of.requestDeviceListUpdateFor(BareJid)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
recipient - recipients bareJidmessage - text to encryptCryptoFailedException - when something crypto related failsUndecidedOmemoIdentityException - When there are undecided devicesjava.lang.InterruptedExceptionSmackException.NotConnectedExceptionSmackException.NoResponseExceptionSmackException.NotLoggedInExceptionpublic 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
recipients - recipients barejidsmessage - text to encryptCryptoFailedException - When something crypto related failsUndecidedOmemoIdentityException - When there are undecided devices.java.lang.InterruptedExceptionSmackException.NotConnectedExceptionSmackException.NoResponseExceptionSmackException.NotLoggedInExceptionpublic 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
muc - multiUserChatmessage - message to sendUndecidedOmemoIdentityException - when there are undecided devices.CryptoFailedExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionNoOmemoSupportException - When the muc doesn't support OMEMO.SmackException.NotLoggedInExceptionpublic OmemoMessage.Received decrypt(org.jxmpp.jid.BareJid sender, OmemoElement omemoElement) throws org.jivesoftware.smack.SmackException.NotLoggedInException, CorruptedOmemoKeyException, NoRawSessionException, CryptoFailedException
sender - bareJid of the message sender (must be the jid of the contact who sent the message)omemoElement - omemoElementSmackException.NotLoggedInException - if the Manager is not authenticatedCorruptedOmemoKeyException - if our or their key is corruptedNoRawSessionException - if the message was not a preKeyMessage, but we had no session with the contactCryptoFailedException - if decryption failspublic java.util.List<MessageOrOmemoMessage> decryptMamQueryResult(org.jivesoftware.smackx.mam.MamManager.MamQuery mamQuery) throws org.jivesoftware.smack.SmackException.NotLoggedInException
mamQuery - The MAM querySmackException.NotLoggedInException - if the Manager is not authenticated.public void trustOmemoIdentity(OmemoDevice device, OmemoFingerprint fingerprint)
device - devicefingerprint - fingerprintpublic void distrustOmemoIdentity(OmemoDevice device, OmemoFingerprint fingerprint)
device - devicefingerprint - fingerprintpublic boolean isTrustedOmemoIdentity(OmemoDevice device, OmemoFingerprint fingerprint)
device - devicefingerprint - fingerprintpublic boolean isDecidedOmemoIdentity(OmemoDevice device, OmemoFingerprint fingerprint)
device - devicefingerprint - fingerprintpublic 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
recipient - recipientCorruptedOmemoKeyException - When the used identityKeys are corruptedCryptoFailedException - When something fails with the cryptoCannotEstablishOmemoSessionException - When we can't establish a session with the recipientSmackException.NotLoggedInExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionjava.security.NoSuchAlgorithmExceptionSmackException.NotConnectedExceptionpublic 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
contact - contactSmackException.NotConnectedExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionPubSubException.NotALeafNodeExceptionXMPPException.XMPPErrorExceptionpublic 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
multiUserChat - MUCXMPPException.XMPPErrorException - ifSmackException.NotConnectedException - somethingjava.lang.InterruptedException - goesSmackException.NoResponseException - wrongpublic 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
connection - XMPPConnectionserver - domainBareJid of the server to testXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionpublic OmemoFingerprint getOwnFingerprint() throws org.jivesoftware.smack.SmackException.NotLoggedInException, CorruptedOmemoKeyException
SmackException.NotLoggedInException - if we don't know our bareJid yet.CorruptedOmemoKeyException - if our identityKey is corrupted.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
device - contacts OmemoDeviceCannotEstablishOmemoSessionException - if we have no session yet, and are unable to create one.SmackException.NotLoggedInExceptionCorruptedOmemoKeyException - if the copy of the fingerprint we have is corrupted.SmackException.NotConnectedExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionpublic 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
contact - contactSmackException.NotLoggedInExceptionCorruptedOmemoKeyExceptionCannotEstablishOmemoSessionExceptionSmackException.NotConnectedExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionpublic void addOmemoMessageListener(OmemoMessageListener listener)
listener - OmemoMessageListenerpublic void removeOmemoMessageListener(OmemoMessageListener listener)
listener - OmemoMessageListenerpublic void addOmemoMucMessageListener(OmemoMucMessageListener listener)
listener - OmemoMessageListener.public void removeOmemoMucMessageListener(OmemoMucMessageListener listener)
listener - OmemoMucMessageListenerpublic 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
contact - contact we want to obtain the deviceList from.java.lang.InterruptedExceptionPubSubException.NotALeafNodeExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionSmackException.NoResponseExceptionpublic 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
SmackException.NotLoggedInExceptionjava.lang.InterruptedExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionSmackException.NoResponseExceptionpublic 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
CorruptedOmemoKeyException - When the IdentityKeyPair is damaged.java.lang.InterruptedException - XMPP errorXMPPException.XMPPErrorException - XMPP errorSmackException.NotConnectedException - XMPP errorSmackException.NoResponseException - XMPP errorSmackException.NotLoggedInExceptionpublic static int randomDeviceId()
public org.jxmpp.jid.BareJid getOwnJid()
public java.lang.Integer getDeviceId()
public OmemoDevice getOwnDevice()
public void resumeStanzaAndPEPListeners()
stopStanzaAndPEPListeners() was called.public void stopStanzaAndPEPListeners()
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
contactsDevice - OmemoDevice of a contact.java.lang.InterruptedExceptionSmackException.NoResponseExceptionCorruptedOmemoKeyException - if our or their identityKey is corrupted.SmackException.NotConnectedExceptionCannotEstablishOmemoSessionException - if no new session can be established.SmackException.NotLoggedInException - if the connection is not authenticated.