Class OmemoMessageBuilder<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.util.OmemoMessageBuilder<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
public class OmemoMessageBuilder<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
extends Object
Class used to build OMEMO messages.
-
Constructor Summary
ConstructorsConstructorDescriptionOmemoMessageBuilder(OmemoDevice userDevice, OmemoTrustCallback callback, OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> ratchet, byte[] aesKey, byte[] iv, String message) Create an OmemoMessageBuilder.OmemoMessageBuilder(OmemoDevice userDevice, OmemoTrustCallback callback, OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> ratchet, String message) Create an OmemoMessageBuilder. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRecipient(OmemoDevice contactsDevice) Add a new recipient device to the message.finish()Assemble an OmemoMessageElement from the current state of the builder.static byte[]Generate a 12 byte initialization vector for AES encryption.static byte[]generateKey(String keyType, int keyLength) Generate a new AES key used to encrypt the message.
-
Constructor Details
-
OmemoMessageBuilder
public OmemoMessageBuilder(OmemoDevice userDevice, OmemoTrustCallback callback, OmemoRatchet<T_IdKeyPair, T_IdKey, throws NoSuchPaddingException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidAlgorithmParameterExceptionT_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> ratchet, byte[] aesKey, byte[] iv, String message) Create an OmemoMessageBuilder.- Parameters:
userDevice- our OmemoDevicecallback- trustCallback for querying trust decisionsratchet- our OmemoRatchetaesKey- aes message key used for message encryptioniv- initialization vector used for message encryptionmessage- message we want to send- Throws:
NoSuchPaddingException- if the requested padding mechanism is not available.BadPaddingException- if the input data is not padded properly.InvalidKeyException- if the key is invalid.NoSuchAlgorithmException- if no such algorithm is available.IllegalBlockSizeException- if the input data length is incorrect.InvalidAlgorithmParameterException- if the provided arguments are invalid.
-
OmemoMessageBuilder
public OmemoMessageBuilder(OmemoDevice userDevice, OmemoTrustCallback callback, OmemoRatchet<T_IdKeyPair, T_IdKey, throws NoSuchPaddingException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidAlgorithmParameterExceptionT_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> ratchet, String message) Create an OmemoMessageBuilder.- Parameters:
userDevice- our OmemoDevicecallback- trustCallback for querying trust decisionsratchet- our OmemoRatchetmessage- message we want to send- Throws:
NoSuchPaddingException- if the requested padding mechanism is not available.BadPaddingException- if the input data is not padded properly.InvalidKeyException- if the key is invalid.NoSuchAlgorithmException- if no such algorithm is available.IllegalBlockSizeException- if the input data length is incorrect.InvalidAlgorithmParameterException- if the provided arguments are invalid.
-
-
Method Details
-
addRecipient
public void addRecipient(OmemoDevice contactsDevice) throws NoIdentityKeyException, CorruptedOmemoKeyException, UndecidedOmemoIdentityException, UntrustedOmemoIdentityException, IOException Add a new recipient device to the message.- Parameters:
contactsDevice- device of the recipient- Throws:
NoIdentityKeyException- if we have no identityKey of that device. Can be fixed by fetching and processing the devices bundle.CorruptedOmemoKeyException- if the identityKey of that device is corrupted.UndecidedOmemoIdentityException- if the user hasn't yet decided whether to trust that device or not.UntrustedOmemoIdentityException- if the user has decided not to trust that device.IOException- if an I/O error occurred.
-
finish
Assemble an OmemoMessageElement from the current state of the builder.- Returns:
- OMEMO element
-
generateKey
Generate a new AES key used to encrypt the message.- Parameters:
keyType- Key TypekeyLength- Key Length in bit- Returns:
- new AES key
- Throws:
NoSuchAlgorithmException- if no such algorithm is available.
-
generateIv
Generate a 12 byte initialization vector for AES encryption.- Returns:
- initialization vector
-