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>
OmemoStore class that uses plain files for storage.| 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, storeOmemoPreKeyspublic T_IdKeyPair loadOmemoIdentityKeyPair(OmemoDevice userDevice) throws CorruptedOmemoKeyException, java.io.IOException
OmemoStoreloadOmemoIdentityKeyPair 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!)java.io.IOException - if an I/O error occurred.public void storeOmemoIdentityKeyPair(OmemoDevice userDevice, T_IdKeyPair identityKeyPair) throws java.io.IOException
OmemoStorestoreOmemoIdentityKeyPair 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 - identityKeyPairjava.io.IOException - if an I/O error occurred.public void removeOmemoIdentityKeyPair(OmemoDevice userDevice)
OmemoStoreremoveOmemoIdentityKeyPair 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, java.io.IOException
OmemoStoreloadOmemoIdentityKey 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.java.io.IOException - if an I/O error occurred.public void storeOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice, T_IdKey t_idKey) throws java.io.IOException
OmemoStorestoreOmemoIdentityKey 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.java.io.IOException - if an I/O error occurred.public void removeOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice)
OmemoStoreremoveOmemoIdentityKey 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)
OmemoStorelocalDeviceIdsOf 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) throws java.io.IOException
OmemoStoresetDateOfLastReceivedMessage 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 messagejava.io.IOException - if an I/O error occurred.public java.util.Date getDateOfLastReceivedMessage(OmemoDevice userDevice, OmemoDevice contactsDevice) throws java.io.IOException
OmemoStoregetDateOfLastReceivedMessage 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 questionjava.io.IOException - if an I/O error occurred.public void setDateOfLastDeviceIdPublication(OmemoDevice userDevice, OmemoDevice contactsDevice, java.util.Date date) throws java.io.IOException
OmemoStoresetDateOfLastDeviceIdPublication 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 publishedjava.io.IOException - if an I/O error occurred.public java.util.Date getDateOfLastDeviceIdPublication(OmemoDevice userDevice, OmemoDevice contactsDevice) throws java.io.IOException
OmemoStoregetDateOfLastDeviceIdPublication 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 questionjava.io.IOException - if an I/O error occurred.public void setDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice, java.util.Date date) throws java.io.IOException
OmemoStoresetDateOfLastSignedPreKeyRenewal 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 - datejava.io.IOException - if an I/O error occurred.public java.util.Date getDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice) throws java.io.IOException
OmemoStoregetDateOfLastSignedPreKeyRenewal in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>userDevice - our OmemoDevice.java.io.IOException - if an I/O error occurred.public T_PreKey loadOmemoPreKey(OmemoDevice userDevice, int preKeyId) throws java.io.IOException
OmemoStoreloadOmemoPreKey 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 loadedjava.io.IOException - if an I/O error occurred.public void storeOmemoPreKey(OmemoDevice userDevice, int preKeyId, T_PreKey t_preKey) throws java.io.IOException
OmemoStorestoreOmemoPreKey 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 - keyjava.io.IOException - if an I/O error occurred.public void removeOmemoPreKey(OmemoDevice userDevice, int preKeyId)
OmemoStoreremoveOmemoPreKey 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) throws java.io.IOException
OmemoStoreloadOmemoPreKeys in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>userDevice - our OmemoDevice.java.io.IOException - if an I/O error occurred.public T_SigPreKey loadOmemoSignedPreKey(OmemoDevice userDevice, int signedPreKeyId) throws java.io.IOException
OmemoStoreloadOmemoSignedPreKey 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 keyjava.io.IOException - if an I/O error occurred.public java.util.TreeMap<java.lang.Integer,T_SigPreKey> loadOmemoSignedPreKeys(OmemoDevice userDevice) throws java.io.IOException
OmemoStoreloadOmemoSignedPreKeys in class OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>userDevice - our OmemoDevice.java.io.IOException - if an I/O error occurred.public void storeOmemoSignedPreKey(OmemoDevice userDevice, int signedPreKeyId, T_SigPreKey signedPreKey) throws java.io.IOException
OmemoStorestoreOmemoSignedPreKey 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 itselfjava.io.IOException - if an I/O error occurred.public void removeOmemoSignedPreKey(OmemoDevice userDevice, int signedPreKeyId)
OmemoStoreremoveOmemoSignedPreKey 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) throws java.io.IOException
OmemoStoreloadRawSession 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 loadjava.io.IOException - if an I/O error occurred.public java.util.HashMap<java.lang.Integer,T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, org.jxmpp.jid.BareJid contact) throws java.io.IOException
OmemoStoreloadAllRawSessionsOf 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 fromjava.io.IOException - if an I/O error occurred.public void storeRawSession(OmemoDevice userDevice, OmemoDevice contactsDevice, T_Sess session) throws java.io.IOException
OmemoStorestoreRawSession 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 - sessionjava.io.IOException - if an I/O error occurred.public void removeRawSession(OmemoDevice userDevice, OmemoDevice contactsDevice)
OmemoStoreremoveRawSession 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)
OmemoStoreremoveAllRawSessionsOf 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)
OmemoStorecontainsRawSession 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) throws java.io.IOException
OmemoStorestoreOmemoMessageCounter 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.java.io.IOException - if an I/O error occurred.public int loadOmemoMessageCounter(OmemoDevice userDevice, OmemoDevice contactsDevice) throws java.io.IOException
OmemoStoreloadOmemoMessageCounter 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.java.io.IOException - if an I/O error occurred.public OmemoCachedDeviceList loadCachedDeviceList(OmemoDevice userDevice, org.jxmpp.jid.BareJid contact) throws java.io.IOException
OmemoStoreloadCachedDeviceList 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 ofjava.io.IOException - if an I/O error occurred.public void storeCachedDeviceList(OmemoDevice userDevice, org.jxmpp.jid.BareJid contact, OmemoCachedDeviceList contactsDeviceList) throws java.io.IOException
OmemoStorestoreCachedDeviceList 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.java.io.IOException - if an I/O error occurred.public void purgeOwnDeviceKeys(OmemoDevice userDevice)
OmemoStorepurgeOwnDeviceKeys 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 - directory to be deletedpublic 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.