mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-26 09:59:28 +00:00
Refactor out old classes.
This commit is contained in:
@@ -31,12 +31,12 @@ import org.thoughtcrime.securesms.sms.OutgoingKeyExchangeMessage;
|
||||
import org.thoughtcrime.securesms.util.Dialogs;
|
||||
import org.whispersystems.libaxolotl.SessionBuilder;
|
||||
import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
|
||||
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
|
||||
import org.whispersystems.libaxolotl.state.IdentityKeyStore;
|
||||
import org.whispersystems.libaxolotl.state.PreKeyStore;
|
||||
import org.whispersystems.libaxolotl.state.SessionRecord;
|
||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||
import org.whispersystems.textsecure.storage.RecipientDevice;
|
||||
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
|
||||
import org.whispersystems.textsecure.push.PushAddress;
|
||||
import org.whispersystems.textsecure.util.Base64;
|
||||
|
||||
public class KeyExchangeInitiator {
|
||||
@@ -68,7 +68,7 @@ public class KeyExchangeInitiator {
|
||||
|
||||
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
|
||||
identityKeyStore, recipient.getRecipientId(),
|
||||
RecipientDevice.DEFAULT_DEVICE_ID);
|
||||
PushAddress.DEFAULT_DEVICE_ID);
|
||||
|
||||
KeyExchangeMessage keyExchangeMessage = sessionBuilder.process();
|
||||
String serializedMessage = Base64.encodeBytesWithoutPadding(keyExchangeMessage.serialize());
|
||||
@@ -81,7 +81,7 @@ public class KeyExchangeInitiator {
|
||||
Recipient recipient)
|
||||
{
|
||||
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
|
||||
SessionRecord sessionRecord = sessionStore.loadSession(recipient.getRecipientId(), RecipientDevice.DEFAULT_DEVICE_ID);
|
||||
SessionRecord sessionRecord = sessionStore.loadSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID);
|
||||
|
||||
return sessionRecord.getSessionState().hasPendingKeyExchange();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.whispersystems.libaxolotl.protocol.CiphertextMessage;
|
||||
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
|
||||
import org.whispersystems.libaxolotl.state.AxolotlStore;
|
||||
import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||
import org.whispersystems.textsecure.storage.RecipientDevice;
|
||||
import org.whispersystems.textsecure.push.PushAddress;
|
||||
import org.whispersystems.textsecure.util.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -92,11 +92,11 @@ public class MmsCipher {
|
||||
long recipientId = recipients.getPrimaryRecipient().getRecipientId();
|
||||
byte[] pduBytes = new PduComposer(context, message).make();
|
||||
|
||||
if (!axolotlStore.containsSession(recipientId, RecipientDevice.DEFAULT_DEVICE_ID)) {
|
||||
if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) {
|
||||
throw new NoSessionException("No session for: " + recipientId);
|
||||
}
|
||||
|
||||
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, RecipientDevice.DEFAULT_DEVICE_ID);
|
||||
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID);
|
||||
CiphertextMessage ciphertextMessage = cipher.encrypt(pduBytes);
|
||||
byte[] encryptedPduBytes = textTransport.getEncodedMessage(ciphertextMessage.serialize());
|
||||
|
||||
|
||||
@@ -3,25 +3,7 @@ package org.thoughtcrime.securesms.crypto;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.storage.TextSecureIdentityKeyStore;
|
||||
import org.thoughtcrime.securesms.crypto.storage.TextSecurePreKeyStore;
|
||||
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingKeyExchangeMessage;
|
||||
import org.whispersystems.libaxolotl.InvalidKeyException;
|
||||
import org.whispersystems.libaxolotl.SessionBuilder;
|
||||
import org.whispersystems.libaxolotl.StaleKeyExchangeException;
|
||||
import org.whispersystems.libaxolotl.UntrustedIdentityException;
|
||||
import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
|
||||
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
|
||||
import org.whispersystems.libaxolotl.state.IdentityKeyStore;
|
||||
import org.whispersystems.libaxolotl.state.PreKeyBundle;
|
||||
import org.whispersystems.libaxolotl.state.PreKeyStore;
|
||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||
import org.whispersystems.textsecure.storage.RecipientDevice;
|
||||
import org.whispersystems.textsecure.util.Base64;
|
||||
|
||||
/**
|
||||
* This class processes key exchange interactions.
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
|
||||
import org.whispersystems.libaxolotl.protocol.PreKeyWhisperMessage;
|
||||
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
|
||||
import org.whispersystems.libaxolotl.state.AxolotlStore;
|
||||
import org.whispersystems.textsecure.storage.RecipientDevice;
|
||||
import org.whispersystems.textsecure.push.PushAddress;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -89,11 +89,11 @@ public class SmsCipher {
|
||||
byte[] paddedBody = transportDetails.getPaddedMessageBody(message.getMessageBody().getBytes());
|
||||
long recipientId = message.getRecipients().getPrimaryRecipient().getRecipientId();
|
||||
|
||||
if (!axolotlStore.containsSession(recipientId, RecipientDevice.DEFAULT_DEVICE_ID)) {
|
||||
if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) {
|
||||
throw new NoSessionException("No session for: " + recipientId);
|
||||
}
|
||||
|
||||
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, RecipientDevice.DEFAULT_DEVICE_ID);
|
||||
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID);
|
||||
CiphertextMessage ciphertextMessage = cipher.encrypt(paddedBody);
|
||||
String encodedCiphertext = new String(transportDetails.getEncodedMessage(ciphertextMessage.serialize()));
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.whispersystems.libaxolotl.InvalidMessageException;
|
||||
import org.whispersystems.libaxolotl.state.SessionRecord;
|
||||
import org.whispersystems.libaxolotl.state.SessionState;
|
||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||
import org.whispersystems.textsecure.storage.RecipientDevice;
|
||||
import org.whispersystems.textsecure.push.PushAddress;
|
||||
import org.whispersystems.textsecure.util.Conversions;
|
||||
|
||||
import java.io.File;
|
||||
@@ -108,7 +108,7 @@ public class TextSecureSessionStore implements SessionStore {
|
||||
public void deleteAllSessions(long recipientId) {
|
||||
List<Integer> devices = getSubDeviceSessions(recipientId);
|
||||
|
||||
deleteSession(recipientId, RecipientDevice.DEFAULT_DEVICE_ID);
|
||||
deleteSession(recipientId, PushAddress.DEFAULT_DEVICE_ID);
|
||||
|
||||
for (int device : devices) {
|
||||
deleteSession(recipientId, device);
|
||||
@@ -156,7 +156,7 @@ public class TextSecureSessionStore implements SessionStore {
|
||||
}
|
||||
|
||||
private String getSessionName(long recipientId, int deviceId) {
|
||||
return recipientId + (deviceId == RecipientDevice.DEFAULT_DEVICE_ID ? "" : "." + deviceId);
|
||||
return recipientId + (deviceId == PushAddress.DEFAULT_DEVICE_ID ? "" : "." + deviceId);
|
||||
}
|
||||
|
||||
private byte[] readBlob(FileInputStream in) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user