Skip to content

Commit f09abff

Browse files
committed
Refactor out old classes.
1 parent f9934bd commit f09abff

16 files changed

Lines changed: 53 additions & 102 deletions

libtextsecure/src/main/java/org/whispersystems/textsecure/push/PushAddress.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package org.whispersystems.textsecure.push;
22

3-
import org.whispersystems.textsecure.storage.RecipientDevice;
3+
public class PushAddress {
44

5-
public class PushAddress extends RecipientDevice {
5+
public static final int DEFAULT_DEVICE_ID = 1;
66

7+
private final long recipientId;
78
private final String e164number;
9+
private final int deviceId;
810
private final String relay;
911

1012
public PushAddress(long recipientId, String e164number, int deviceId, String relay) {
11-
super(recipientId, deviceId);
13+
this.recipientId = recipientId;
1214
this.e164number = e164number;
15+
this.deviceId = deviceId;
1316
this.relay = relay;
1417
}
1518

@@ -21,4 +24,11 @@ public String getRelay() {
2124
return relay;
2225
}
2326

27+
public long getRecipientId() {
28+
return recipientId;
29+
}
30+
31+
public int getDeviceId() {
32+
return deviceId;
33+
}
2434
}

libtextsecure/src/main/java/org/whispersystems/textsecure/storage/CanonicalRecipient.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

libtextsecure/src/main/java/org/whispersystems/textsecure/storage/RecipientDevice.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/org/thoughtcrime/securesms/AutoInitiateActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
import android.widget.Button;
2727

2828
import org.thoughtcrime.securesms.crypto.KeyExchangeInitiator;
29+
import org.thoughtcrime.securesms.crypto.MasterSecret;
30+
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
2931
import org.thoughtcrime.securesms.protocol.Tag;
3032
import org.thoughtcrime.securesms.recipients.Recipient;
3133
import org.thoughtcrime.securesms.util.MemoryCleaner;
3234
import org.thoughtcrime.securesms.util.TextSecurePreferences;
3335
import org.whispersystems.libaxolotl.state.SessionStore;
34-
import org.thoughtcrime.securesms.crypto.MasterSecret;
35-
import org.whispersystems.textsecure.storage.RecipientDevice;
36-
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
36+
import org.whispersystems.textsecure.push.PushAddress;
3737

3838
/**
3939
* Activity which prompts the user to initiate a secure
@@ -118,6 +118,6 @@ private static boolean isExchangeQualified(Context context,
118118
Recipient recipient)
119119
{
120120
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
121-
return sessionStore.containsSession(recipient.getRecipientId(), RecipientDevice.DEFAULT_DEVICE_ID);
121+
return sessionStore.containsSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID);
122122
}
123123
}

src/org/thoughtcrime/securesms/ConversationActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
import org.thoughtcrime.securesms.util.TextSecurePreferences;
108108
import org.whispersystems.libaxolotl.InvalidMessageException;
109109
import org.whispersystems.libaxolotl.state.SessionStore;
110-
import org.whispersystems.textsecure.storage.RecipientDevice;
110+
import org.whispersystems.textsecure.push.PushAddress;
111111
import org.whispersystems.textsecure.util.Util;
112112

113113
import java.io.IOException;
@@ -318,7 +318,7 @@ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMen
318318
Recipient primaryRecipient = getRecipients() == null ? null : getRecipients().getPrimaryRecipient();
319319
boolean isPushDestination = DirectoryHelper.isPushDestination(this, getRecipients());
320320
boolean isSecureDestination = isSingleConversation() && sessionStore.containsSession(primaryRecipient.getRecipientId(),
321-
RecipientDevice.DEFAULT_DEVICE_ID);
321+
PushAddress.DEFAULT_DEVICE_ID);
322322

323323
getMenuInflater().inflate(R.menu.conversation_button_context, menu);
324324

@@ -697,7 +697,7 @@ private void initializeSecurity() {
697697
Recipient primaryRecipient = getRecipients() == null ? null : getRecipients().getPrimaryRecipient();
698698
boolean isPushDestination = DirectoryHelper.isPushDestination(this, getRecipients());
699699
boolean isSecureDestination = isSingleConversation() && sessionStore.containsSession(primaryRecipient.getRecipientId(),
700-
RecipientDevice.DEFAULT_DEVICE_ID);
700+
PushAddress.DEFAULT_DEVICE_ID);
701701

702702
if (isPushDestination || isSecureDestination) {
703703
this.isEncryptedConversation = true;

src/org/thoughtcrime/securesms/VerifyIdentityActivity.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
import android.widget.TextView;
2222
import android.widget.Toast;
2323

24+
import org.thoughtcrime.securesms.crypto.IdentityKeyParcelable;
2425
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
26+
import org.thoughtcrime.securesms.crypto.MasterSecret;
27+
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
2528
import org.thoughtcrime.securesms.recipients.Recipient;
2629
import org.thoughtcrime.securesms.util.DynamicLanguage;
2730
import org.thoughtcrime.securesms.util.DynamicTheme;
2831
import org.thoughtcrime.securesms.util.MemoryCleaner;
2932
import org.whispersystems.libaxolotl.IdentityKey;
3033
import org.whispersystems.libaxolotl.state.SessionRecord;
3134
import org.whispersystems.libaxolotl.state.SessionStore;
32-
import org.thoughtcrime.securesms.crypto.IdentityKeyParcelable;
33-
import org.thoughtcrime.securesms.crypto.MasterSecret;
34-
import org.whispersystems.textsecure.storage.RecipientDevice;
35-
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
35+
import org.whispersystems.textsecure.push.PushAddress;
3636

3737
/**
3838
* Activity for verifying identity keys.
@@ -184,7 +184,7 @@ protected String getVerifiedTitle() {
184184
private IdentityKey getRemoteIdentityKey(MasterSecret masterSecret, Recipient recipient) {
185185
SessionStore sessionStore = new TextSecureSessionStore(this, masterSecret);
186186
SessionRecord record = sessionStore.loadSession(recipient.getRecipientId(),
187-
RecipientDevice.DEFAULT_DEVICE_ID);
187+
PushAddress.DEFAULT_DEVICE_ID);
188188

189189
if (record == null) {
190190
return null;

src/org/thoughtcrime/securesms/crypto/KeyExchangeInitiator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
import org.thoughtcrime.securesms.util.Dialogs;
3232
import org.whispersystems.libaxolotl.SessionBuilder;
3333
import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
34-
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
3534
import org.whispersystems.libaxolotl.state.IdentityKeyStore;
3635
import org.whispersystems.libaxolotl.state.PreKeyStore;
3736
import org.whispersystems.libaxolotl.state.SessionRecord;
3837
import org.whispersystems.libaxolotl.state.SessionStore;
39-
import org.whispersystems.textsecure.storage.RecipientDevice;
38+
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
39+
import org.whispersystems.textsecure.push.PushAddress;
4040
import org.whispersystems.textsecure.util.Base64;
4141

4242
public class KeyExchangeInitiator {
@@ -68,7 +68,7 @@ private static void initiateKeyExchange(Context context, MasterSecret masterSecr
6868

6969
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
7070
identityKeyStore, recipient.getRecipientId(),
71-
RecipientDevice.DEFAULT_DEVICE_ID);
71+
PushAddress.DEFAULT_DEVICE_ID);
7272

7373
KeyExchangeMessage keyExchangeMessage = sessionBuilder.process();
7474
String serializedMessage = Base64.encodeBytesWithoutPadding(keyExchangeMessage.serialize());
@@ -81,7 +81,7 @@ private static boolean hasInitiatedSession(Context context, MasterSecret masterS
8181
Recipient recipient)
8282
{
8383
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
84-
SessionRecord sessionRecord = sessionStore.loadSession(recipient.getRecipientId(), RecipientDevice.DEFAULT_DEVICE_ID);
84+
SessionRecord sessionRecord = sessionStore.loadSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID);
8585

8686
return sessionRecord.getSessionState().hasPendingKeyExchange();
8787
}

src/org/thoughtcrime/securesms/crypto/MmsCipher.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
1818
import org.whispersystems.libaxolotl.state.AxolotlStore;
1919
import org.whispersystems.libaxolotl.util.guava.Optional;
20-
import org.whispersystems.textsecure.storage.RecipientDevice;
20+
import org.whispersystems.textsecure.push.PushAddress;
2121
import org.whispersystems.textsecure.util.Util;
2222

2323
import java.io.IOException;
@@ -92,11 +92,11 @@ public SendReq encrypt(Context context, SendReq message)
9292
long recipientId = recipients.getPrimaryRecipient().getRecipientId();
9393
byte[] pduBytes = new PduComposer(context, message).make();
9494

95-
if (!axolotlStore.containsSession(recipientId, RecipientDevice.DEFAULT_DEVICE_ID)) {
95+
if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) {
9696
throw new NoSessionException("No session for: " + recipientId);
9797
}
9898

99-
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, RecipientDevice.DEFAULT_DEVICE_ID);
99+
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID);
100100
CiphertextMessage ciphertextMessage = cipher.encrypt(pduBytes);
101101
byte[] encryptedPduBytes = textTransport.getEncodedMessage(ciphertextMessage.serialize());
102102

src/org/thoughtcrime/securesms/crypto/SecurityEvent.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,7 @@
33
import android.content.Context;
44
import android.content.Intent;
55

6-
import org.thoughtcrime.securesms.crypto.storage.TextSecureIdentityKeyStore;
7-
import org.thoughtcrime.securesms.crypto.storage.TextSecurePreKeyStore;
8-
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
9-
import org.thoughtcrime.securesms.recipients.Recipient;
10-
import org.thoughtcrime.securesms.recipients.RecipientFactory;
116
import org.thoughtcrime.securesms.service.KeyCachingService;
12-
import org.thoughtcrime.securesms.sms.OutgoingKeyExchangeMessage;
13-
import org.whispersystems.libaxolotl.InvalidKeyException;
14-
import org.whispersystems.libaxolotl.SessionBuilder;
15-
import org.whispersystems.libaxolotl.StaleKeyExchangeException;
16-
import org.whispersystems.libaxolotl.UntrustedIdentityException;
17-
import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
18-
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
19-
import org.whispersystems.libaxolotl.state.IdentityKeyStore;
20-
import org.whispersystems.libaxolotl.state.PreKeyBundle;
21-
import org.whispersystems.libaxolotl.state.PreKeyStore;
22-
import org.whispersystems.libaxolotl.state.SessionStore;
23-
import org.whispersystems.textsecure.storage.RecipientDevice;
24-
import org.whispersystems.textsecure.util.Base64;
257

268
/**
279
* This class processes key exchange interactions.

src/org/thoughtcrime/securesms/crypto/SmsCipher.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.whispersystems.libaxolotl.protocol.PreKeyWhisperMessage;
3131
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
3232
import org.whispersystems.libaxolotl.state.AxolotlStore;
33-
import org.whispersystems.textsecure.storage.RecipientDevice;
33+
import org.whispersystems.textsecure.push.PushAddress;
3434

3535
import java.io.IOException;
3636

@@ -89,11 +89,11 @@ public OutgoingTextMessage encrypt(OutgoingTextMessage message) throws NoSession
8989
byte[] paddedBody = transportDetails.getPaddedMessageBody(message.getMessageBody().getBytes());
9090
long recipientId = message.getRecipients().getPrimaryRecipient().getRecipientId();
9191

92-
if (!axolotlStore.containsSession(recipientId, RecipientDevice.DEFAULT_DEVICE_ID)) {
92+
if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) {
9393
throw new NoSessionException("No session for: " + recipientId);
9494
}
9595

96-
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, RecipientDevice.DEFAULT_DEVICE_ID);
96+
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID);
9797
CiphertextMessage ciphertextMessage = cipher.encrypt(paddedBody);
9898
String encodedCiphertext = new String(transportDetails.getEncodedMessage(ciphertextMessage.serialize()));
9999

0 commit comments

Comments
 (0)