Rebase on master

This commit is contained in:
Paul Schaub 2018-06-09 14:29:18 +02:00
parent 19a91794c6
commit ce5b5f88ef
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
18 changed files with 117 additions and 156 deletions

View File

@ -43,7 +43,7 @@ public class AbstractOmemoMessageListener implements OmemoMessageListener {
private static class SyncPointListener extends AbstractOmemoMessageListener { private static class SyncPointListener extends AbstractOmemoMessageListener {
protected final ResultSyncPoint<?,?> syncPoint; protected final ResultSyncPoint<?,?> syncPoint;
public SyncPointListener(ResultSyncPoint<?,?> syncPoint) { SyncPointListener(ResultSyncPoint<?,?> syncPoint) {
this.syncPoint = syncPoint; this.syncPoint = syncPoint;
} }

View File

@ -60,8 +60,7 @@ public class OmemoManagerSetupHelper {
final XMPPConnection target, final XMPPConnection target,
String targetNick, String targetNick,
String[] targetGroups) String[] targetGroups)
throws Exception throws Exception {
{
final SimpleResultSyncPoint subscribed = new SimpleResultSyncPoint(); final SimpleResultSyncPoint subscribed = new SimpleResultSyncPoint();
Roster subscriberRoster = Roster.getInstanceFor(subscriber); Roster subscriberRoster = Roster.getInstanceFor(subscriber);
@ -194,16 +193,14 @@ public class OmemoManagerSetupHelper {
pm.getLeafNode(OmemoConstants.PEP_NODE_BUNDLE_FROM_DEVICE_ID(id)).deleteAllItems(); pm.getLeafNode(OmemoConstants.PEP_NODE_BUNDLE_FROM_DEVICE_ID(id)).deleteAllItems();
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | } catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException |
PubSubException.NotALeafNodeException | XMPPException.XMPPErrorException | PubSubException.NotALeafNodeException | XMPPException.XMPPErrorException |
PubSubException.NotAPubSubNodeException e) PubSubException.NotAPubSubNodeException e) {
{
// Silent // Silent
} }
try { try {
pm.deleteNode(OmemoConstants.PEP_NODE_BUNDLE_FROM_DEVICE_ID(id)); pm.deleteNode(OmemoConstants.PEP_NODE_BUNDLE_FROM_DEVICE_ID(id));
} catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException } catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException
| XMPPException.XMPPErrorException e) | XMPPException.XMPPErrorException e) {
{
// Silent // Silent
} }
} }
@ -212,16 +209,14 @@ public class OmemoManagerSetupHelper {
pm.getLeafNode(OmemoConstants.PEP_NODE_DEVICE_LIST).deleteAllItems(); pm.getLeafNode(OmemoConstants.PEP_NODE_DEVICE_LIST).deleteAllItems();
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | } catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException |
PubSubException.NotALeafNodeException | XMPPException.XMPPErrorException | PubSubException.NotALeafNodeException | XMPPException.XMPPErrorException |
PubSubException.NotAPubSubNodeException e) PubSubException.NotAPubSubNodeException e) {
{
// Silent // Silent
} }
try { try {
pm.deleteNode(OmemoConstants.PEP_NODE_DEVICE_LIST); pm.deleteNode(OmemoConstants.PEP_NODE_DEVICE_LIST);
} catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException | } catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException |
XMPPException.XMPPErrorException e) XMPPException.XMPPErrorException e) {
{
// Silent // Silent
} }
} }
@ -232,8 +227,7 @@ public class OmemoManagerSetupHelper {
try { try {
roster.removeEntry(r); roster.removeEntry(r);
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | } catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException |
XMPPException.XMPPErrorException | SmackException.NotLoggedInException e) XMPPException.XMPPErrorException | SmackException.NotLoggedInException e) {
{
// Silent // Silent
} }
} }

View File

