public final class OmemoManager
extends org.jivesoftware.smack.Manager
| Modifier and Type | Method and Description |
|---|---|
void |
addOmemoMessageListener(OmemoMessageListener listener) |
void |
addOmemoMucMessageListener(OmemoMucMessageListener listener) |
void |
buildSessionsWith(org.jxmpp.jid.BareJid contact)
Build OMEMO sessions with devices of contact.
|
boolean |
contactSupportsOmemo(org.jxmpp.jid.BareJid contact)
Returns true, if the contact has any active devices published in a deviceList.
|
OmemoVAxolotlElement |
createKeyTransportElement(byte[] aesKey,
byte[] iv,
OmemoDevice... to)
Create a new KeyTransportElement.
|
ClearTextMessage |
decrypt(org.jxmpp.jid.BareJid sender,
org.jivesoftware.smack.packet.Message omemoMessage)
Decrypt an OMEMO message.
|
java.util.List<ClearTextMessage> |
decryptMamQueryResult(org.jivesoftware.smackx.mam.MamManager.MamQueryResult mamQueryResult)
Return a list of all OMEMO messages that were found in the MAM query result, that could be successfully decrypted.
|
void |
distrustOmemoIdentity(OmemoDevice device,
OmemoFingerprint fingerprint)
Distrust the fingerprint/OmemoDevice tuple.
|
org.jivesoftware.smack.packet.Message |
encrypt(java.util.ArrayList<org.jxmpp.jid.BareJid> recipients,
java.lang.String message)
OMEMO encrypt a cleartext message for multiple recipients.
|
org.jivesoftware.smack.packet.Message |
encrypt(org.jxmpp.jid.BareJid to,
java.lang.String message)
OMEMO encrypt a cleartext message for a single recipient.
|
org.jivesoftware.smack.packet.Message |
encrypt(org.jivesoftware.smackx.muc.MultiUserChat muc,
java.lang.String message)
Encrypt a message for all recipients in the MultiUserChat.
|
org.jivesoftware.smack.packet.Message |
encryptForExistingSessions(CannotEstablishOmemoSessionException exception,
java.lang.String message)
Encrypt a message for all users we could build a session with successfully in a previous attempt.
|
java.util.HashMap<OmemoDevice,OmemoFingerprint> |
getActiveFingerprints(org.jxmpp.jid.BareJid contact)
Return all fingerprints of active devices of a contact.
|
int |
getDeviceId()
Return the deviceId of this OmemoManager.
|
OmemoFingerprint |
getFingerprint(OmemoDevice device) |
static OmemoManager |
getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
Get an instance of the OmemoManager for the given connection.
|
static OmemoManager |
getInstanceFor(org.jivesoftware.smack.XMPPConnection connection,
java.lang.Integer deviceId)
Get an instance of the OmemoManager for the given connection and deviceId.
|
OmemoFingerprint |
getOurFingerprint()
Return the fingerprint of our identity key.
|
OmemoDevice |
getOwnDevice()
Return the OmemoDevice of the user.
|
org.jxmpp.jid.BareJid |
getOwnJid()
Return the BareJid of the user.
|
void |
initialize()
Initializes the OmemoManager.
|
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.jxmpp.jid.EntityBareJid multiUserChat)
Returns true, if the MUC with the EntityBareJid multiUserChat is non-anonymous and members only (prerequisite
for OMEMO encryption in MUC).
|
void |
purgeDevices()
Clear all other devices except this one from our device list and republish the list.
|
static int |
randomDeviceId() |
void |
regenerate()
Generate fresh identity keys and bundle and publish it to the server.
|
void |
removeOmemoMessageListener(OmemoMessageListener listener) |
void |
removeOmemoMucMessageListener(OmemoMucMessageListener listener) |
void |
requestDeviceListUpdateFor(org.jxmpp.jid.BareJid contact)
Request a deviceList update from contact contact.
|
boolean |
resourceSupportsOmemo(org.jxmpp.jid.FullJid fullJid)
Returns true, if the device resource has announced OMEMO support.
|
void |
rotateSignedPreKey()
Rotate the signedPreKey published in our OmemoBundle.
|
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 |
shutdown()
Remove all active stanza listeners of this manager from the connection.
|
static boolean |
stanzaContainsOmemoElement(org.jivesoftware.smack.packet.Stanza stanza)
Return true, if the given Stanza contains an OMEMO element 'encrypted'.
|
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 - ConnectiondeviceId - deviceId of the Manager. If the deviceId is null, a random id will be generated.public static OmemoManager getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
connection - connectionpublic void initialize()
throws CorruptedOmemoKeyException,
java.lang.InterruptedException,
org.jivesoftware.smack.SmackException.NoResponseException,
org.jivesoftware.smack.SmackException.NotConnectedException,
org.jivesoftware.smack.XMPPException.XMPPErrorException,
org.jivesoftware.smack.SmackException.NotLoggedInException,
org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException
CorruptedOmemoKeyExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionXMPPException.XMPPErrorExceptionSmackException.NotLoggedInExceptionPubSubException.NotALeafNodeExceptionpublic org.jivesoftware.smack.packet.Message encrypt(org.jxmpp.jid.BareJid to,
java.lang.String message)
throws CryptoFailedException,
UndecidedOmemoIdentityException,
java.security.NoSuchAlgorithmException,
java.lang.InterruptedException,
CannotEstablishOmemoSessionException,
org.jivesoftware.smack.SmackException.NotConnectedException,
org.jivesoftware.smack.SmackException.NoResponseException
to - recipients barejidmessage - text to encryptCryptoFailedException - when something crypto related failsUndecidedOmemoIdentityException - When there are undecided devicesjava.security.NoSuchAlgorithmExceptionjava.lang.InterruptedExceptionCannotEstablishOmemoSessionException - when we could not create session withs all of the recipients devices.SmackException.NotConnectedExceptionSmackException.NoResponseExceptionpublic org.jivesoftware.smack.packet.Message encrypt(java.util.ArrayList<org.jxmpp.jid.BareJid> recipients,
java.lang.String message)
throws CryptoFailedException,
UndecidedOmemoIdentityException,
java.security.NoSuchAlgorithmException,
java.lang.InterruptedException,
CannotEstablishOmemoSessionException,
org.jivesoftware.smack.SmackException.NotConnectedException,
org.jivesoftware.smack.SmackException.NoResponseException
recipients - recipients barejidsmessage - text to encryptCryptoFailedException - When something crypto related failsUndecidedOmemoIdentityException - When there are undecided devices.java.security.NoSuchAlgorithmExceptionjava.lang.InterruptedExceptionCannotEstablishOmemoSessionException - When there is one recipient, for whom we failed to create a session
with every one of their devices.SmackException.NotConnectedExceptionSmackException.NoResponseExceptionpublic org.jivesoftware.smack.packet.Message encrypt(org.jivesoftware.smackx.muc.MultiUserChat muc,
java.lang.String message)
throws UndecidedOmemoIdentityException,
java.security.NoSuchAlgorithmException,
CryptoFailedException,
org.jivesoftware.smack.XMPPException.XMPPErrorException,
org.jivesoftware.smack.SmackException.NotConnectedException,
java.lang.InterruptedException,
org.jivesoftware.smack.SmackException.NoResponseException,
NoOmemoSupportException,
CannotEstablishOmemoSessionException
muc - multiUserChatmessage - message to sendUndecidedOmemoIdentityException - when there are undecided devices.java.security.NoSuchAlgorithmExceptionCryptoFailedExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionNoOmemoSupportException - When the muc doesn't support OMEMO.CannotEstablishOmemoSessionException - when there is a user for whom we could not create a session
with any of their devices.public org.jivesoftware.smack.packet.Message encryptForExistingSessions(CannotEstablishOmemoSessionException exception, java.lang.String message) throws CryptoFailedException, UndecidedOmemoIdentityException
exception - CannotEstablishSessionException from a previous encrypt(user(s), message) call.message - message we want to send.CryptoFailedExceptionUndecidedOmemoIdentityException - when there are undecided identities.public ClearTextMessage decrypt(org.jxmpp.jid.BareJid sender, org.jivesoftware.smack.packet.Message omemoMessage) throws java.lang.InterruptedException, org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.SmackException.NotConnectedException, CryptoFailedException, org.jivesoftware.smack.XMPPException.XMPPErrorException, CorruptedOmemoKeyException, NoRawSessionException
sender - sender of the messageomemoMessage - messagejava.lang.InterruptedException - ExceptionSmackException.NoResponseException - ExceptionSmackException.NotConnectedException - ExceptionCryptoFailedException - When decryption failsXMPPException.XMPPErrorException - ExceptionCorruptedOmemoKeyException - When the used keys are invalidNoRawSessionException - When there is no double ratchet session found for this messagepublic java.util.List<ClearTextMessage> decryptMamQueryResult(org.jivesoftware.smackx.mam.MamManager.MamQueryResult mamQueryResult) throws java.lang.InterruptedException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NoResponseException
mamQueryResult - mamQueryResultjava.lang.InterruptedException - ExceptionXMPPException.XMPPErrorException - ExceptionSmackException.NotConnectedException - ExceptionSmackException.NoResponseException - Exceptionpublic 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 purgeDevices()
throws org.jivesoftware.smack.SmackException,
java.lang.InterruptedException,
org.jivesoftware.smack.XMPPException.XMPPErrorException,
CorruptedOmemoKeyException
java.lang.InterruptedExceptionorg.jivesoftware.smack.SmackExceptionXMPPException.XMPPErrorExceptionCorruptedOmemoKeyExceptionpublic void regenerate()
throws org.jivesoftware.smack.SmackException,
java.lang.InterruptedException,
org.jivesoftware.smack.XMPPException.XMPPErrorException,
CorruptedOmemoKeyException
org.jivesoftware.smack.SmackExceptionjava.lang.InterruptedExceptionXMPPException.XMPPErrorExceptionCorruptedOmemoKeyExceptionpublic void sendRatchetUpdateMessage(OmemoDevice recipient) throws CorruptedOmemoKeyException, UndecidedOmemoIdentityException, CryptoFailedException, CannotEstablishOmemoSessionException
recipient - recipientUndecidedOmemoIdentityException - When the trust of session with the recipient is not decided yetCorruptedOmemoKeyException - When the used identityKeys are corruptedCryptoFailedException - When something fails with the cryptoCannotEstablishOmemoSessionException - When we can't establish a session with the recipientpublic OmemoVAxolotlElement createKeyTransportElement(byte[] aesKey, byte[] iv, OmemoDevice... to) throws UndecidedOmemoIdentityException, CorruptedOmemoKeyException, CryptoFailedException, CannotEstablishOmemoSessionException
aesKey - AES key to transportiv - Initialization vectorto - list of recipient devicesUndecidedOmemoIdentityException - When the trust of session with the recipient is not decided yetCorruptedOmemoKeyException - When the used identityKeys are corruptedCryptoFailedException - When something fails with the cryptoCannotEstablishOmemoSessionException - When we can't establish a session with the recipientpublic boolean contactSupportsOmemo(org.jxmpp.jid.BareJid contact)
throws org.jivesoftware.smack.SmackException.NotConnectedException,
java.lang.InterruptedException,
org.jivesoftware.smack.SmackException.NoResponseException
contact - contactSmackException.NotConnectedExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionpublic boolean resourceSupportsOmemo(org.jxmpp.jid.FullJid fullJid)
throws org.jivesoftware.smack.XMPPException.XMPPErrorException,
org.jivesoftware.smack.SmackException.NotConnectedException,
java.lang.InterruptedException,
org.jivesoftware.smack.SmackException.NoResponseException
fullJid - jid of a resourceXMPPException.XMPPErrorException - ifSmackException.NotConnectedException - somethingjava.lang.InterruptedException - goesSmackException.NoResponseException - wrongpublic boolean multiUserChatSupportsOmemo(org.jxmpp.jid.EntityBareJid multiUserChat)
throws org.jivesoftware.smack.XMPPException.XMPPErrorException,
org.jivesoftware.smack.SmackException.NotConnectedException,
java.lang.InterruptedException,
org.jivesoftware.smack.SmackException.NoResponseException
multiUserChat - EntityBareJid of the 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 getOurFingerprint()
public OmemoFingerprint getFingerprint(OmemoDevice device) throws CannotEstablishOmemoSessionException
public java.util.HashMap<OmemoDevice,OmemoFingerprint> getActiveFingerprints(org.jxmpp.jid.BareJid contact)
contact - contactpublic void addOmemoMessageListener(OmemoMessageListener listener)
public void removeOmemoMessageListener(OmemoMessageListener listener)
public void addOmemoMucMessageListener(OmemoMucMessageListener listener)
public void removeOmemoMucMessageListener(OmemoMucMessageListener listener)
public void buildSessionsWith(org.jxmpp.jid.BareJid contact)
throws java.lang.InterruptedException,
CannotEstablishOmemoSessionException,
org.jivesoftware.smack.SmackException.NotConnectedException,
org.jivesoftware.smack.SmackException.NoResponseException
contact - contact we want to build session with.java.lang.InterruptedExceptionCannotEstablishOmemoSessionExceptionSmackException.NotConnectedExceptionSmackException.NoResponseExceptionpublic void requestDeviceListUpdateFor(org.jxmpp.jid.BareJid contact)
throws org.jivesoftware.smack.SmackException.NotConnectedException,
java.lang.InterruptedException,
org.jivesoftware.smack.SmackException.NoResponseException
contact - contact we want to obtain the deviceList from.SmackException.NotConnectedExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionpublic void rotateSignedPreKey()
throws CorruptedOmemoKeyException,
java.lang.InterruptedException,
org.jivesoftware.smack.XMPPException.XMPPErrorException,
org.jivesoftware.smack.SmackException.NotConnectedException,
org.jivesoftware.smack.SmackException.NoResponseException,
org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException
CorruptedOmemoKeyException - When the IdentityKeyPair is damaged.java.lang.InterruptedException - XMPP errorXMPPException.XMPPErrorException - XMPP errorSmackException.NotConnectedException - XMPP errorSmackException.NoResponseException - XMPP errorPubSubException.NotALeafNodeException - if the bundle node on the server is a CollectionNodepublic static boolean stanzaContainsOmemoElement(org.jivesoftware.smack.packet.Stanza stanza)
stanza - stanzapublic static int randomDeviceId()
public org.jxmpp.jid.BareJid getOwnJid()
public int getDeviceId()
public OmemoDevice getOwnDevice()
public void shutdown()