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, java.io.IOException
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!)java.io.IOException
- if an I/O error occured.public void storeOmemoIdentityKeyPair(OmemoDevice userDevice, T_IdKeyPair identityKeyPair) throws java.io.IOException
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
- identityKeyPairjava.io.IOException
- if an I/O error occured.public 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, java.io.IOException
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.java.io.IOException
- if an I/O error occured.public void storeOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice, T_IdKey t_idKey) throws java.io.IOException
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.java.io.IOException
- if an I/O error occured.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) throws java.io.IOException
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 messagejava.io.IOException
- if an I/O error occured.public java.util.Date getDateOfLastReceivedMessage(OmemoDevice userDevice, OmemoDevice contactsDevice) throws java.io.IOException
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 questionjava.io.IOException
- if an I/O error occured.public void setDateOfLastDeviceIdPublication(OmemoDevice userDevice, OmemoDevice contactsDevice, java.util.Date date) throws java.io.IOException
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 publishedjava.io.IOException
- if an I/O error occured.public java.util.Date getDateOfLastDeviceIdPublication(OmemoDevice userDevice, OmemoDevice contactsDevice) throws java.io.IOException
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 questionjava.io.IOException
- if an I/O error occured.public void setDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice, java.util.Date date) throws java.io.IOException
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
- datejava.io.IOException
- if an I/O error occured.public java.util.Date getDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice) throws java.io.IOException
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.java.io.IOException
- if an I/O error occured.public T_PreKey loadOmemoPreKey(OmemoDevice userDevice, int preKeyId) throws java.io.IOException
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 loadedjava.io.IOException
- if an I/O error occured.public void storeOmemoPreKey(OmemoDevice userDevice, int preKeyId, T_PreKey t_preKey) throws java.io.IOException
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
- keyjava.io.IOException
- if an I/O error occured.public 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) throws java.io.IOException
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.java.io.IOException
- if an I/O error occured.public T_SigPreKey loadOmemoSignedPreKey(OmemoDevice userDevice, int signedPreKeyId) throws java.io.IOException
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 keyjava.io.IOException
- if an I/O error occured.public java.util.TreeMap<java.lang.Integer,T_SigPreKey> loadOmemoSignedPreKeys(OmemoDevice userDevice) throws java.io.IOException
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.java.io.IOException
- if an I/O error occured.public void storeOmemoSignedPreKey(OmemoDevice userDevice, int signedPreKeyId, T_SigPreKey signedPreKey) throws java.io.IOException
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 itselfjava.io.IOException
- if an I/O error occured.public 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) throws java.io.IOException
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 loadjava.io.IOException
- if an I/O error occured.public java.util.HashMap<java.lang.Integer,T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, org.jxmpp.jid.BareJid contact) throws java.io.IOException
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 fromjava.io.IOException
- if an I/O error occured.public void storeRawSession(OmemoDevice userDevice, OmemoDevice contactsDevice, T_Sess session) throws java.io.IOException
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
- sessionjava.io.IOException
- if an I/O error occured.public 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) throws java.io.IOException
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.java.io.IOException
- if an I/O error occured.public int loadOmemoMessageCounter(OmemoDevice userDevice, OmemoDevice contactsDevice) throws java.io.IOException
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.java.io.IOException
- if an I/O error occured.public OmemoCachedDeviceList loadCachedDeviceList(OmemoDevice userDevice, org.jxmpp.jid.BareJid contact) throws java.io.IOException
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 ofjava.io.IOException
- if an I/O error occured.public void storeCachedDeviceList(OmemoDevice userDevice, org.jxmpp.jid.BareJid contact, OmemoCachedDeviceList contactsDeviceList) throws java.io.IOException
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.java.io.IOException
- if an I/O error occured.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
- TODO javadoc me pleasepublic 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.