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 java.lang.Object implements OmemoCarbonCopyStanzaReceivedListener, OmemoMessageStanzaReceivedListener
This class contains OMEMO related logic and registers listeners etc.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.logging.Logger
LOGGER
-
Constructor Summary
Constructors Modifier Constructor Description protected
OmemoService()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
createDefaultOmemoStoreBackend()
Create a default OmemoStore object.static OmemoService<?,?,?,?,?,?,?,?,?>
getInstance()
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.OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
getOmemoStoreBackend()
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 boolean
isServiceRegistered()
Returns true, if an instance of the service singleton is set.void
onOmemoCarbonCopyReceived(CarbonExtension.Direction direction, Message carbonCopy, Message wrappingMessage, OmemoManager.LoggedInOmemoManager managerGuard)
void
onOmemoMessageStanzaReceived(Stanza stanza, OmemoManager.LoggedInOmemoManager managerGuard)
protected abstract void
processBundle(OmemoManager omemoManager, T_Bundle contactsBundle, OmemoDevice contactsDevice)
Process a received bundle.void
purgeDeviceList(OmemoManager.LoggedInOmemoManager managerGuard)
Publish a new DeviceList with just our device in it.protected static void
setInstance(OmemoService<?,?,?,?,?,?,?,?,?> omemoService)
Set singleton instance.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.
-
-
-
Field Detail
-
LOGGER
protected static final java.util.logging.Logger LOGGER
-
-
Constructor Detail
-
OmemoService
protected OmemoService()
-
-
Method Detail
-
getInstance
public static OmemoService<?,?,?,?,?,?,?,?,?> getInstance()
Return the singleton instance of this class. When no instance is set, throw an IllegalStateException instead.- Returns:
- instance.
-
setInstance
protected static void setInstance(OmemoService<?,?,?,?,?,?,?,?,?> omemoService)
Set singleton instance. Throws an IllegalStateException, if there is already a service set as instance.- Parameters:
omemoService
- instance
-
isServiceRegistered
public static boolean 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,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> getOmemoStoreBackend()
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,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> createDefaultOmemoStoreBackend()
Create a default OmemoStore object.- Returns:
- default omemoStore.
-
instantiateOmemoRatchet
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. 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,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. 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 java.io.IOException
- Specified by:
onOmemoCarbonCopyReceived
in interfaceOmemoCarbonCopyStanzaReceivedListener
- Throws:
java.io.IOException
-
onOmemoMessageStanzaReceived
public void onOmemoMessageStanzaReceived(Stanza stanza, OmemoManager.LoggedInOmemoManager managerGuard) throws java.io.IOException
- Specified by:
onOmemoMessageStanzaReceived
in interfaceOmemoMessageStanzaReceivedListener
- Throws:
java.io.IOException
-
purgeDeviceList
public void purgeDeviceList(OmemoManager.LoggedInOmemoManager managerGuard) throws java.lang.InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, java.io.IOException, PubSubException.NotALeafNodeException
Publish a new DeviceList with just our device in it.- Parameters:
managerGuard
- authenticated OmemoManager.- Throws:
java.lang.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.java.io.IOException
- if an I/O error occurred.PubSubException.NotALeafNodeException
- if a PubSub leaf node operation was attempted on a non-leaf node.
-
-