mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Temp commit
This commit is contained in:
parent
9a779ff8aa
commit
85171ee71b
14 changed files with 195 additions and 196 deletions
|
@ -62,13 +62,13 @@ public class SignalOmemoRatchet
|
|||
private static final Logger LOGGER = Logger.getLogger(OmemoRatchet.class.getName());
|
||||
private final SignalOmemoStoreConnector storeConnector;
|
||||
|
||||
SignalOmemoRatchet(OmemoManager.KnownBareJidGuard managerGuard,
|
||||
SignalOmemoRatchet(OmemoManager omemoManager,
|
||||
OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
|
||||
SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle,
|
||||
SessionCipher> store)
|
||||
{
|
||||
super(managerGuard, store);
|
||||
this.storeConnector = new SignalOmemoStoreConnector(managerGuard, store);
|
||||
super(omemoManager, store);
|
||||
this.storeConnector = new SignalOmemoStoreConnector(omemoManager, store);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,8 +157,7 @@ public class SignalOmemoRatchet
|
|||
}
|
||||
|
||||
private SessionCipher getCipher(OmemoDevice device) {
|
||||
SignalOmemoKeyUtil keyUtil = (SignalOmemoKeyUtil) store.keyUtil();
|
||||
SignalProtocolAddress address = keyUtil.omemoDeviceAsAddress(device);
|
||||
return new SessionCipher(storeConnector, storeConnector, storeConnector, storeConnector, address);
|
||||
return new SessionCipher(storeConnector, storeConnector, storeConnector, storeConnector,
|
||||
SignalOmemoStoreConnector.asAddress(device));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public final class SignalOmemoService
|
|||
|
||||
@Override
|
||||
protected SignalOmemoRatchet instantiateOmemoRatchet(
|
||||
OmemoManager.KnownBareJidGuard manager,
|
||||
OmemoManager manager,
|
||||
OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> store)
|
||||
{
|
||||
|
@ -111,14 +111,14 @@ public final class SignalOmemoService
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void processBundle(OmemoManager.KnownBareJidGuard managerGuard,
|
||||
protected void processBundle(OmemoManager.LoggedInOmemoManager managerGuard,
|
||||
PreKeyBundle preKeyBundle,
|
||||
OmemoDevice device)
|
||||
throws CorruptedOmemoKeyException
|
||||
{
|
||||
SignalOmemoStoreConnector connector = new SignalOmemoStoreConnector(managerGuard, getOmemoStoreBackend());
|
||||
SignalOmemoStoreConnector connector = new SignalOmemoStoreConnector(managerGuard.get(), getOmemoStoreBackend());
|
||||
SessionBuilder builder = new SessionBuilder(connector, connector, connector, connector,
|
||||
getOmemoStoreBackend().keyUtil().omemoDeviceAsAddress(device));
|
||||
SignalOmemoStoreConnector.asAddress(device));
|
||||
try {
|
||||
builder.process(preKeyBundle);
|
||||
LOGGER.log(Level.FINE, "Session built with " + device);
|
||||
|
|
|
@ -59,20 +59,20 @@ public class SignalOmemoStoreConnector
|
|||
|
||||
private static final Logger LOGGER = Logger.getLogger(SignalOmemoStoreConnector.class.getName());
|
||||
|
||||
private final OmemoManager.KnownBareJidGuard managerGuard;
|
||||
private final OmemoManager omemoManager;
|
||||
private final OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher>
|
||||
omemoStore;
|
||||
|
||||
public SignalOmemoStoreConnector(OmemoManager.KnownBareJidGuard managerGuard, OmemoStore<IdentityKeyPair,
|
||||
public SignalOmemoStoreConnector(OmemoManager omemoManager, OmemoStore<IdentityKeyPair,
|
||||
IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, SignalProtocolAddress, ECPublicKey,
|
||||
PreKeyBundle, SessionCipher> store) {
|
||||
this.managerGuard = managerGuard;
|
||||
this.omemoManager = omemoManager;
|
||||
this.omemoStore = store;
|
||||
}
|
||||
|
||||
OmemoDevice getOurDevice() {
|
||||
return managerGuard.get().getOwnDevice();
|
||||
return omemoManager.getOwnDevice();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -98,7 +98,7 @@ public class SignalOmemoStoreConnector
|
|||
public boolean saveIdentity(SignalProtocolAddress signalProtocolAddress, IdentityKey identityKey) {
|
||||
OmemoDevice device;
|
||||
try {
|
||||
device = omemoStore.keyUtil().addressAsOmemoDevice(signalProtocolAddress);
|
||||
device = asOmemoDevice(signalProtocolAddress);
|
||||
} catch (XmppStringprepException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public class SignalOmemoStoreConnector
|
|||
public SessionRecord loadSession(SignalProtocolAddress signalProtocolAddress) {
|
||||
OmemoDevice device;
|
||||
try {
|
||||
device = omemoStore.keyUtil().addressAsOmemoDevice(signalProtocolAddress);
|
||||
device = asOmemoDevice(signalProtocolAddress);
|
||||
} catch (XmppStringprepException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ public class SignalOmemoStoreConnector
|
|||
public void storeSession(SignalProtocolAddress signalProtocolAddress, SessionRecord sessionRecord) {
|
||||
OmemoDevice device;
|
||||
try {
|
||||
device = omemoStore.keyUtil().addressAsOmemoDevice(signalProtocolAddress);
|
||||
device = asOmemoDevice(signalProtocolAddress);
|
||||
} catch (XmppStringprepException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public class SignalOmemoStoreConnector
|
|||
public boolean containsSession(SignalProtocolAddress signalProtocolAddress) {
|
||||
OmemoDevice device;
|
||||
try {
|
||||
device = omemoStore.keyUtil().addressAsOmemoDevice(signalProtocolAddress);
|
||||
device = asOmemoDevice(signalProtocolAddress);
|
||||
} catch (XmppStringprepException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ public class SignalOmemoStoreConnector
|
|||
public void deleteSession(SignalProtocolAddress signalProtocolAddress) {
|
||||
OmemoDevice device;
|
||||
try {
|
||||
device = omemoStore.keyUtil().addressAsOmemoDevice(signalProtocolAddress);
|
||||
device = asOmemoDevice(signalProtocolAddress);
|
||||
} catch (XmppStringprepException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
@ -259,4 +259,12 @@ public class SignalOmemoStoreConnector
|
|||
public void removeSignedPreKey(int i) {
|
||||
omemoStore.removeOmemoSignedPreKey(getOurDevice(), i);
|
||||
}
|
||||
|
||||
public static OmemoDevice asOmemoDevice(SignalProtocolAddress address) throws XmppStringprepException {
|
||||
return new OmemoDevice(JidCreate.bareFrom(address.getName()), address.getDeviceId());
|
||||
}
|
||||
|
||||
public static SignalProtocolAddress asAddress(OmemoDevice device) {
|
||||
return new SignalProtocolAddress(device.getJid().toString(), device.getDeviceId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,15 +28,11 @@ import static junit.framework.TestCase.fail;
|
|||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.signal.SignalOmemoKeyUtil;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
import org.whispersystems.libsignal.IdentityKey;
|
||||
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||
|
||||
/**
|
||||
|
@ -97,26 +93,4 @@ public class LegacySignalOmemoKeyUtilTest extends SmackTestSuite {
|
|||
assertTrue("Length of fingerprint must be 64.",
|
||||
keyUtil.getFingerprintOfIdentityKey(ik).length() == 64);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addressToDeviceTest() {
|
||||
SignalProtocolAddress address = new SignalProtocolAddress("test@server.tld",1337);
|
||||
try {
|
||||
OmemoDevice device = keyUtil.addressAsOmemoDevice(address);
|
||||
assertEquals(device, new OmemoDevice(JidCreate.bareFrom("test@server.tld"), 1337));
|
||||
} catch (XmppStringprepException e) {
|
||||
fail("Could not convert address to device: " + e + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deviceToAddressTest() {
|
||||
try {
|
||||
OmemoDevice device = new OmemoDevice(JidCreate.bareFrom("test@server.tld"), 1337);
|
||||
SignalProtocolAddress address = keyUtil.omemoDeviceAsAddress(device);
|
||||
assertEquals(address, new SignalProtocolAddress("test@server.tld", 1337));
|
||||
} catch (XmppStringprepException e) {
|
||||
fail("Could not convert device to address: " + e + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue