Package org.jivesoftware.smackx.omemo
Class OmemoService<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
java.lang.Object
org.jivesoftware.smackx.omemo.OmemoService<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
- Type Parameters:
T_IdKeyPair- IdentityKeyPair classT_IdKey- IdentityKey classT_PreKey- PreKey classT_SigPreKey- SignedPreKey classT_Sess- Session classT_Addr- Address classT_ECPub- Elliptic Curve PublicKey classT_Bundle- Bundle classT_Ciph- Cipher class
- All Implemented Interfaces:
OmemoCarbonCopyStanzaReceivedListener,OmemoMessageStanzaReceivedListener
- Direct Known Subclasses:
SignalOmemoService
public abstract class OmemoService<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
extends Object
implements OmemoCarbonCopyStanzaReceivedListener, OmemoMessageStanzaReceivedListener
This class contains OMEMO related logic and registers listeners etc.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract OmemoStore<T_IdKeyPair,T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> Create a default OmemoStore object.static OmemoService<?,?, ?, ?, ?, ?, ?, ?, ?> Return the singleton instance of this class.protected OmemoRatchet<T_IdKeyPair,T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> getOmemoRatchet(OmemoManager manager) Return the deposited instance of the OmemoRatchet for the given manager.Return the used omemoStore backend.protected abstract OmemoRatchet<T_IdKeyPair,T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> instantiateOmemoRatchet(OmemoManager manager, OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> store) Return a new instance of the OMEMO ratchet.static booleanReturns true, if an instance of the service singleton is set.voidonOmemoCarbonCopyReceived(CarbonExtension.Direction direction, Message carbonCopy, Message wrappingMessage, OmemoManager.LoggedInOmemoManager managerGuard) voidonOmemoMessageStanzaReceived(Stanza stanza, OmemoManager.LoggedInOmemoManager managerGuard) protected abstract voidprocessBundle(OmemoManager omemoManager, T_Bundle contactsBundle, OmemoDevice contactsDevice) Process a received bundle.voidpurgeDeviceList(OmemoManager.LoggedInOmemoManager managerGuard) Publish a new DeviceList with just our device in it.protected static voidsetInstance(OmemoService<?, ?, ?, ?, ?, ?, ?, ?, ?> omemoService) Set singleton instance.voidsetOmemoStoreBackend(OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> omemoStore) Set an omemoStore as backend.
-
Field Details
-
LOGGER
-
-
Constructor Details
-
OmemoService
protected OmemoService()
-
-
Method Details
-
getInstance
Return the singleton instance of this class. When no instance is set, throw an IllegalStateException instead.- Returns:
- instance.
-
setInstance
Set singleton instance. Throws an IllegalStateException, if there is already a service set as instance.- Parameters:
omemoService- instance
-
isServiceRegistered
Returns true, if an instance of the service singleton is set. Otherwise return false.- Returns:
- true, if instance is not null.
-
getOmemoStoreBackend
public OmemoStore<T_IdKeyPair,T_IdKey, getOmemoStoreBackend()T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> Return the used omemoStore backend. If there is no store backend set yet, set the default one (typically a file-based one).- Returns:
- omemoStore backend
-
setOmemoStoreBackend
public void setOmemoStoreBackend(OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> omemoStore) Set an omemoStore as backend. Throws an IllegalStateException, if there is already a backend set.- Parameters:
omemoStore- store.
-
createDefaultOmemoStoreBackend
protected abstract OmemoStore<T_IdKeyPair,T_IdKey, createDefaultOmemoStoreBackend()T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> Create a default OmemoStore object.- Returns:
- default omemoStore.
-
instantiateOmemoRatchet
protected abstract OmemoRatchet<T_IdKeyPair,T_IdKey, instantiateOmemoRatchetT_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> (OmemoManager manager, OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> store) Return a new instance of the OMEMO ratchet. The ratchet is internally used to encrypt/decrypt message keys.- Parameters:
manager- OmemoManagerstore- OmemoStore- Returns:
- instance of the OmemoRatchet
-
getOmemoRatchet
protected OmemoRatchet<T_IdKeyPair,T_IdKey, getOmemoRatchetT_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> (OmemoManager manager) Return the deposited instance of the OmemoRatchet for the given manager. If there is none yet, create a new one, deposit it and return it.- Parameters:
manager- OmemoManager we want to have the ratchet for.- Returns:
- OmemoRatchet instance
-
processBundle
protected abstract void processBundle(OmemoManager omemoManager, T_Bundle contactsBundle, OmemoDevice contactsDevice) throws CorruptedOmemoKeyException Process a received bundle. Typically, that includes saving keys and building a session.- Parameters:
omemoManager- our OmemoManagercontactsBundle- bundle of the contactcontactsDevice- OmemoDevice of the contact- Throws:
CorruptedOmemoKeyException- if the OMEMO key is corrupted.
-
onOmemoCarbonCopyReceived
public void onOmemoCarbonCopyReceived(CarbonExtension.Direction direction, Message carbonCopy, Message wrappingMessage, OmemoManager.LoggedInOmemoManager managerGuard) throws IOException - Specified by:
onOmemoCarbonCopyReceivedin interfaceOmemoCarbonCopyStanzaReceivedListener- Throws:
IOException
-
onOmemoMessageStanzaReceived
public void onOmemoMessageStanzaReceived(Stanza stanza, OmemoManager.LoggedInOmemoManager managerGuard) throws IOException - Specified by:
onOmemoMessageStanzaReceivedin interfaceOmemoMessageStanzaReceivedListener- Throws:
IOException
-
purgeDeviceList
public void purgeDeviceList(OmemoManager.LoggedInOmemoManager managerGuard) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, IOException, PubSubException.NotALeafNodeException Publish a new DeviceList with just our device in it.- Parameters:
managerGuard- authenticated OmemoManager.- Throws:
InterruptedException- if the calling thread was interrupted.XMPPException.XMPPErrorException- if there was an XMPP error returned.SmackException.NotConnectedException- if the XMPP connection is not connected.SmackException.NoResponseException- if there was no response from the remote entity.IOException- if an I/O error occurred.PubSubException.NotALeafNodeException- if a PubSub leaf node operation was attempted on a non-leaf node.
-