1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-24 15:22:07 +01:00

Fix javadoc issues

This commit is contained in:
Paul Schaub 2019-12-13 18:25:46 +01:00
parent 10aee6c787
commit a8b2446042
23 changed files with 126 additions and 98 deletions

View file

@ -149,7 +149,6 @@ public class SignalOmemoRatchet
throw new AssertionError("Signals trust management MUST be disabled.");
}
// TODO: Figure out, if this is enough...
int type = ciphertextMessage.getType() == CiphertextMessage.PREKEY_TYPE ?
OmemoElement.TYPE_OMEMO_PREKEY_MESSAGE : OmemoElement.TYPE_OMEMO_MESSAGE;

View file

@ -87,8 +87,9 @@ public class SignalOmemoStoreConnector
}
/**
* We don't use this.
* @return dummy TODO javadoc me please
* The OMEMO protocol does not make use of a local registration ID, so we can simply return 0 here.
*
* @return local registration id.
*/
@Override
public int getLocalRegistrationId() {

View file

@ -437,8 +437,9 @@ public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Se
/**
* Return the {@link KeyCache} object of an {@link OmemoManager}.
* @param device TODO javadoc me please
* @return
*
* @param device OMEMO device of which we want to have the cache.
* @return key cache of the device
*/
private KeyCache<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess> getCache(OmemoDevice device) {
KeyCache<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess> cache = caches.get(device);
@ -451,11 +452,12 @@ public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Se
/**
* Cache that stores values for an {@link OmemoManager}.
* @param <T_IdKeyPair>
* @param <T_IdKey>
* @param <T_PreKey>
* @param <T_SigPreKey>
* @param <T_Sess>
*
* @param <T_IdKeyPair> type of the identity key pair
* @param <T_IdKey> type of the public identity key
* @param <T_PreKey> type of a public preKey
* @param <T_SigPreKey> type of the public signed preKey
* @param <T_Sess> type of the OMEMO session
*/
private static class KeyCache<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess> {
private T_IdKeyPair identityKeyPair;

View file

@ -45,6 +45,7 @@ import org.jxmpp.jid.BareJid;
/**
* Like a rocket!
* Implementation of the {@link OmemoStore} class that uses plain files for storage.
*
* @author Paul Schaub
*/
@ -514,7 +515,7 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
/**
* Delete a directory with all subdirectories.
* @param root TODO javadoc me please
* @param root directory to be deleted
*/
public static void deleteDirectory(File root) {
File[] currList;

View file

@ -30,7 +30,7 @@ public final class OmemoConfiguration {
* Set to true, in order to ignore read-only devices.
*
* @param ignore ignore read-only devices
* @see <a href="example.com">Blog Post explaining the danger of read-only devices. TODO: Add URL </a>
* @see <a href="https://blog.jabberhead.tk/2019/12/13/pitfalls-for-omemo-implementations-part-1-inactive-devices/">Blog Post explaining the danger of read-only devices.</a>
*/
public static void setIgnoreReadOnlyDevices(boolean ignore) {
IGNORE_READ_ONLY_DEVICES = ignore;
@ -40,7 +40,7 @@ public final class OmemoConfiguration {
* Return true, if the client should stop encrypting messages to a read-only device.
*
* @return true if read-only devices should get ignored after a certain amount of unanswered messages.
* @see <a href="example.com">Blog Post explaining the danger of read-only devices. TODO: Add URL </a>
* @see <a href="https://blog.jabberhead.tk/2019/12/13/pitfalls-for-omemo-implementations-part-1-inactive-devices/">Blog Post explaining the danger of read-only devices.</a>
*/
public static boolean getIgnoreReadOnlyDevices() {
return IGNORE_READ_ONLY_DEVICES;
@ -53,7 +53,7 @@ public final class OmemoConfiguration {
* This threshold is used to prevent read-only devices from weakening forward secrecy.
*
* @param maxReadOnlyMessageCount maximum number of allowed messages to a read-only device.
* @see <a href="example.com">Blog Post explaining the danger of read-only devices. TODO: Add URL </a>
* @see <a href="https://blog.jabberhead.tk/2019/12/13/pitfalls-for-omemo-implementations-part-1-inactive-devices/">Blog Post explaining the danger of read-only devices.</a>
*/
public static void setMaxReadOnlyMessageCount(int maxReadOnlyMessageCount) {
if (maxReadOnlyMessageCount <= 0) {
@ -69,7 +69,7 @@ public final class OmemoConfiguration {
* This threshold is used to prevent read-only devices from weakening forward secrecy.
*
* @return maximum number of allowed messages to a read-only device.
* @see <a href="example.com">Blog Post explaining the danger of read-only devices. TODO: Add URL </a>
* @see <a href="https://blog.jabberhead.tk/2019/12/13/pitfalls-for-omemo-implementations-part-1-inactive-devices/">Blog Post explaining the danger of read-only devices.</a>
*/
public static int getMaxReadOnlyMessageCount() {
return MAX_READ_ONLY_MESSAGE_COUNT;

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.omemo;
import org.jivesoftware.smack.initializer.UrlInitializer;
/**
* Initializer class that registers omemo providers.
* Initializer class that registers OMEMO providers.
*
* @author Paul Schaub
*/

View file

@ -151,7 +151,7 @@ public final class OmemoManager extends Manager {
* @param connection XmppConnection.
* @param deviceId MUST NOT be null and MUST be greater than 0.
*
* @return manager TODO javadoc me please
* @return OmemoManager instance for the given connection and deviceId.
*/
public static synchronized OmemoManager getInstanceFor(XMPPConnection connection, Integer deviceId) {
if (deviceId == null || deviceId < 1) {
@ -182,7 +182,7 @@ public final class OmemoManager extends Manager {
*
* @param connection XmppConnection.
*
* @return manager TODO javadoc me please
* @return OmemoManager instance for the given connection and a determined deviceId.
*/
public static synchronized OmemoManager getInstanceFor(XMPPConnection connection) {
TreeMap<Integer, OmemoManager> managers = INSTANCES.get(connection);
@ -219,7 +219,8 @@ public final class OmemoManager extends Manager {
/**
* Return the TrustCallback of this manager.
* @return
*
* @return callback that is used for trust decisions.
*/
OmemoTrustCallback getTrustCallback() {
return trustCallback;
@ -530,10 +531,11 @@ public final class OmemoManager extends Manager {
*
* @param multiUserChat MUC
* @return true if chat supports OMEMO
* @throws XMPPException.XMPPErrorException if
* @throws SmackException.NotConnectedException something
* @throws InterruptedException goes
* @throws SmackException.NoResponseException wrong
*
* @throws XMPPException.XMPPErrorException if there was an XMPP protocol level error
* @throws SmackException.NotConnectedException if the connection is not connected
* @throws InterruptedException if the thread is interrupted
* @throws SmackException.NoResponseException if the server does not respond
*/
public boolean multiUserChatSupportsOmemo(MultiUserChat multiUserChat)
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
@ -564,7 +566,8 @@ public final class OmemoManager extends Manager {
/**
* Return the fingerprint of our identity key.
*
* @return fingerprint TODO javadoc me please
* @return our own OMEMO fingerprint
*
* @throws SmackException.NotLoggedInException if we don't know our bareJid yet.
* @throws CorruptedOmemoKeyException if our identityKey is corrupted.
* @throws IOException if an I/O error occurred.
@ -580,8 +583,10 @@ public final class OmemoManager extends Manager {
/**
* Get the fingerprint of a contacts device.
*
* @param device contacts OmemoDevice
* @return fingerprint TODO javadoc me please
* @return fingerprint of the given OMEMO device.
*
* @throws CannotEstablishOmemoSessionException if we have no session yet, and are unable to create one.
* @throws SmackException.NotLoggedInException if the XMPP connection is not authenticated.
* @throws CorruptedOmemoKeyException if the copy of the fingerprint we have is corrupted.
@ -763,7 +768,8 @@ public final class OmemoManager extends Manager {
/**
* Returns a pseudo random number from the interval [1, Integer.MAX_VALUE].
* @return deviceId TODO javadoc me please
*
* @return a random deviceId.
*/
public static int randomDeviceId() {
return new Random().nextInt(Integer.MAX_VALUE - 1) + 1;
@ -772,7 +778,7 @@ public final class OmemoManager extends Manager {
/**
* Return the BareJid of the user.
*
* @return bareJid TODO javadoc me please
* @return our own bare JID.
*/
public BareJid getOwnJid() {
if (ownJid == null && connection().isAuthenticated()) {
@ -785,7 +791,7 @@ public final class OmemoManager extends Manager {
/**
* Return the deviceId of this OmemoManager.
*
* @return deviceId TODO javadoc me please
* @return this OmemoManagers deviceId.
*/
public synchronized Integer getDeviceId() {
return deviceId;
@ -794,7 +800,7 @@ public final class OmemoManager extends Manager {
/**
* Return the OmemoDevice of the user.
*
* @return omemoDevice TODO javadoc me please
* @return our own OmemoDevice
*/
public synchronized OmemoDevice getOwnDevice() {
BareJid jid = getOwnJid();
@ -926,7 +932,7 @@ public final class OmemoManager extends Manager {
/**
* Return the OMEMO service object.
*
* @return omemoService TODO javadoc me please
* @return the OmemoService object related to this OmemoManager.
*/
OmemoService<?, ?, ?, ?, ?, ?, ?, ?, ?> getOmemoService() {
throwIfNoServiceSet();

View file

@ -49,7 +49,7 @@ public class OmemoMessage {
/**
* Return the original OmemoElement (&lt;encrypted/&gt;).
*
* @return omemoElement TODO javadoc me please
* @return omemoElement of the message
*/
public OmemoElement getElement() {
return element;
@ -58,7 +58,7 @@ public class OmemoMessage {
/**
* Return the messageKey (or transported key in case of a KeyTransportMessage).
*
* @return key TODO javadoc me please
* @return encryption key that protects the message payload
*/
public byte[] getKey() {
return messageKey.clone();
@ -66,6 +66,7 @@ public class OmemoMessage {
/**
* Return the initialization vector belonging to the key.
*
* @return initialization vector
*/
public byte[] getIv() {
@ -189,7 +190,8 @@ public class OmemoMessage {
/**
* Return the OmemoDevice which sent the message.
* @return senderDevice TODO javadoc me please
*
* @return OMEMO device that sent the message.
*/
public OmemoDevice getSenderDevice() {
return senderDevice;

View file

@ -107,17 +107,11 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
private static final long MILLIS_PER_HOUR = 1000L * 60 * 60;
/**
* This is a singleton.
*/
private static OmemoService<?, ?, ?, ?, ?, ?, ?, ?, ?> INSTANCE;
private OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> omemoStore;
private final HashMap<OmemoManager, OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>> omemoRatchets = new HashMap<>();
/**
* Create a new OmemoService object. This should only happen once.
*/
protected OmemoService() {
}
@ -229,7 +223,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
}
/**
* Initialize OMEMO functionality for OmemoManager omemoManager.
* Initialize OMEMO functionality for the given {@link OmemoManager}.
*
* @param managerGuard OmemoManager we'd like to initialize.
* @throws InterruptedException if the calling thread was interrupted.
@ -456,7 +450,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
CipherAndAuthTag cipherAndAuthTag = getOmemoRatchet(manager)
.retrieveMessageKeyAndAuthTag(senderDevice, omemoElement);
// Retrieve senders fingerprint. TODO: Find a way to do this without the store.
// Retrieve senders fingerprint.
OmemoFingerprint senderFingerprint;
try {
senderFingerprint = getOmemoStoreBackend().getFingerprint(manager.getOwnDevice(), senderDevice);
@ -489,7 +483,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param contactsDevices set of recipient devices.
* @param key AES-Key to be transported.
* @param iv initialization vector to be used with the key.
* @return KeyTransportElement TODO javadoc me please
*
* @return a new key transport element
*
* @throws InterruptedException if the calling thread was interrupted.
* @throws UndecidedOmemoIdentityException if the list of recipients contains an undecided device
@ -598,7 +593,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param connection authenticated XMPP connection.
* @param contact BareJid of the contact of which we want to retrieve the device list from.
* @return
* @return device list
*
* @throws InterruptedException if the calling thread was interrupted.
* @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
* @throws SmackException.NoResponseException if there was no response from the remote entity.
@ -645,9 +641,11 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
}
/**
* Refresh our own device list and publish it to the server.
*
* @param connection XMPPConnection
* @param userDevice our OMEMO device
*
* @param connection TODO javadoc me please
* @param userDevice TODO javadoc me please
* @throws InterruptedException if the calling thread was interrupted.
* @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
* @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
@ -694,8 +692,9 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* Add our load the deviceList of the user from cache, delete stale devices if needed, add the users device
* back if necessary, store the refurbished list in cache and return it.
*
* @param userDevice TODO javadoc me please
* @return
* @param userDevice our own OMEMO device
* @return cleaned device list
*
* @throws IOException if an I/O error occurred.
*/
OmemoCachedDeviceList cleanUpDeviceList(OmemoDevice userDevice) throws IOException {
@ -853,7 +852,6 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
try {
fingerprint = getOmemoStoreBackend().getFingerprint(userDevice, device);
} catch (CorruptedOmemoKeyException | NoIdentityKeyException e) {
// TODO: Best solution?
LOGGER.log(Level.WARNING, "Could not load fingerprint of " + device, e);
undecidedDevices.add(device);
continue;
@ -922,7 +920,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* This method ignores {@link OmemoConfiguration#getDeleteStaleDevices()}!
*
* In this case, a stale device is one of our devices, from which we haven't received an OMEMO message from
* for more than {@link OmemoConfiguration#DELETE_STALE_DEVICE_AFTER_HOURS} hours.
* for more than {@link OmemoConfiguration#getDeleteStaleDevicesAfterHours()} hours.
*
* @param userDevice our OmemoDevice
* @return our altered deviceList with stale devices marked as inactive.
@ -1001,7 +999,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param lastReceipt date of last received message from that device
* @param maxAgeHours threshold
*
* @return staleness TODO javadoc me please
* @return true if the subject device is considered stale
*/
static boolean isStale(OmemoDevice userDevice, OmemoDevice subject, Date lastReceipt, int maxAgeHours) {
if (userDevice.equals(subject)) {
@ -1042,7 +1040,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param managerGuard authenticated OmemoManager.
* @param mamQuery Mam archive query
* @return list of {@link MessageOrOmemoMessage}s.
* @return list of {@link MessageOrOmemoMessage MessageOrOmemoMessages}.
*
* @throws IOException if an I/O error occurred.
*/
List<MessageOrOmemoMessage> decryptMamQueryResult(OmemoManager.LoggedInOmemoManager managerGuard,
@ -1326,8 +1325,10 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
/**
* Send an empty OMEMO message to contactsDevice in order to forward the ratchet.
* @param managerGuard TODO javadoc me please
* @param contactsDevice TODO javadoc me please
*
* @param managerGuard OMEMO manager
* @param contactsDevice contacts OMEMO device
*
* @throws CorruptedOmemoKeyException if our or their OMEMO key is corrupted.
* @throws InterruptedException if the calling thread was interrupted.
* @throws SmackException.NoResponseException if there was no response from the remote entity.

View file

@ -184,7 +184,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* Pack a OmemoBundleElement containing our key material.
*
* @param userDevice our OmemoDevice.
* @return OmemoBundleElement TODO javadoc me please
* @return OMEMO bundle element
*
* @throws CorruptedOmemoKeyException when a key could not be loaded
* @throws IOException if an I/O error occurred.
*/
@ -205,7 +206,9 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
/**
* Replenish our supply of keys. If we are missing any type of keys, generate them fresh.
* @param userDevice TODO javadoc me please
*
* @param userDevice our own OMEMO device
*
* @throws CorruptedOmemoKeyException if the OMEMO key is corrupted.
* @throws IOException if an I/O error occurred.
*/
@ -238,7 +241,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
/**
* Generate a new IdentityKeyPair. We should always have only one pair and usually keep this for a long time.
*
* @return identityKeyPair TODO javadoc me please
* @return a fresh identityKeyPair
*/
public T_IdKeyPair generateOmemoIdentityKeyPair() {
return keyUtil().generateOmemoIdentityKeyPair();
@ -249,7 +252,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* Return null, if we have no identityKeyPair.
*
* @param userDevice our OmemoDevice.
* @return identityKeyPair TODO javadoc me please
* @return loaded identityKeyPair
*
* @throws CorruptedOmemoKeyException Thrown, if the stored key is damaged (*hands up* not my fault!)
* @throws IOException if an I/O error occurred.
*/
@ -277,7 +281,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param userDevice our OmemoDevice.
* @param contactsDevice the device of which we want to load the identityKey.
* @return identityKey TODO javadoc me please
* @return loaded identityKey
*
* @throws CorruptedOmemoKeyException when the key in question is corrupted and cant be deserialized.
* @throws IOException if an I/O error occurred.
*/
@ -453,7 +458,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param userDevice our OmemoDevice.
* @param signedPreKeyId id of the key
* @return key TODO javadoc me please
* @return loaded signed preKey
*
* @throws IOException if an I/O error occurred.
*/
public abstract T_SigPreKey loadOmemoSignedPreKey(OmemoDevice userDevice, int signedPreKeyId) throws IOException;
@ -476,7 +482,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param identityKeyPair identityKeyPair used to sign the preKey
* @param signedPreKeyId id that the preKey will have
* @return signedPreKey TODO javadoc me please
* @return a fresh signedPreKey
*
* @throws CorruptedOmemoKeyException when something goes wrong
*/
public T_SigPreKey generateOmemoSignedPreKey(T_IdKeyPair identityKeyPair, int signedPreKeyId)
@ -571,8 +578,9 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
/**
* Load a list of deviceIds from our own devices.
*
* @param userDevice TODO javadoc me please
* @param userDevice our own OMEMO device
* @return the cached OMEMO device list.
*
* @throws IOException if an I/O error occurred.
*/
public OmemoCachedDeviceList loadCachedDeviceList(OmemoDevice userDevice) throws IOException {
@ -652,7 +660,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param managerGuard authenticated OmemoManager
* @param contactsDevice OmemoDevice we want to get the fingerprint from
* @return fingerprint TODO javadoc me please
* @return fingerprint of the contacts OMEMO device
*
* @throws CannotEstablishOmemoSessionException If we have no local copy of the identityKey of the contact
* and are unable to build a fresh session

View file

@ -158,7 +158,7 @@ public abstract class OmemoBundleElement implements ExtensionElement {
* Return the HashMap of preKeys in the bundle.
* The map uses the preKeys ids as key and the preKeys as value.
*
* @return preKeys TODO javadoc me please
* @return preKeys Pre-Keys contained in the bundle
*/
public HashMap<Integer, byte[]> getPreKeys() {
if (preKeys == null) {

View file

@ -21,8 +21,9 @@ import static org.jivesoftware.smackx.omemo.util.OmemoConstants.OMEMO_NAMESPACE_
import java.util.HashMap;
/**
* OMEMO device bundle as described here:
* https://xmpp.org/extensions/xep-0384.html#usecases-announcing (Example 3).
* OMEMO device bundle as described by the protocol.
*
* @see <a href="https://xmpp.org/extensions/xep-0384.html#usecases-announcing">XEP-0384: OMEMO Encryption (Example 3)</a>.
*
* @author Paul Schaub
*/

View file

@ -55,7 +55,7 @@ public abstract class OmemoElement implements ExtensionElement {
/**
* Return the payload of the message.
*
* @return payload TODO javadoc me please
* @return encrypted payload of the message.
*/
public byte[] getPayload() {
if (payload == null) {

View file

@ -79,7 +79,8 @@ public class CannotEstablishOmemoSessionException extends Exception {
/**
* Return true, if there is at least one recipient, which would not be able to decipher the message on any of
* their devices.
* @return boolean TODO javadoc me please
*
* @return true if the exception requires to be thrown
*/
public boolean requiresThrowing() {
for (Map.Entry<BareJid, HashMap<OmemoDevice, Throwable>> entry : failures.entrySet()) {

View file

@ -22,9 +22,6 @@ import java.util.List;
public final class MultipleCryptoFailedException extends CryptoFailedException {
/**
*
*/
private static final long serialVersionUID = 1L;
private final List<CryptoFailedException> cryptoFailedExceptions;

View file

@ -44,7 +44,8 @@ public class ReadOnlyDeviceException extends Exception {
/**
* Return the device in question.
* @return device TODO javadoc me please
*
* @return device that is read-only.
*/
public OmemoDevice getDevice() {
return device;

View file

@ -31,8 +31,8 @@ public class StaleDeviceException extends Exception {
* This exception gets thrown if a message cannot be encrypted for a device due to the device being inactive for too long (stale).
*
* @param device OmemoDevice.
* @param lastMessageDate TODO javadoc me please
* @param lastDeviceIdPublicationDate TODO javadoc me please
* @param lastMessageDate date of the last received message from the device.
* @param lastDeviceIdPublicationDate date on which the device ID was last published via pubsub.
*/
public StaleDeviceException(OmemoDevice device, Date lastMessageDate, Date lastDeviceIdPublicationDate) {
this.device = device;

View file

@ -41,7 +41,7 @@ public class CiphertextTuple {
/**
* Return the ciphertext.
*
* @return ciphertext TODO javadoc me please
* @return ciphertext part of the tuple
*/
public byte[] getCiphertext() {
return ciphertext;
@ -50,7 +50,7 @@ public class CiphertextTuple {
/**
* Return the messageType.
*
* @return messageType TODO javadoc me please
* @return type of the message
*/
public int getMessageType() {
return this.messageType;

View file

@ -43,7 +43,7 @@ public class OmemoDevice {
/**
* Return the BareJid of the device owner.
*
* @return bareJid TODO javadoc me please
* @return bare JID of the device owner.
*/
public BareJid getJid() {
return this.jid;
@ -52,7 +52,7 @@ public class OmemoDevice {
/**
* Return the OMEMO device Id of the device.
*
* @return deviceId TODO javadoc me please
* @return OMEMO device ID.
*/
public int getDeviceId() {
return this.deviceId;

View file

@ -17,7 +17,16 @@
package org.jivesoftware.smackx.omemo.trust;
public enum TrustState {
undecided, // User has yet to decide, whether the identity is trusted or not.
untrusted, // User decided NOT to trust this device.
trusted // User decided to trust this device.
/**
* User has yet to decide, whether the identity is trusted or not.
*/
undecided,
/**
* User decided NOT to trust this device.
*/
untrusted,
/**
* User decided to trust this device.
*/
trusted
}

View file

@ -22,7 +22,6 @@ package org.jivesoftware.smackx.omemo.util;
*/
public final class OmemoConstants {
// Constants
/**
* Omemo related namespace.
*/

View file

@ -55,7 +55,8 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* Extract an IdentityKey from a OmemoBundleElement.
*
* @param bundle OmemoBundleElement
* @return identityKey TODO javadoc me please
* @return identityKey of the bundle
*
* @throws CorruptedOmemoKeyException if the key is damaged/malformed
*/
public T_IdKey identityKey(OmemoBundleElement bundle) throws CorruptedOmemoKeyException {
@ -66,7 +67,8 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* Extract a signedPreKey from an OmemoBundleElement.
*
* @param bundle OmemoBundleElement
* @return singedPreKey TODO javadoc me please
* @return signed preKey
*
* @throws CorruptedOmemoKeyException if the key is damaged/malformed
*/
public T_ECPub signedPreKeyPublic(OmemoBundleElement bundle) throws CorruptedOmemoKeyException {
@ -77,7 +79,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* Extract the id of the transported signedPreKey from the bundle.
*
* @param bundle OmemoBundleElement
* @return signedPreKeyId TODO javadoc me please
* @return id of the signed preKey
*/
public int signedPreKeyId(OmemoBundleElement bundle) {
return bundle.getSignedPreKeyId();
@ -87,7 +89,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* Extract the signature of the signedPreKey in the bundle as a byte array.
*
* @param bundle OmemoBundleElement
* @return signature TODO javadoc me please
* @return signature on the signed preKey
*/
public byte[] signedPreKeySignature(OmemoBundleElement bundle) {
return bundle.getSignedPreKeySignature();
@ -153,7 +155,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* Serialize an identityKey into bytes.
*
* @param identityKey idKey
* @return bytes TODO javadoc me please
* @return byte array representation of the identity key.
*/
public abstract byte[] identityKeyToBytes(T_IdKey identityKey);
@ -170,7 +172,8 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* Deserialize a public preKey from bytes.
*
* @param data preKey as bytes
* @return preKey TODO javadoc me please
* @return deserialized preKey
*
* @throws CorruptedOmemoKeyException if the key is damaged or malformed
*/
public T_ECPub preKeyPublicFromBytes(byte[] data) throws CorruptedOmemoKeyException {
@ -209,7 +212,8 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param identityKeyPair identityKeyPair used to sign the preKey
* @param signedPreKeyId id that the preKey will have
* @return signedPreKey TODO javadoc me please
* @return deserialized signed preKey
*
* @throws CorruptedOmemoKeyException when the identityKeyPair is invalid
*/
public abstract T_SigPreKey generateOmemoSignedPreKey(T_IdKeyPair identityKeyPair, int signedPreKeyId) throws CorruptedOmemoKeyException;
@ -219,7 +223,8 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* Deserialize a public signedPreKey from bytes.
*
* @param data bytes
* @return signedPreKey TODO javadoc me please
* @return deserialized signed preKey
*
* @throws CorruptedOmemoKeyException if the key is damaged or malformed
*/
public T_ECPub signedPreKeyPublicFromBytes(byte[] data) throws CorruptedOmemoKeyException {
@ -267,7 +272,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
/**
* Generate a new IdentityKeyPair. We should always have only one pair and usually keep this for a long time.
*
* @return identityKeyPair TODO javadoc me please
* @return deserialized identity key pair
*/
public abstract T_IdKeyPair generateOmemoIdentityKeyPair();

View file

@ -21,15 +21,12 @@ import static org.jivesoftware.smackx.omemo.util.OmemoConstants.Crypto.KEYLENGTH
import static org.jivesoftware.smackx.omemo.util.OmemoConstants.Crypto.KEYTYPE;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.util.ArrayList;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
@ -128,7 +125,6 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @throws InvalidKeyException if the key is invalid.
* @throws NoSuchAlgorithmException if no such algorithm is available.
* @throws IllegalBlockSizeException if the input data length is incorrect.
* @throws UnsupportedEncodingException if the encoding is not supported.
* @throws InvalidAlgorithmParameterException if the provided arguments are invalid.
*/
public OmemoMessageBuilder(OmemoDevice userDevice,
@ -136,7 +132,7 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> ratchet,
String message)
throws NoSuchPaddingException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException,
UnsupportedEncodingException, InvalidAlgorithmParameterException {
InvalidAlgorithmParameterException {
this(userDevice, callback, ratchet, generateKey(KEYTYPE, KEYLENGTH), generateIv(), message);
}
@ -148,7 +144,6 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param message plaintext message
* @throws NoSuchPaddingException if the requested padding mechanism is not availble.
* @throws NoSuchProviderException
* @throws InvalidAlgorithmParameterException if the provided arguments are invalid.
* @throws InvalidKeyException if the key is invalid.
* @throws BadPaddingException if the input data is not padded properly.
@ -248,7 +243,7 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
/**
* Assemble an OmemoMessageElement from the current state of the builder.
*
* @return OmemoMessageElement TODO javadoc me please
* @return OMEMO element
*/
public OmemoElement finish() {
OmemoHeaderElement_VAxolotl header = new OmemoHeaderElement_VAxolotl(
@ -276,7 +271,7 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
/**
* Generate a 12 byte initialization vector for AES encryption.
*
* @return iv initialization vector
* @return initialization vector
*/
public static byte[] generateIv() {
SecureRandom random = new SecureRandom();