@ -39,8 +39,7 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
* excessive storage access, or it can be used standalone as an ephemeral store, which doesn't persist its contents. * excessive storage access, or it can be used standalone as an ephemeral store, which doesn't persist its contents.
*/ */
public class SignalCachingOmemoStore extends CachingOmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, public class SignalCachingOmemoStore extends CachingOmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord,
SignedPreKeyRecord, SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> SignedPreKeyRecord, SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {
{
/** /**
* Create a new SignalCachingOmemoStore as a caching layer around a persisting OmemoStore * Create a new SignalCachingOmemoStore as a caching layer around a persisting OmemoStore
@ -48,8 +47,7 @@ public class SignalCachingOmemoStore extends CachingOmemoStore<IdentityKeyPair,
* @param wrappedStore other store implementation that gets wrapped * @param wrappedStore other store implementation that gets wrapped
*/ */
public SignalCachingOmemoStore(OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, public SignalCachingOmemoStore(OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> wrappedStore) SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> wrappedStore) {
{
super(wrappedStore); super(wrappedStore);
} }

View File

@ -43,16 +43,14 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class SignalFileBasedOmemoStore public class SignalFileBasedOmemoStore
extends FileBasedOmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, extends FileBasedOmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {
{
public SignalFileBasedOmemoStore(File base) { public SignalFileBasedOmemoStore(File base) {
super(base); super(base);
} }
@Override @Override
public OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, ECPublicKey, PreKeyBundle> keyUtil() public OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, ECPublicKey, PreKeyBundle> keyUtil() {
{
return new SignalOmemoKeyUtil(); return new SignalOmemoKeyUtil();
} }
} }

View File

@ -47,8 +47,8 @@ import org.whispersystems.libsignal.util.KeyHelper;
* @author Paul Schaub * @author Paul Schaub
*/ */
public class SignalOmemoKeyUtil extends OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, public class SignalOmemoKeyUtil extends OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
SessionRecord, ECPublicKey, PreKeyBundle> SessionRecord, ECPublicKey, PreKeyBundle> {
{
@Override @Override
public IdentityKeyPair generateOmemoIdentityKeyPair() { public IdentityKeyPair generateOmemoIdentityKeyPair() {
return KeyHelper.generateIdentityKeyPair(); return KeyHelper.generateIdentityKeyPair();
@ -66,8 +66,7 @@ public class SignalOmemoKeyUtil extends OmemoKeyUtil<IdentityKeyPair, IdentityKe
@Override @Override
public SignedPreKeyRecord generateOmemoSignedPreKey(IdentityKeyPair identityKeyPair, int currentPreKeyId) public SignedPreKeyRecord generateOmemoSignedPreKey(IdentityKeyPair identityKeyPair, int currentPreKeyId)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
try { try {
return KeyHelper.generateSignedPreKey(identityKeyPair, currentPreKeyId); return KeyHelper.generateSignedPreKey(identityKeyPair, currentPreKeyId);
} catch (InvalidKeyException e) { } catch (InvalidKeyException e) {
@ -140,8 +139,7 @@ public class SignalOmemoKeyUtil extends OmemoKeyUtil<IdentityKeyPair, IdentityKe
@Override @Override
public PreKeyBundle bundleFromOmemoBundle(OmemoBundleElement bundle, OmemoDevice contact, int preKeyId) public PreKeyBundle bundleFromOmemoBundle(OmemoBundleElement bundle, OmemoDevice contact, int preKeyId)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
return new PreKeyBundle(0, return new PreKeyBundle(0,
contact.getDeviceId(), contact.getDeviceId(),
preKeyId, preKeyId,

View File

@ -57,16 +57,15 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
public class SignalOmemoRatchet public class SignalOmemoRatchet
extends OmemoRatchet<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, extends OmemoRatchet<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {
{
private static final Logger LOGGER = Logger.getLogger(OmemoRatchet.class.getName()); private static final Logger LOGGER = Logger.getLogger(OmemoRatchet.class.getName());
private final SignalOmemoStoreConnector storeConnector; private final SignalOmemoStoreConnector storeConnector;
SignalOmemoRatchet(OmemoManager omemoManager, SignalOmemoRatchet(OmemoManager omemoManager,
OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle,
SessionCipher> store) SessionCipher> store) {
{
super(omemoManager, store); super(omemoManager, store);
this.storeConnector = new SignalOmemoStoreConnector(omemoManager, store); this.storeConnector = new SignalOmemoStoreConnector(omemoManager, store);
} }
@ -74,8 +73,8 @@ public class SignalOmemoRatchet
@Override @Override
public byte[] doubleRatchetDecrypt(OmemoDevice sender, byte[] encryptedKey) public byte[] doubleRatchetDecrypt(OmemoDevice sender, byte[] encryptedKey)
throws CorruptedOmemoKeyException, NoRawSessionException, CryptoFailedException, throws CorruptedOmemoKeyException, NoRawSessionException, CryptoFailedException,
UntrustedOmemoIdentityException UntrustedOmemoIdentityException {
{
SessionCipher cipher = getCipher(sender); SessionCipher cipher = getCipher(sender);
byte[] decryptedKey; byte[] decryptedKey;

View File

@ -48,8 +48,8 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public final class SignalOmemoService public final class SignalOmemoService
extends OmemoService<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, extends OmemoService<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {
{
private static SignalOmemoService INSTANCE; private static SignalOmemoService INSTANCE;
private static boolean LICENSE_ACKNOWLEDGED = false; private static boolean LICENSE_ACKNOWLEDGED = false;
@ -57,8 +57,8 @@ public final class SignalOmemoService
protected SignalOmemoRatchet instantiateOmemoRatchet( protected SignalOmemoRatchet instantiateOmemoRatchet(
OmemoManager manager, OmemoManager manager,
OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> store) SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> store) {
{
return new SignalOmemoRatchet(manager, getOmemoStoreBackend()); return new SignalOmemoRatchet(manager, getOmemoStoreBackend());
} }
@ -95,8 +95,8 @@ public final class SignalOmemoService
protected void processBundle(OmemoManager omemoManager, protected void processBundle(OmemoManager omemoManager,
PreKeyBundle contactsBundle, PreKeyBundle contactsBundle,
OmemoDevice contactsDevice) OmemoDevice contactsDevice)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
SignalOmemoStoreConnector connector = new SignalOmemoStoreConnector(omemoManager, getOmemoStoreBackend()); SignalOmemoStoreConnector connector = new SignalOmemoStoreConnector(omemoManager, getOmemoStoreBackend());
SessionBuilder builder = new SessionBuilder(connector, connector, connector, connector, SessionBuilder builder = new SessionBuilder(connector, connector, connector, connector,
SignalOmemoStoreConnector.asAddress(contactsDevice)); SignalOmemoStoreConnector.asAddress(contactsDevice));

View File

@ -45,20 +45,17 @@ public class LegacySignalOmemoKeyUtilTest extends SmackTestSuite {
private final SignalOmemoKeyUtil keyUtil = new SignalOmemoKeyUtil(); private final SignalOmemoKeyUtil keyUtil = new SignalOmemoKeyUtil();
@Test @Test
public void omemoIdentityKeyPairSerializationTest() { public void omemoIdentityKeyPairSerializationTest() throws CorruptedOmemoKeyException {
IdentityKeyPair ikp = keyUtil.generateOmemoIdentityKeyPair(); IdentityKeyPair ikp = keyUtil.generateOmemoIdentityKeyPair();
byte[] bytes = keyUtil.identityKeyPairToBytes(ikp); byte[] bytes = keyUtil.identityKeyPairToBytes(ikp);
assertNotNull("serialized identityKeyPair must not be null.", assertNotNull("serialized identityKeyPair must not be null.",
bytes); bytes);
assertNotSame("serialized identityKeyPair must not be of length 0.", assertNotSame("serialized identityKeyPair must not be of length 0.",
0, bytes.length); 0, bytes.length);
try {
IdentityKeyPair ikp2 = keyUtil.identityKeyPairFromBytes(bytes); IdentityKeyPair ikp2 = keyUtil.identityKeyPairFromBytes(bytes);
assertTrue("Deserialized IdentityKeyPairs PublicKey must equal the originals one.", assertTrue("Deserialized IdentityKeyPairs PublicKey must equal the originals one.",
ikp.getPublicKey().equals(ikp2.getPublicKey())); ikp.getPublicKey().equals(ikp2.getPublicKey()));
} catch (CorruptedOmemoKeyException e) {
fail("Caught exception while deserializing IdentityKeyPair.");
}
} }
@Test @Test

View File

@ -47,8 +47,7 @@ import org.jxmpp.jid.BareJid;
* @param <T_Ciph> * @param <T_Ciph>
*/ */
public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> public class CachingOmemoStore<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> extends OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> {
{
private final HashMap<OmemoDevice, KeyCache<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess>> caches = new HashMap<>(); private final HashMap<OmemoDevice, KeyCache<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess>> caches = new HashMap<>();
private final OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> persistent; private final OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> persistent;
@ -81,8 +80,7 @@ public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Se
@Override @Override
public T_IdKeyPair loadOmemoIdentityKeyPair(OmemoDevice userDevice) public T_IdKeyPair loadOmemoIdentityKeyPair(OmemoDevice userDevice)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
T_IdKeyPair pair = getCache(userDevice).identityKeyPair; T_IdKeyPair pair = getCache(userDevice).identityKeyPair;
if (pair == null && persistent != null) { if (pair == null && persistent != null) {
@ -113,8 +111,7 @@ public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Se
@Override @Override
public T_IdKey loadOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice) public T_IdKey loadOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
T_IdKey idKey = getCache(userDevice).identityKeys.get(contactsDevice); T_IdKey idKey = getCache(userDevice).identityKeys.get(contactsDevice);
if (idKey == null && persistent != null) { if (idKey == null && persistent != null) {

View File

@ -62,8 +62,7 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
@Override @Override
public T_IdKeyPair loadOmemoIdentityKeyPair(OmemoDevice userDevice) public T_IdKeyPair loadOmemoIdentityKeyPair(OmemoDevice userDevice)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
File identityKeyPairPath = hierarchy.getIdentityKeyPairPath(userDevice); File identityKeyPairPath = hierarchy.getIdentityKeyPairPath(userDevice);
return keyUtil().identityKeyPairFromBytes(readBytes(identityKeyPairPath)); return keyUtil().identityKeyPairFromBytes(readBytes(identityKeyPairPath));
} }
@ -84,8 +83,7 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
@Override @Override
public T_IdKey loadOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice) public T_IdKey loadOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
File identityKeyPath = hierarchy.getContactsIdentityKeyPath(userDevice, contactsDevice); File identityKeyPath = hierarchy.getContactsIdentityKeyPath(userDevice, contactsDevice);
byte[] bytes = readBytes(identityKeyPath); byte[] bytes = readBytes(identityKeyPath);
return bytes != null ? keyUtil().identityKeyFromBytes(bytes) : null; return bytes != null ? keyUtil().identityKeyFromBytes(bytes) : null;

View File

@ -42,7 +42,6 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.Async; import org.jivesoftware.smack.util.Async;
import org.jivesoftware.smackx.carbons.CarbonCopyReceivedListener; import org.jivesoftware.smackx.carbons.CarbonCopyReceivedListener;
@ -152,7 +151,7 @@ public final class OmemoManager extends Manager {
* *
* @return manager * @return manager
*/ */
public synchronized static OmemoManager getInstanceFor(XMPPConnection connection, Integer deviceId) { public static synchronized OmemoManager getInstanceFor(XMPPConnection connection, Integer deviceId) {
if (deviceId == null || deviceId < 1) { if (deviceId == null || deviceId < 1) {
throw new IllegalArgumentException("DeviceId MUST NOT be null and MUST be greater than 0."); throw new IllegalArgumentException("DeviceId MUST NOT be null and MUST be greater than 0.");
} }
@ -183,7 +182,7 @@ public final class OmemoManager extends Manager {
* *
* @return manager * @return manager
*/ */
public synchronized static OmemoManager getInstanceFor(XMPPConnection connection) { public static synchronized OmemoManager getInstanceFor(XMPPConnection connection) {
TreeMap<Integer, OmemoManager> managers = INSTANCES.get(connection); TreeMap<Integer, OmemoManager> managers = INSTANCES.get(connection);
if (managers == null) { if (managers == null) {
managers = new TreeMap<>(); managers = new TreeMap<>();
@ -308,8 +307,7 @@ public final class OmemoManager extends Manager {
public OmemoMessage.Sent encrypt(BareJid recipient, String message) public OmemoMessage.Sent encrypt(BareJid recipient, String message)
throws CryptoFailedException, UndecidedOmemoIdentityException, throws CryptoFailedException, UndecidedOmemoIdentityException,
InterruptedException, SmackException.NotConnectedException, InterruptedException, SmackException.NotConnectedException,
SmackException.NoResponseException, SmackException.NotLoggedInException SmackException.NoResponseException, SmackException.NotLoggedInException {
{
synchronized (LOCK) { synchronized (LOCK) {
Set<BareJid> recipients = new HashSet<>(); Set<BareJid> recipients = new HashSet<>();
recipients.add(recipient); recipients.add(recipient);
@ -333,8 +331,7 @@ public final class OmemoManager extends Manager {
public OmemoMessage.Sent encrypt(Set<BareJid> recipients, String message) public OmemoMessage.Sent encrypt(Set<BareJid> recipients, String message)
throws CryptoFailedException, UndecidedOmemoIdentityException, throws CryptoFailedException, UndecidedOmemoIdentityException,
InterruptedException, SmackException.NotConnectedException, InterruptedException, SmackException.NotConnectedException,
SmackException.NoResponseException, SmackException.NotLoggedInException SmackException.NoResponseException, SmackException.NotLoggedInException {
{
synchronized (LOCK) { synchronized (LOCK) {
LoggedInOmemoManager guard = new LoggedInOmemoManager(this); LoggedInOmemoManager guard = new LoggedInOmemoManager(this);
Set<OmemoDevice> devices = getDevicesOf(getOwnJid()); Set<OmemoDevice> devices = getDevicesOf(getOwnJid());
@ -364,8 +361,7 @@ public final class OmemoManager extends Manager {
throws UndecidedOmemoIdentityException, CryptoFailedException, throws UndecidedOmemoIdentityException, CryptoFailedException,
XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException, NoOmemoSupportException, SmackException.NoResponseException, NoOmemoSupportException,
SmackException.NotLoggedInException SmackException.NotLoggedInException {
{
synchronized (LOCK) { synchronized (LOCK) {
if (!multiUserChatSupportsOmemo(muc)) { if (!multiUserChatSupportsOmemo(muc)) {
throw new NoOmemoSupportException(); throw new NoOmemoSupportException();
@ -396,8 +392,7 @@ public final class OmemoManager extends Manager {
*/ */
public OmemoMessage.Received decrypt(BareJid sender, OmemoElement omemoElement) public OmemoMessage.Received decrypt(BareJid sender, OmemoElement omemoElement)
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException, NoRawSessionException, throws SmackException.NotLoggedInException, CorruptedOmemoKeyException, NoRawSessionException,
CryptoFailedException CryptoFailedException {
{
LoggedInOmemoManager managerGuard = new LoggedInOmemoManager(this); LoggedInOmemoManager managerGuard = new LoggedInOmemoManager(this);
return getOmemoService().decryptMessage(managerGuard, sender, omemoElement); return getOmemoService().decryptMessage(managerGuard, sender, omemoElement);
} }
@ -415,8 +410,7 @@ public final class OmemoManager extends Manager {
* @throws SmackException.NotLoggedInException if the OmemoManager is not authenticated * @throws SmackException.NotLoggedInException if the OmemoManager is not authenticated
*/ */
public List<OmemoMessage.Forwarded> decryptMAMQueryResult(MamManager.MamQueryResult result) public List<OmemoMessage.Forwarded> decryptMAMQueryResult(MamManager.MamQueryResult result)
throws SmackException.NotLoggedInException throws SmackException.NotLoggedInException {
{
LoggedInOmemoManager managerGuard = new LoggedInOmemoManager(this); LoggedInOmemoManager managerGuard = new LoggedInOmemoManager(this);
ArrayList<OmemoMessage.Forwarded> decryptedMessages = new ArrayList<>(); ArrayList<OmemoMessage.Forwarded> decryptedMessages = new ArrayList<>();
@ -512,8 +506,7 @@ public final class OmemoManager extends Manager {
public void sendRatchetUpdateMessage(OmemoDevice recipient) public void sendRatchetUpdateMessage(OmemoDevice recipient)
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException, InterruptedException, throws SmackException.NotLoggedInException, CorruptedOmemoKeyException, InterruptedException,
SmackException.NoResponseException, NoSuchAlgorithmException, SmackException.NotConnectedException, SmackException.NoResponseException, NoSuchAlgorithmException, SmackException.NotConnectedException,
CryptoFailedException, CannotEstablishOmemoSessionException CryptoFailedException, CannotEstablishOmemoSessionException {
{
synchronized (LOCK) { synchronized (LOCK) {
Message message = new Message(); Message message = new Message();
message.setFrom(getOwnJid()); message.setFrom(getOwnJid());
@ -542,8 +535,7 @@ public final class OmemoManager extends Manager {
*/ */
public boolean contactSupportsOmemo(BareJid contact) public boolean contactSupportsOmemo(BareJid contact)
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException SmackException.NotConnectedException, SmackException.NoResponseException {
{
synchronized (LOCK) { synchronized (LOCK) {
OmemoCachedDeviceList deviceList = getOmemoService().refreshDeviceList(connection(), getOwnDevice(), contact); OmemoCachedDeviceList deviceList = getOmemoService().refreshDeviceList(connection(), getOwnDevice(), contact);
return !deviceList.getActiveDevices().isEmpty(); return !deviceList.getActiveDevices().isEmpty();
@ -563,8 +555,7 @@ public final class OmemoManager extends Manager {
*/ */
public boolean multiUserChatSupportsOmemo(MultiUserChat multiUserChat) public boolean multiUserChatSupportsOmemo(MultiUserChat multiUserChat)
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException SmackException.NoResponseException {
{
EntityBareJid jid = multiUserChat.getRoom(); EntityBareJid jid = multiUserChat.getRoom();
RoomInfo roomInfo = MultiUserChatManager.getInstanceFor(connection()).getRoomInfo(jid); RoomInfo roomInfo = MultiUserChatManager.getInstanceFor(connection()).getRoomInfo(jid);
return roomInfo.isNonanonymous() && roomInfo.isMembersOnly(); return roomInfo.isNonanonymous() && roomInfo.isMembersOnly();
@ -583,8 +574,7 @@ public final class OmemoManager extends Manager {
*/ */
public static boolean serverSupportsOmemo(XMPPConnection connection, DomainBareJid server) public static boolean serverSupportsOmemo(XMPPConnection connection, DomainBareJid server)
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException SmackException.NoResponseException {
{
return ServiceDiscoveryManager.getInstanceFor(connection) return ServiceDiscoveryManager.getInstanceFor(connection)
.discoverInfo(server).containsFeature(PubSub.NAMESPACE); .discoverInfo(server).containsFeature(PubSub.NAMESPACE);
} }
@ -597,8 +587,7 @@ public final class OmemoManager extends Manager {
* @throws CorruptedOmemoKeyException if our identityKey is corrupted. * @throws CorruptedOmemoKeyException if our identityKey is corrupted.
*/ */
public OmemoFingerprint getOwnFingerprint() public OmemoFingerprint getOwnFingerprint()
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException throws SmackException.NotLoggedInException, CorruptedOmemoKeyException {
{
synchronized (LOCK) { synchronized (LOCK) {
if (getOwnJid() == null) { if (getOwnJid() == null) {
throw new SmackException.NotLoggedInException(); throw new SmackException.NotLoggedInException();
@ -652,8 +641,7 @@ public final class OmemoManager extends Manager {
public HashMap<OmemoDevice, OmemoFingerprint> getActiveFingerprints(BareJid contact) public HashMap<OmemoDevice, OmemoFingerprint> getActiveFingerprints(BareJid contact)
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException, throws SmackException.NotLoggedInException, CorruptedOmemoKeyException,
CannotEstablishOmemoSessionException, SmackException.NotConnectedException, InterruptedException, CannotEstablishOmemoSessionException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException SmackException.NoResponseException {
{
synchronized (LOCK) { synchronized (LOCK) {
if (getOwnJid() == null) { if (getOwnJid() == null) {
throw new SmackException.NotLoggedInException(); throw new SmackException.NotLoggedInException();
@ -740,8 +728,7 @@ public final class OmemoManager extends Manager {
*/ */
public void purgeDeviceList() public void purgeDeviceList()
throws SmackException.NotLoggedInException, InterruptedException, XMPPException.XMPPErrorException, throws SmackException.NotLoggedInException, InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException SmackException.NotConnectedException, SmackException.NoResponseException {
{
synchronized (LOCK) { synchronized (LOCK) {
getOmemoService().purgeDeviceList(new LoggedInOmemoManager(this)); getOmemoService().purgeDeviceList(new LoggedInOmemoManager(this));
} }
@ -761,8 +748,7 @@ public final class OmemoManager extends Manager {
*/ */
public void rotateSignedPreKey() public void rotateSignedPreKey()
throws CorruptedOmemoKeyException, SmackException.NotLoggedInException, XMPPException.XMPPErrorException, throws CorruptedOmemoKeyException, SmackException.NotLoggedInException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
{
synchronized (LOCK) { synchronized (LOCK) {
if (!connection().isAuthenticated()) { if (!connection().isAuthenticated()) {
throw new SmackException.NotLoggedInException(); throw new SmackException.NotLoggedInException();
@ -862,8 +848,7 @@ public final class OmemoManager extends Manager {
* @param stanza original stanza * @param stanza original stanza
* @param decryptedMessage decrypted OmemoMessage. * @param decryptedMessage decrypted OmemoMessage.
*/ */
void notifyOmemoMessageReceived(Stanza stanza, OmemoMessage.Received decryptedMessage) void notifyOmemoMessageReceived(Stanza stanza, OmemoMessage.Received decryptedMessage) {
{
for (OmemoMessageListener l : omemoMessageListeners) { for (OmemoMessageListener l : omemoMessageListeners) {
l.onOmemoMessageReceived(stanza, decryptedMessage); l.onOmemoMessageReceived(stanza, decryptedMessage);
} }
@ -878,8 +863,7 @@ public final class OmemoManager extends Manager {
*/ */
void notifyOmemoMucMessageReceived(MultiUserChat muc, void notifyOmemoMucMessageReceived(MultiUserChat muc,
Stanza stanza, Stanza stanza,
OmemoMessage.Received decryptedMessage) OmemoMessage.Received decryptedMessage) {
{
for (OmemoMucMessageListener l : omemoMucMessageListeners) { for (OmemoMucMessageListener l : omemoMucMessageListeners) {
l.onOmemoMucMessageReceived(muc, stanza, decryptedMessage); l.onOmemoMucMessageReceived(muc, stanza, decryptedMessage);
} }
@ -949,8 +933,7 @@ public final class OmemoManager extends Manager {
public void rebuildSessionWith(OmemoDevice contactsDevice) public void rebuildSessionWith(OmemoDevice contactsDevice)
throws InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException, throws InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException,
SmackException.NotConnectedException, CannotEstablishOmemoSessionException, SmackException.NotConnectedException, CannotEstablishOmemoSessionException,
SmackException.NotLoggedInException SmackException.NotLoggedInException {
{
if (!connection().isAuthenticated()) { if (!connection().isAuthenticated()) {
throw new SmackException.NotLoggedInException(); throw new SmackException.NotLoggedInException();
} }
@ -1039,7 +1022,7 @@ public final class OmemoManager extends Manager {
continue; continue;
} }
for (ExtensionElement item : ((ItemsExtension) items).getItems()) { for (ExtensionElement item : ((ItemsExtension) items).getExtensions()) {
if (!(item instanceof PayloadItem<?>)) { if (!(item instanceof PayloadItem<?>)) {
continue; continue;
} }

View File

@ -154,8 +154,7 @@ public abstract class OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @throws CryptoFailedException if decryption using AES key fails. * @throws CryptoFailedException if decryption using AES key fails.
*/ */
static String decryptMessageElement(OmemoElement element, CipherAndAuthTag cipherAndAuthTag) static String decryptMessageElement(OmemoElement element, CipherAndAuthTag cipherAndAuthTag)
throws CryptoFailedException throws CryptoFailedException {
{
if (!element.isMessageElement()) { if (!element.isMessageElement()) {
throw new IllegalArgumentException("decryptMessageElement cannot decrypt OmemoElement which is no MessageElement!"); throw new IllegalArgumentException("decryptMessageElement cannot decrypt OmemoElement which is no MessageElement!");
} }

View File

@ -98,8 +98,8 @@ import org.jxmpp.jid.Jid;
* @author Paul Schaub * @author Paul Schaub
*/ */
public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
implements OmemoCarbonCopyStanzaReceivedListener, OmemoMessageStanzaReceivedListener implements OmemoCarbonCopyStanzaReceivedListener, OmemoMessageStanzaReceivedListener {
{
static { static {
Security.addProvider(new BouncyCastleProvider()); Security.addProvider(new BouncyCastleProvider());
} }
@ -243,8 +243,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
void init(OmemoManager.LoggedInOmemoManager managerGuard) void init(OmemoManager.LoggedInOmemoManager managerGuard)
throws InterruptedException, CorruptedOmemoKeyException, XMPPException.XMPPErrorException, throws InterruptedException, CorruptedOmemoKeyException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException, SmackException.NotConnectedException, SmackException.NoResponseException,
PubSubException.NotALeafNodeException PubSubException.NotALeafNodeException {
{
OmemoManager manager = managerGuard.get(); OmemoManager manager = managerGuard.get();
OmemoDevice userDevice = manager.getOwnDevice(); OmemoDevice userDevice = manager.getOwnDevice();
@ -283,8 +283,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
OmemoDevice contactsDevice) OmemoDevice contactsDevice)
throws InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException, throws InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException,
SmackException.NotConnectedException, CannotEstablishOmemoSessionException, NoSuchAlgorithmException, SmackException.NotConnectedException, CannotEstablishOmemoSessionException, NoSuchAlgorithmException,
CryptoFailedException CryptoFailedException {
{
OmemoManager manager = managerGuard.get(); OmemoManager manager = managerGuard.get();
OmemoDevice userDevice = manager.getOwnDevice(); OmemoDevice userDevice = manager.getOwnDevice();
@ -344,8 +344,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
byte[] iv, byte[] iv,
String message) String message)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException,
UndecidedOmemoIdentityException, CryptoFailedException UndecidedOmemoIdentityException, CryptoFailedException {
{
OmemoManager manager = managerGuard.get(); OmemoManager manager = managerGuard.get();
OmemoDevice userDevice = manager.getOwnDevice(); OmemoDevice userDevice = manager.getOwnDevice();
@ -444,10 +444,10 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @throws NoRawSessionException if we have no session with the device and it sent a normal (non-preKey) message. * @throws NoRawSessionException if we have no session with the device and it sent a normal (non-preKey) message.
*/ */
OmemoMessage.Received decryptMessage(OmemoManager.LoggedInOmemoManager managerGuard, OmemoMessage.Received decryptMessage(OmemoManager.LoggedInOmemoManager managerGuard,
BareJid senderJid, BareJid senderJid,
OmemoElement omemoElement) OmemoElement omemoElement)
throws CorruptedOmemoKeyException, CryptoFailedException, NoRawSessionException throws CorruptedOmemoKeyException, CryptoFailedException, NoRawSessionException {
{
OmemoManager manager = managerGuard.get(); OmemoManager manager = managerGuard.get();
int senderId = omemoElement.getHeader().getSid(); int senderId = omemoElement.getHeader().getSid();
OmemoDevice senderDevice = new OmemoDevice(senderJid, senderId); OmemoDevice senderDevice = new OmemoDevice(senderJid, senderId);
@ -498,8 +498,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
byte[] key, byte[] key,
byte[] iv) byte[] iv)
throws InterruptedException, UndecidedOmemoIdentityException, CryptoFailedException, throws InterruptedException, UndecidedOmemoIdentityException, CryptoFailedException,
SmackException.NotConnectedException, SmackException.NoResponseException SmackException.NotConnectedException, SmackException.NoResponseException {
{
return encrypt(managerGuard, contactsDevices, key, iv, null); return encrypt(managerGuard, contactsDevices, key, iv, null);
} }
@ -521,8 +520,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
Set<OmemoDevice> contactsDevices, Set<OmemoDevice> contactsDevices,
String message) String message)
throws InterruptedException, UndecidedOmemoIdentityException, CryptoFailedException, throws InterruptedException, UndecidedOmemoIdentityException, CryptoFailedException,
SmackException.NotConnectedException, SmackException.NoResponseException SmackException.NotConnectedException, SmackException.NoResponseException {
{
byte[] key, iv; byte[] key, iv;
iv = OmemoMessageBuilder.generateIv(); iv = OmemoMessageBuilder.generateIv();
@ -553,8 +552,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
OmemoDevice contactsDevice) OmemoDevice contactsDevice)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException,
XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException,
PubSubException.NotAPubSubNodeException PubSubException.NotAPubSubNodeException {
{
PubSubManager pm = PubSubManager.getInstance(connection, contactsDevice.getJid()); PubSubManager pm = PubSubManager.getInstance(connection, contactsDevice.getJid());
LeafNode node = pm.getLeafNode(contactsDevice.getBundleNodeName()); LeafNode node = pm.getLeafNode(contactsDevice.getBundleNodeName());
@ -603,8 +602,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
private static OmemoDeviceListElement fetchDeviceList(XMPPConnection connection, BareJid contact) private static OmemoDeviceListElement fetchDeviceList(XMPPConnection connection, BareJid contact)
throws InterruptedException, PubSubException.NotALeafNodeException, SmackException.NoResponseException, throws InterruptedException, PubSubException.NotALeafNodeException, SmackException.NoResponseException,
SmackException.NotConnectedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, XMPPException.XMPPErrorException,
PubSubException.NotAPubSubNodeException PubSubException.NotAPubSubNodeException {
{
PubSubManager pm = PubSubManager.getInstance(connection, contact); PubSubManager pm = PubSubManager.getInstance(connection, contact);
String nodeName = OmemoConstants.PEP_NODE_DEVICE_LIST; String nodeName = OmemoConstants.PEP_NODE_DEVICE_LIST;
LeafNode node = pm.getLeafNode(nodeName); LeafNode node = pm.getLeafNode(nodeName);
@ -633,8 +632,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*/ */
static void publishDeviceList(XMPPConnection connection, OmemoDeviceListElement deviceList) static void publishDeviceList(XMPPConnection connection, OmemoDeviceListElement deviceList)
throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException,
SmackException.NoResponseException SmackException.NoResponseException {
{
PubSubManager.getInstance(connection, connection.getUser().asBareJid()) PubSubManager.getInstance(connection, connection.getUser().asBareJid())
.tryToPublishAndPossibleAutoCreate(OmemoConstants.PEP_NODE_DEVICE_LIST, new PayloadItem<>(deviceList)); .tryToPublishAndPossibleAutoCreate(OmemoConstants.PEP_NODE_DEVICE_LIST, new PayloadItem<>(deviceList));
} }
@ -651,8 +650,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*/ */
private void refreshAndRepublishDeviceList(XMPPConnection connection, OmemoDevice userDevice) private void refreshAndRepublishDeviceList(XMPPConnection connection, OmemoDevice userDevice)
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException SmackException.NotConnectedException, SmackException.NoResponseException {
{
// refreshOmemoDeviceList; // refreshOmemoDeviceList;
OmemoDeviceListElement publishedList; OmemoDeviceListElement publishedList;
try { try {
@ -788,10 +787,10 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @throws SmackException.NoResponseException * @throws SmackException.NoResponseException
*/ */
private Set<OmemoDevice> buildMissingSessionsWithContact(XMPPConnection connection, private Set<OmemoDevice> buildMissingSessionsWithContact(XMPPConnection connection,
OmemoDevice userDevice, OmemoDevice userDevice,
BareJid contact) BareJid contact)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
{
OmemoCachedDeviceList contactsDeviceIds = getOmemoStoreBackend().loadCachedDeviceList(userDevice, contact); OmemoCachedDeviceList contactsDeviceIds = getOmemoStoreBackend().loadCachedDeviceList(userDevice, contact);
Set<OmemoDevice> contactsDevices = new HashSet<>(); Set<OmemoDevice> contactsDevices = new HashSet<>();
for (int deviceId : contactsDeviceIds.getActiveDevices()) { for (int deviceId : contactsDeviceIds.getActiveDevices()) {
@ -814,9 +813,10 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @throws SmackException.NoResponseException * @throws SmackException.NoResponseException
*/ */
private Set<OmemoDevice> buildMissingSessionsWithDevices(XMPPConnection connection, private Set<OmemoDevice> buildMissingSessionsWithDevices(XMPPConnection connection,
OmemoDevice userDevice, OmemoDevice userDevice,
Set<OmemoDevice> devices) Set<OmemoDevice> devices)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException { throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
Set<OmemoDevice> devicesWithSession = new HashSet<>(); Set<OmemoDevice> devicesWithSession = new HashSet<>();
for (OmemoDevice device : devices) { for (OmemoDevice device : devices) {
@ -855,10 +855,10 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @throws SmackException.NoResponseException * @throws SmackException.NoResponseException
*/ */
private Set<OmemoDevice> buildMissingSessionsWithContacts(XMPPConnection connection, private Set<OmemoDevice> buildMissingSessionsWithContacts(XMPPConnection connection,
OmemoDevice userDevice, OmemoDevice userDevice,
Set<BareJid> contacts) Set<BareJid> contacts)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
{
Set<OmemoDevice> devicesWithSessions = new HashSet<>(); Set<OmemoDevice> devicesWithSessions = new HashSet<>();
for (BareJid contact : contacts) { for (BareJid contact : contacts) {
@ -1338,8 +1338,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param brokenDevice device which session broke. * @param brokenDevice device which session broke.
*/ */
private void repairBrokenSessionWithPreKeyMessage(OmemoManager.LoggedInOmemoManager managerGuard, private void repairBrokenSessionWithPreKeyMessage(OmemoManager.LoggedInOmemoManager managerGuard,
OmemoDevice brokenDevice) OmemoDevice brokenDevice) {
{
LOGGER.log(Level.WARNING, "Attempt to repair the session by sending a fresh preKey message to " LOGGER.log(Level.WARNING, "Attempt to repair the session by sending a fresh preKey message to "
+ brokenDevice); + brokenDevice);
OmemoManager manager = managerGuard.get(); OmemoManager manager = managerGuard.get();
@ -1372,8 +1372,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
private void sendRatchetUpdate(OmemoManager.LoggedInOmemoManager managerGuard, OmemoDevice contactsDevice) private void sendRatchetUpdate(OmemoManager.LoggedInOmemoManager managerGuard, OmemoDevice contactsDevice)
throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException, throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException,
NoSuchAlgorithmException, SmackException.NotConnectedException, CryptoFailedException, NoSuchAlgorithmException, SmackException.NotConnectedException, CryptoFailedException,
CannotEstablishOmemoSessionException CannotEstablishOmemoSessionException {
{
OmemoManager manager = managerGuard.get(); OmemoManager manager = managerGuard.get();
OmemoElement ratchetUpdate = createRatchetUpdateElement(managerGuard, contactsDevice); OmemoElement ratchetUpdate = createRatchetUpdateElement(managerGuard, contactsDevice);
Message m = new Message(); Message m = new Message();
@ -1414,8 +1414,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*/ */
public void purgeDeviceList(OmemoManager.LoggedInOmemoManager managerGuard) public void purgeDeviceList(OmemoManager.LoggedInOmemoManager managerGuard)
throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException,
SmackException.NoResponseException SmackException.NoResponseException {
{
OmemoManager omemoManager = managerGuard.get(); OmemoManager omemoManager = managerGuard.get();
OmemoDevice userDevice = omemoManager.getOwnDevice(); OmemoDevice userDevice = omemoManager.getOwnDevice();

View File

@ -133,8 +133,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @throws IllegalStateException when our IdentityKeyPair is null. * @throws IllegalStateException when our IdentityKeyPair is null.
*/ */
void changeSignedPreKey(OmemoDevice userDevice) void changeSignedPreKey(OmemoDevice userDevice)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
T_IdKeyPair idKeyPair = loadOmemoIdentityKeyPair(userDevice); T_IdKeyPair idKeyPair = loadOmemoIdentityKeyPair(userDevice);
if (idKeyPair == null) { if (idKeyPair == null) {
throw new IllegalStateException("Our IdentityKeyPair is null."); throw new IllegalStateException("Our IdentityKeyPair is null.");
@ -182,8 +182,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @throws CorruptedOmemoKeyException when a key could not be loaded * @throws CorruptedOmemoKeyException when a key could not be loaded
*/ */
OmemoBundleElement_VAxolotl packOmemoBundle(OmemoDevice userDevice) OmemoBundleElement_VAxolotl packOmemoBundle(OmemoDevice userDevice)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
int currentSignedPreKeyId = loadCurrentOmemoSignedPreKeyId(userDevice); int currentSignedPreKeyId = loadCurrentOmemoSignedPreKeyId(userDevice);
T_SigPreKey currentSignedPreKey = loadOmemoSignedPreKeys(userDevice).get(currentSignedPreKeyId); T_SigPreKey currentSignedPreKey = loadOmemoSignedPreKeys(userDevice).get(currentSignedPreKeyId);
@ -202,8 +202,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @throws CorruptedOmemoKeyException * @throws CorruptedOmemoKeyException
*/ */
public void replenishKeys(OmemoDevice userDevice) public void replenishKeys(OmemoDevice userDevice)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
T_IdKeyPair identityKeyPair = loadOmemoIdentityKeyPair(userDevice); T_IdKeyPair identityKeyPair = loadOmemoIdentityKeyPair(userDevice);
if (identityKeyPair == null) { if (identityKeyPair == null) {
identityKeyPair = generateOmemoIdentityKeyPair(); identityKeyPair = generateOmemoIdentityKeyPair();
@ -433,8 +433,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @throws CorruptedOmemoKeyException when something goes wrong * @throws CorruptedOmemoKeyException when something goes wrong
*/ */
public T_SigPreKey generateOmemoSignedPreKey(T_IdKeyPair identityKeyPair, int signedPreKeyId) public T_SigPreKey generateOmemoSignedPreKey(T_IdKeyPair identityKeyPair, int signedPreKeyId)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
return keyUtil().generateOmemoSignedPreKey(identityKeyPair, signedPreKeyId); return keyUtil().generateOmemoSignedPreKey(identityKeyPair, signedPreKeyId);
} }
@ -561,8 +560,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @throws CorruptedOmemoKeyException if the identityKey of userDevice is corrupted. * @throws CorruptedOmemoKeyException if the identityKey of userDevice is corrupted.
*/ */
public OmemoFingerprint getFingerprint(OmemoDevice userDevice) public OmemoFingerprint getFingerprint(OmemoDevice userDevice)
throws CorruptedOmemoKeyException throws CorruptedOmemoKeyException {
{
T_IdKeyPair keyPair = loadOmemoIdentityKeyPair(userDevice); T_IdKeyPair keyPair = loadOmemoIdentityKeyPair(userDevice);
if (keyPair == null) { if (keyPair == null) {
return null; return null;
@ -582,6 +581,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*/ */
public OmemoFingerprint getFingerprint(OmemoDevice userDevice, OmemoDevice contactsDevice) public OmemoFingerprint getFingerprint(OmemoDevice userDevice, OmemoDevice contactsDevice)
throws CorruptedOmemoKeyException, NoIdentityKeyException { throws CorruptedOmemoKeyException, NoIdentityKeyException {
T_IdKey identityKey = loadOmemoIdentityKey(userDevice, contactsDevice); T_IdKey identityKey = loadOmemoIdentityKey(userDevice, contactsDevice);
if (identityKey == null) { if (identityKey == null) {
throw new NoIdentityKeyException(contactsDevice); throw new NoIdentityKeyException(contactsDevice);

View File

@ -66,7 +66,7 @@ public abstract class OmemoHeaderElement implements NamedElement {
} }
@Override @Override
public CharSequence toXML() { public CharSequence toXML(String enclosingNamespace) {
XmlStringBuilder sb = new XmlStringBuilder(this); XmlStringBuilder sb = new XmlStringBuilder(this);
sb.attribute(ATTR_SID, getSid()).rightAngleBracket(); sb.attribute(ATTR_SID, getSid()).rightAngleBracket();

View File

@ -68,7 +68,7 @@ public class OmemoKeyElement implements NamedElement {
} }
@Override @Override
public CharSequence toXML() { public CharSequence toXML(String enclosingNamespace) {
XmlStringBuilder sb = new XmlStringBuilder(this); XmlStringBuilder sb = new XmlStringBuilder(this);
if (isPreKey()) { if (isPreKey()) {

View File

@ -77,8 +77,8 @@ public abstract class OmemoStoreTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey
@Test @Test
public void storeLoadRemoveOmemoIdentityKeyPair() public void storeLoadRemoveOmemoIdentityKeyPair()
throws IOException, CorruptedOmemoKeyException throws IOException, CorruptedOmemoKeyException {
{
T_IdKeyPair before = store.generateOmemoIdentityKeyPair(); T_IdKeyPair before = store.generateOmemoIdentityKeyPair();
assertNull(store.loadOmemoIdentityKeyPair(alice)); assertNull(store.loadOmemoIdentityKeyPair(alice));
@ -106,8 +106,8 @@ public abstract class OmemoStoreTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey
@Test @Test
public void storeLoadRemoveOmemoIdentityKey() public void storeLoadRemoveOmemoIdentityKey()
throws IOException, CorruptedOmemoKeyException throws IOException, CorruptedOmemoKeyException {
{
// Create IdentityKeys and get bytes // Create IdentityKeys and get bytes
T_IdKey keyA1 = store.keyUtil().identityKeyFromPair(store.generateOmemoIdentityKeyPair()); T_IdKey keyA1 = store.keyUtil().identityKeyFromPair(store.generateOmemoIdentityKeyPair());
T_IdKey keyB1 = store.keyUtil().identityKeyFromPair(store.generateOmemoIdentityKeyPair()); T_IdKey keyB1 = store.keyUtil().identityKeyFromPair(store.generateOmemoIdentityKeyPair());
@ -172,8 +172,8 @@ public abstract class OmemoStoreTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey
@Test @Test
public void storeLoadRemoveOmemoPreKeys() public void storeLoadRemoveOmemoPreKeys()
throws IOException, InterruptedException throws IOException, InterruptedException {
{
TreeMap<Integer, T_PreKey> before = store.generateOmemoPreKeys(1, 10); TreeMap<Integer, T_PreKey> before = store.generateOmemoPreKeys(1, 10);
assertEquals("The store must have no prekeys before this test.", 0, store.loadOmemoPreKeys(alice).size()); assertEquals("The store must have no prekeys before this test.", 0, store.loadOmemoPreKeys(alice).size());
@ -210,8 +210,8 @@ public abstract class OmemoStoreTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey
@Test @Test
public void storeLoadRemoveOmemoSignedPreKeys() public void storeLoadRemoveOmemoSignedPreKeys()
throws IOException, CorruptedOmemoKeyException throws IOException, CorruptedOmemoKeyException {
{
TreeMap<Integer, T_SigPreKey> before = store.loadOmemoSignedPreKeys(alice); TreeMap<Integer, T_SigPreKey> before = store.loadOmemoSignedPreKeys(alice);
assertEquals("At this stage, there must be no signed prekeys in the store.", 0, before.size()); assertEquals("At this stage, there must be no signed prekeys in the store.", 0, before.size());

View File

@ -1,6 +1,6 @@
allprojects { allprojects {
ext { ext {
shortVersion = '4.2.5' shortVersion = '4.4.0-alpha1'
isSnapshot = true isSnapshot = true
jxmppVersion = '0.6.2' jxmppVersion = '0.6.2'
miniDnsVersion = '0.3.0' miniDnsVersion = '0.3.0'