Этот коммит содержится в:
Paul Schaub 2018-06-09 14:29:18 +02:00
родитель 19a91794c6
Коммит ce5b5f88ef
Подписано: vanitasvitae
Идентификатор ключа GPG: 62BEE9264BF17311
18 изменённых файлов: 117 добавлений и 156 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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.
*/
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
@ -48,8 +47,7 @@ public class SignalCachingOmemoStore extends CachingOmemoStore<IdentityKeyPair,
* @param wrappedStore other store implementation that gets wrapped
*/
public SignalCachingOmemoStore(OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> wrappedStore)
{
SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> wrappedStore) {
super(wrappedStore);
}

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -47,8 +47,7 @@ import org.jxmpp.jid.BareJid;
* @param <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 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
public T_IdKeyPair loadOmemoIdentityKeyPair(OmemoDevice userDevice)
throws CorruptedOmemoKeyException
{
throws CorruptedOmemoKeyException {
T_IdKeyPair pair = getCache(userDevice).identityKeyPair;
if (pair == null && persistent != null) {
@ -113,8 +111,7 @@ public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Se
@Override
public T_IdKey loadOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice)
throws CorruptedOmemoKeyException
{
throws CorruptedOmemoKeyException {
T_IdKey idKey = getCache(userDevice).identityKeys.get(contactsDevice);
if (idKey == null && persistent != null) {

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -98,8 +98,8 @@ import org.jxmpp.jid.Jid;
* @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>
implements OmemoCarbonCopyStanzaReceivedListener, OmemoMessageStanzaReceivedListener
{
implements OmemoCarbonCopyStanzaReceivedListener, OmemoMessageStanzaReceivedListener {
static {
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)
throws InterruptedException, CorruptedOmemoKeyException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException,
PubSubException.NotALeafNodeException
{
PubSubException.NotALeafNodeException {
OmemoManager manager = managerGuard.get();
OmemoDevice userDevice = manager.getOwnDevice();
@ -283,8 +283,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
OmemoDevice contactsDevice)
throws InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException,
SmackException.NotConnectedException, CannotEstablishOmemoSessionException, NoSuchAlgorithmException,
CryptoFailedException
{
CryptoFailedException {
OmemoManager manager = managerGuard.get();
OmemoDevice userDevice = manager.getOwnDevice();
@ -344,8 +344,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
byte[] iv,
String message)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException,
UndecidedOmemoIdentityException, CryptoFailedException
{
UndecidedOmemoIdentityException, CryptoFailedException {
OmemoManager manager = managerGuard.get();
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.
*/
OmemoMessage.Received decryptMessage(OmemoManager.LoggedInOmemoManager managerGuard,
BareJid senderJid,
OmemoElement omemoElement)
throws CorruptedOmemoKeyException, CryptoFailedException, NoRawSessionException
{
BareJid senderJid,
OmemoElement omemoElement)
throws CorruptedOmemoKeyException, CryptoFailedException, NoRawSessionException {
OmemoManager manager = managerGuard.get();
int senderId = omemoElement.getHeader().getSid();
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[] iv)
throws InterruptedException, UndecidedOmemoIdentityException, CryptoFailedException,
SmackException.NotConnectedException, SmackException.NoResponseException
{
SmackException.NotConnectedException, SmackException.NoResponseException {
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,
String message)
throws InterruptedException, UndecidedOmemoIdentityException, CryptoFailedException,
SmackException.NotConnectedException, SmackException.NoResponseException
{
SmackException.NotConnectedException, SmackException.NoResponseException {
byte[] key, iv;
iv = OmemoMessageBuilder.generateIv();
@ -553,8 +552,8 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
OmemoDevice contactsDevice)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException,
XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException,
PubSubException.NotAPubSubNodeException
{
PubSubException.NotAPubSubNodeException {
PubSubManager pm = PubSubManager.getInstance(connection, contactsDevice.getJid());
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)
throws InterruptedException, PubSubException.NotALeafNodeException, SmackException.NoResponseException,
SmackException.NotConnectedException, XMPPException.XMPPErrorException,
PubSubException.NotAPubSubNodeException
{
PubSubException.NotAPubSubNodeException {
PubSubManager pm = PubSubManager.getInstance(connection, contact);
String nodeName = OmemoConstants.PEP_NODE_DEVICE_LIST;
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)
throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException,
SmackException.NoResponseException
{
SmackException.NoResponseException {
PubSubManager.getInstance(connection, connection.getUser().asBareJid())
.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)
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException
{
SmackException.NotConnectedException, SmackException.NoResponseException {
// refreshOmemoDeviceList;
OmemoDeviceListElement publishedList;
try {
@ -788,10 +787,10 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @throws SmackException.NoResponseException
*/
private Set<OmemoDevice> buildMissingSessionsWithContact(XMPPConnection connection,
OmemoDevice userDevice,
BareJid contact)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException
{
OmemoDevice userDevice,
BareJid contact)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
OmemoCachedDeviceList contactsDeviceIds = getOmemoStoreBackend().loadCachedDeviceList(userDevice, contact);
Set<OmemoDevice> contactsDevices = new HashSet<>();
for (int deviceId : contactsDeviceIds.getActiveDevices()) {
@ -814,9 +813,10 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @throws SmackException.NoResponseException
*/
private Set<OmemoDevice> buildMissingSessionsWithDevices(XMPPConnection connection,
OmemoDevice userDevice,
Set<OmemoDevice> devices)
OmemoDevice userDevice,
Set<OmemoDevice> devices)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
Set<OmemoDevice> devicesWithSession = new HashSet<>();
for (OmemoDevice device : devices) {
@ -855,10 +855,10 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @throws SmackException.NoResponseException
*/
private Set<OmemoDevice> buildMissingSessionsWithContacts(XMPPConnection connection,
OmemoDevice userDevice,
Set<BareJid> contacts)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException
{
OmemoDevice userDevice,
Set<BareJid> contacts)
throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
Set<OmemoDevice> devicesWithSessions = new HashSet<>();
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.
*/
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 "
+ brokenDevice);
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)
throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException,
NoSuchAlgorithmException, SmackException.NotConnectedException, CryptoFailedException,
CannotEstablishOmemoSessionException
{
CannotEstablishOmemoSessionException {
OmemoManager manager = managerGuard.get();
OmemoElement ratchetUpdate = createRatchetUpdateElement(managerGuard, contactsDevice);
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)
throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException,
SmackException.NoResponseException
{
SmackException.NoResponseException {
OmemoManager omemoManager = managerGuard.get();
OmemoDevice userDevice = omemoManager.getOwnDevice();

Просмотреть файл

@ -133,8 +133,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @throws IllegalStateException when our IdentityKeyPair is null.
*/
void changeSignedPreKey(OmemoDevice userDevice)
throws CorruptedOmemoKeyException
{
throws CorruptedOmemoKeyException {
T_IdKeyPair idKeyPair = loadOmemoIdentityKeyPair(userDevice);
if (idKeyPair == 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
*/
OmemoBundleElement_VAxolotl packOmemoBundle(OmemoDevice userDevice)
throws CorruptedOmemoKeyException
{
throws CorruptedOmemoKeyException {
int currentSignedPreKeyId = loadCurrentOmemoSignedPreKeyId(userDevice);
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
*/
public void replenishKeys(OmemoDevice userDevice)
throws CorruptedOmemoKeyException
{
throws CorruptedOmemoKeyException {
T_IdKeyPair identityKeyPair = loadOmemoIdentityKeyPair(userDevice);
if (identityKeyPair == null) {
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
*/
public T_SigPreKey generateOmemoSignedPreKey(T_IdKeyPair identityKeyPair, int signedPreKeyId)
throws CorruptedOmemoKeyException
{
throws CorruptedOmemoKeyException {
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.
*/
public OmemoFingerprint getFingerprint(OmemoDevice userDevice)
throws CorruptedOmemoKeyException
{
throws CorruptedOmemoKeyException {
T_IdKeyPair keyPair = loadOmemoIdentityKeyPair(userDevice);
if (keyPair == 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)
throws CorruptedOmemoKeyException, NoIdentityKeyException {
T_IdKey identityKey = loadOmemoIdentityKey(userDevice, contactsDevice);
if (identityKey == null) {
throw new NoIdentityKeyException(contactsDevice);

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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