public final class OmemoManager extends 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,
Message omemoMessage)
Decrypt an OMEMO message.
|
java.util.List<ClearTextMessage> |
decryptMamQueryResult(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.
|
Message |
encrypt(java.util.ArrayList<org.jxmpp.jid.BareJid> recipients,
java.lang.String message)
OMEMO encrypt a cleartext message for multiple recipients.
|
Message |
encrypt(org.jxmpp.jid.BareJid to,
java.lang.String message)
OMEMO encrypt a cleartext message for a single recipient.
|
Message |
encrypt(MultiUserChat muc,
java.lang.String message)
Encrypt a message for all recipients in the MultiUserChat.
|
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(XMPPConnection connection)
Get an instance of the OmemoManager for the given connection.
|
static OmemoManager |
getInstanceFor(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.
|
void |
rotateSignedPreKey()
Rotate the signedPreKey published in our OmemoBundle.
|
void |
sendRatchetUpdateMessage(OmemoDevice recipient)
Send a ratchet update message.
|
static boolean |
serverSupportsOmemo(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(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.
|
connection, getAuthenticatedConnectionOrThrow, schedulepublic static OmemoManager getInstanceFor(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(XMPPConnection connection)
connection - connectionpublic void initialize() throws CorruptedOmemoKeyException, java.lang.InterruptedException, SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, SmackException.NotLoggedInException, PubSubException.NotALeafNodeException
CorruptedOmemoKeyExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionXMPPException.XMPPErrorExceptionSmackException.NotLoggedInExceptionPubSubException.NotALeafNodeExceptionpublic Message encrypt(org.jxmpp.jid.BareJid to, java.lang.String message) throws CryptoFailedException, UndecidedOmemoIdentityException, java.security.NoSuchAlgorithmException, java.lang.InterruptedException, CannotEstablishOmemoSessionException, SmackException.NotConnectedException, 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 Message encrypt(java.util.ArrayList<org.jxmpp.jid.BareJid> recipients, java.lang.String message) throws CryptoFailedException, UndecidedOmemoIdentityException, java.security.NoSuchAlgorithmException, java.lang.InterruptedException, CannotEstablishOmemoSessionException, SmackException.NotConnectedException, 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 Message encrypt(MultiUserChat muc, java.lang.String message) throws UndecidedOmemoIdentityException, java.security.NoSuchAlgorithmException, CryptoFailedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException, 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 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, Message omemoMessage) throws java.lang.InterruptedException, SmackException.NoResponseException, SmackException.NotConnectedException, CryptoFailedException, 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(MamManager.MamQueryResult mamQueryResult) throws java.lang.InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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 SmackException, java.lang.InterruptedException, XMPPException.XMPPErrorException, CorruptedOmemoKeyException
java.lang.InterruptedExceptionSmackExceptionXMPPException.XMPPErrorExceptionCorruptedOmemoKeyExceptionpublic void regenerate() throws SmackException, java.lang.InterruptedException, XMPPException.XMPPErrorException, CorruptedOmemoKeyException
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 SmackException.NotConnectedException, java.lang.InterruptedException, SmackException.NoResponseException
contact - contactSmackException.NotConnectedExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionpublic boolean multiUserChatSupportsOmemo(org.jxmpp.jid.EntityBareJid multiUserChat) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException, SmackException.NoResponseException
multiUserChat - EntityBareJid of the MUCXMPPException.XMPPErrorException - ifSmackException.NotConnectedException - somethingjava.lang.InterruptedException - goesSmackException.NoResponseException - wrongpublic static boolean serverSupportsOmemo(XMPPConnection connection, org.jxmpp.jid.DomainBareJid server) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException, 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, SmackException.NotConnectedException, SmackException.NoResponseException
contact - contact we want to build session with.java.lang.InterruptedExceptionCannotEstablishOmemoSessionExceptionSmackException.NotConnectedExceptionSmackException.NoResponseExceptionpublic void requestDeviceListUpdateFor(org.jxmpp.jid.BareJid contact) throws SmackException.NotConnectedException, java.lang.InterruptedException, SmackException.NoResponseException
contact - contact we want to obtain the deviceList from.SmackException.NotConnectedExceptionjava.lang.InterruptedExceptionSmackException.NoResponseExceptionpublic void rotateSignedPreKey() throws CorruptedOmemoKeyException, java.lang.InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, 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(Stanza stanza)
stanza - stanzapublic static int randomDeviceId()
public org.jxmpp.jid.BareJid getOwnJid()
public int getDeviceId()
public OmemoDevice getOwnDevice()
public void shutdown()