public abstract class FileBasedOmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> extends OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
Modifier and Type | Class and Description |
---|---|
static class |
FileBasedOmemoStore.FileHierarchy
This class represents the directory structure of the FileBasedOmemoStore.
|
Constructor and Description |
---|
FileBasedOmemoStore(java.io.File basePath) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsRawSession(OmemoDevice userDevice,
OmemoDevice contactsDevice)
Return true, if we have a session with the device, otherwise false.
|
static void |
deleteDirectory(java.io.File root)
Delete a directory with all subdirectories.
|
java.util.Date |
getDateOfLastDeviceIdPublication(OmemoDevice userDevice,
OmemoDevice contactsDevice)
Return the date of the last time the deviceId was published after previously being not published.
|
java.util.Date |
getDateOfLastReceivedMessage(OmemoDevice userDevice,
OmemoDevice contactsDevice)
Return the date of the last message that was received from device 'from'.
|
java.util.Date |
getDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice)
Get the date of the last time the signed preKey was renewed.
|
java.util.HashMap<java.lang.Integer,T_Sess> |
loadAllRawSessionsOf(OmemoDevice userDevice,
org.jxmpp.jid.BareJid contact)
Load all crypto-lib specific session objects of contact 'contact'.
|
OmemoCachedDeviceList |
loadCachedDeviceList(OmemoDevice userDevice,
org.jxmpp.jid.BareJid contact)
Load a list of deviceIds from contact 'contact' from the local cache.
|
T_IdKey |
loadOmemoIdentityKey(OmemoDevice userDevice,
OmemoDevice contactsDevice)
Load the public identityKey of a device.
|
T_IdKeyPair |
loadOmemoIdentityKeyPair(OmemoDevice userDevice)
Load our identityKeyPair from storage.
|
int |
loadOmemoMessageCounter(OmemoDevice userDevice,
OmemoDevice contactsDevice)
Return the current value of the message counter.
|
T_PreKey |
loadOmemoPreKey(OmemoDevice userDevice,
int preKeyId)
Load the preKey with id 'preKeyId' from storage.
|
java.util.TreeMap<java.lang.Integer,T_PreKey> |
loadOmemoPreKeys(OmemoDevice userDevice)
Return all our current OmemoPreKeys.
|
T_SigPreKey |
loadOmemoSignedPreKey(OmemoDevice userDevice,
int signedPreKeyId)
Return the signedPreKey with the id 'singedPreKeyId'.
|
java.util.TreeMap<java.lang.Integer,T_SigPreKey> |
loadOmemoSignedPreKeys(OmemoDevice userDevice)
Load all our signed PreKeys.
|
T_Sess |
loadRawSession(OmemoDevice userDevice,
OmemoDevice contactsDevice)
Load the crypto-lib specific session object of the device from storage.
|
java.util.SortedSet<java.lang.Integer> |
localDeviceIdsOf(org.jxmpp.jid.BareJid localUser)
Returns a sorted set of all the deviceIds, the localUser has had data stored under in the store.
|
void |
purgeOwnDeviceKeys(OmemoDevice userDevice)
Delete this device's IdentityKey, PreKeys, SignedPreKeys and Sessions.
|
void |
removeAllRawSessionsOf(OmemoDevice userDevice,
org.jxmpp.jid.BareJid contact)
Remove all crypto-lib specific session of a contact.
|
void |
removeOmemoIdentityKey(OmemoDevice userDevice,
OmemoDevice contactsDevice)
Removes the identityKey of a device.
|
void |
removeOmemoIdentityKeyPair(OmemoDevice userDevice)
Remove the identityKeyPair of a user.
|
void |
removeOmemoPreKey(OmemoDevice userDevice,
int preKeyId)
Remove a preKey from storage.
|
void |
removeOmemoSignedPreKey(OmemoDevice userDevice,
int signedPreKeyId)
Remove a signedPreKey from storage.
|
void |
removeRawSession(OmemoDevice userDevice,
OmemoDevice contactsDevice)
Remove a crypto-lib specific session from storage.
|
void |
setDateOfLastDeviceIdPublication(OmemoDevice userDevice,
OmemoDevice contactsDevice,
java.util.Date date)
Set the date of the last time the deviceId was published.
|
void |
setDateOfLastReceivedMessage(OmemoDevice userDevice,
OmemoDevice contactsDevice,
java.util.Date date)
Set the date of the last message that was received from a device.
|
void |
setDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice,
java.util.Date date)
Set the date of the last time the signed preKey was renewed.
|
void |
storeCachedDeviceList(OmemoDevice userDevice,
org.jxmpp.jid.BareJid contact,
OmemoCachedDeviceList contactsDeviceList)
Store the DeviceList of the contact in local storage.
|
void |
storeOmemoIdentityKey(OmemoDevice userDevice,
OmemoDevice contactsDevice,
T_IdKey t_idKey)
Store the public identityKey of the device.
|
void |
storeOmemoIdentityKeyPair(OmemoDevice userDevice,
T_IdKeyPair identityKeyPair)
Store our identityKeyPair in storage.
|
void |
storeOmemoMessageCounter(OmemoDevice userDevice,
OmemoDevice contactsDevice,
int counter)
Store the number of messages we sent to a device since we last received a message back.
|
void |
storeOmemoPreKey(OmemoDevice userDevice,
int preKeyId,
T_PreKey t_preKey)
Store a PreKey in storage.
|
void |
storeOmemoSignedPreKey(OmemoDevice userDevice,
int signedPreKeyId,
T_SigPreKey signedPreKey)
Store a signedPreKey in storage.
|
void |
storeRawSession(OmemoDevice userDevice,
OmemoDevice contactsDevice,
T_Sess session)
Store a crypto-lib specific session to storage.
|
static void |
useLegacyBareJidEncoding()
Convert
BareJids to Strings using the legacy Jid.toString() method instead of the
proper, url safe Jid.asUrlEncodedString() method. |
generateOmemoIdentityKeyPair, generateOmemoPreKeys, generateOmemoSignedPreKey, getFingerprint, getFingerprint, getFingerprintAndMaybeBuildSession, keyUtil, loadCachedDeviceList, loadCurrentOmemoSignedPreKeyId, replenishKeys, storeOmemoPreKeys
public T_IdKeyPair loadOmemoIdentityKeyPair(OmemoDevice userDevice) throws CorruptedOmemoKeyException
OmemoStore
loadOmemoIdentityKeyPair
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.CorruptedOmemoKeyException
- Thrown, if the stored key is damaged (*hands up* not my fault!)public void storeOmemoIdentityKeyPair(OmemoDevice userDevice, T_IdKeyPair identityKeyPair)
OmemoStore
storeOmemoIdentityKeyPair
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.identityKeyPair
- identityKeyPairpublic void removeOmemoIdentityKeyPair(OmemoDevice userDevice)
OmemoStore
removeOmemoIdentityKeyPair
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our device.public T_IdKey loadOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice) throws CorruptedOmemoKeyException
OmemoStore
loadOmemoIdentityKey
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contactsDevice
- the device of which we want to load the identityKey.CorruptedOmemoKeyException
- when the key in question is corrupted and cant be deserialized.public void storeOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice, T_IdKey t_idKey)
OmemoStore
storeOmemoIdentityKey
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contactsDevice
- device.t_idKey
- identityKey belonging to the contactsDevice.public void removeOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice)
OmemoStore
removeOmemoIdentityKey
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our omemoDevice.contactsDevice
- device of which we want to delete the identityKey.public java.util.SortedSet<java.lang.Integer> localDeviceIdsOf(org.jxmpp.jid.BareJid localUser)
OmemoStore
localDeviceIdsOf
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
localUser
- BareJid of the user.public void setDateOfLastReceivedMessage(OmemoDevice userDevice, OmemoDevice contactsDevice, java.util.Date date)
OmemoStore
setDateOfLastReceivedMessage
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- omemoManager of our device.contactsDevice
- device in questiondate
- date of the last received messagepublic java.util.Date getDateOfLastReceivedMessage(OmemoDevice userDevice, OmemoDevice contactsDevice)
OmemoStore
getDateOfLastReceivedMessage
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contactsDevice
- device in questionpublic void setDateOfLastDeviceIdPublication(OmemoDevice userDevice, OmemoDevice contactsDevice, java.util.Date date)
OmemoStore
setDateOfLastDeviceIdPublication
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevicecontactsDevice
- OmemoDevice in questiondate
- date of the last publication after not being publishedpublic java.util.Date getDateOfLastDeviceIdPublication(OmemoDevice userDevice, OmemoDevice contactsDevice)
OmemoStore
getDateOfLastDeviceIdPublication
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevicecontactsDevice
- OmemoDevice in questionpublic void setDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice, java.util.Date date)
OmemoStore
setDateOfLastSignedPreKeyRenewal
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.date
- datepublic java.util.Date getDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice)
OmemoStore
getDateOfLastSignedPreKeyRenewal
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.public T_PreKey loadOmemoPreKey(OmemoDevice userDevice, int preKeyId)
OmemoStore
loadOmemoPreKey
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.preKeyId
- id of the key to be loadedpublic void storeOmemoPreKey(OmemoDevice userDevice, int preKeyId, T_PreKey t_preKey)
OmemoStore
storeOmemoPreKey
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.preKeyId
- id of the keyt_preKey
- keypublic void removeOmemoPreKey(OmemoDevice userDevice, int preKeyId)
OmemoStore
removeOmemoPreKey
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.preKeyId
- id of the used key that will be deletedpublic java.util.TreeMap<java.lang.Integer,T_PreKey> loadOmemoPreKeys(OmemoDevice userDevice)
OmemoStore
loadOmemoPreKeys
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.public T_SigPreKey loadOmemoSignedPreKey(OmemoDevice userDevice, int signedPreKeyId)
OmemoStore
loadOmemoSignedPreKey
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.signedPreKeyId
- id of the keypublic java.util.TreeMap<java.lang.Integer,T_SigPreKey> loadOmemoSignedPreKeys(OmemoDevice userDevice)
OmemoStore
loadOmemoSignedPreKeys
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.public void storeOmemoSignedPreKey(OmemoDevice userDevice, int signedPreKeyId, T_SigPreKey signedPreKey)
OmemoStore
storeOmemoSignedPreKey
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.signedPreKeyId
- id of the signedPreKeysignedPreKey
- the key itselfpublic void removeOmemoSignedPreKey(OmemoDevice userDevice, int signedPreKeyId)
OmemoStore
removeOmemoSignedPreKey
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.signedPreKeyId
- id of the key that will be removedpublic T_Sess loadRawSession(OmemoDevice userDevice, OmemoDevice contactsDevice)
OmemoStore
loadRawSession
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contactsDevice
- device whose session we want to loadpublic java.util.HashMap<java.lang.Integer,T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, org.jxmpp.jid.BareJid contact)
OmemoStore
loadAllRawSessionsOf
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contact
- BareJid of the contact we want to get all sessions frompublic void storeRawSession(OmemoDevice userDevice, OmemoDevice contactsDevice, T_Sess session)
OmemoStore
storeRawSession
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contactsDevice
- OmemoDevice whose session we want to storesession
- sessionpublic void removeRawSession(OmemoDevice userDevice, OmemoDevice contactsDevice)
OmemoStore
removeRawSession
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contactsDevice
- device whose session we want to deletepublic void removeAllRawSessionsOf(OmemoDevice userDevice, org.jxmpp.jid.BareJid contact)
OmemoStore
removeAllRawSessionsOf
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contact
- BareJid of the contactpublic boolean containsRawSession(OmemoDevice userDevice, OmemoDevice contactsDevice)
OmemoStore
containsRawSession
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contactsDevice
- devicepublic void storeOmemoMessageCounter(OmemoDevice userDevice, OmemoDevice contactsDevice, int counter)
OmemoStore
storeOmemoMessageCounter
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our omemoDevice.contactsDevice
- device of which we want to set the message counter.counter
- counter value.public int loadOmemoMessageCounter(OmemoDevice userDevice, OmemoDevice contactsDevice)
OmemoStore
loadOmemoMessageCounter
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our omemoDevicecontactsDevice
- device of which we want to get the message counter.public OmemoCachedDeviceList loadCachedDeviceList(OmemoDevice userDevice, org.jxmpp.jid.BareJid contact)
OmemoStore
loadCachedDeviceList
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contact
- contact we want to get the deviceList ofpublic void storeCachedDeviceList(OmemoDevice userDevice, org.jxmpp.jid.BareJid contact, OmemoCachedDeviceList contactsDeviceList)
OmemoStore
storeCachedDeviceList
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.contact
- ContactcontactsDeviceList
- list of the contacts devices' ids.public void purgeOwnDeviceKeys(OmemoDevice userDevice)
OmemoStore
purgeOwnDeviceKeys
in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
userDevice
- our OmemoDevice.public static void deleteDirectory(java.io.File root)
root
- public static void useLegacyBareJidEncoding()
BareJids
to Strings using the legacy Jid.toString()
method instead of the
proper, url safe Jid.asUrlEncodedString()
method.
While it is highly advised to use the new format, you can use this method to stay backwards compatible to data
sets created by the old implementation.