Abstract out TrustStore interface.

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2014-11-12 17:09:59 -08:00
parent cbebc040cc
commit 9215322846
6 changed files with 18 additions and 9 deletions

View File

@ -21,6 +21,7 @@ import org.whispersystems.libaxolotl.state.PreKeyRecord;
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord; import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
import org.whispersystems.libaxolotl.util.guava.Optional; import org.whispersystems.libaxolotl.util.guava.Optional;
import org.whispersystems.textsecure.api.push.ContactTokenDetails; import org.whispersystems.textsecure.api.push.ContactTokenDetails;
import org.whispersystems.textsecure.api.push.TrustStore;
import org.whispersystems.textsecure.internal.push.PushServiceSocket; import org.whispersystems.textsecure.internal.push.PushServiceSocket;
import org.whispersystems.textsecure.api.push.SignedPreKeyEntity; import org.whispersystems.textsecure.api.push.SignedPreKeyEntity;
@ -32,7 +33,7 @@ public class TextSecureAccountManager {
private final PushServiceSocket pushServiceSocket; private final PushServiceSocket pushServiceSocket;
public TextSecureAccountManager(String url, PushServiceSocket.TrustStore trustStore, public TextSecureAccountManager(String url, TrustStore trustStore,
String user, String password) String user, String password)
{ {
this.pushServiceSocket = new PushServiceSocket(url, trustStore, user, password); this.pushServiceSocket = new PushServiceSocket(url, trustStore, user, password);

View File

@ -19,6 +19,7 @@ package org.whispersystems.textsecure.api;
import org.whispersystems.libaxolotl.InvalidMessageException; import org.whispersystems.libaxolotl.InvalidMessageException;
import org.whispersystems.textsecure.api.crypto.AttachmentCipherInputStream; import org.whispersystems.textsecure.api.crypto.AttachmentCipherInputStream;
import org.whispersystems.textsecure.api.messages.TextSecureAttachmentPointer; import org.whispersystems.textsecure.api.messages.TextSecureAttachmentPointer;
import org.whispersystems.textsecure.api.push.TrustStore;
import org.whispersystems.textsecure.internal.push.PushServiceSocket; import org.whispersystems.textsecure.internal.push.PushServiceSocket;
import java.io.File; import java.io.File;
@ -29,7 +30,7 @@ public class TextSecureMessageReceiver {
private final PushServiceSocket socket; private final PushServiceSocket socket;
public TextSecureMessageReceiver(String url, PushServiceSocket.TrustStore trustStore, public TextSecureMessageReceiver(String url, TrustStore trustStore,
String user, String password) String user, String password)
{ {
this.socket = new PushServiceSocket(url, trustStore, user, password); this.socket = new PushServiceSocket(url, trustStore, user, password);

View File

@ -33,6 +33,7 @@ import org.whispersystems.textsecure.api.messages.TextSecureAttachmentStream;
import org.whispersystems.textsecure.api.messages.TextSecureGroup; import org.whispersystems.textsecure.api.messages.TextSecureGroup;
import org.whispersystems.textsecure.api.messages.TextSecureMessage; import org.whispersystems.textsecure.api.messages.TextSecureMessage;
import org.whispersystems.textsecure.api.push.PushAddress; import org.whispersystems.textsecure.api.push.PushAddress;
import org.whispersystems.textsecure.api.push.TrustStore;
import org.whispersystems.textsecure.internal.push.MismatchedDevices; import org.whispersystems.textsecure.internal.push.MismatchedDevices;
import org.whispersystems.textsecure.internal.push.OutgoingPushMessage; import org.whispersystems.textsecure.internal.push.OutgoingPushMessage;
import org.whispersystems.textsecure.internal.push.OutgoingPushMessageList; import org.whispersystems.textsecure.internal.push.OutgoingPushMessageList;
@ -63,7 +64,7 @@ public class TextSecureMessageSender {
private final AxolotlStore store; private final AxolotlStore store;
private final Optional<EventListener> eventListener; private final Optional<EventListener> eventListener;
public TextSecureMessageSender(String url, PushServiceSocket.TrustStore trustStore, public TextSecureMessageSender(String url, TrustStore trustStore,
String user, String password, AxolotlStore store, String user, String password, AxolotlStore store,
Optional<EventListener> eventListener) Optional<EventListener> eventListener)
{ {

View File

@ -0,0 +1,9 @@
package org.whispersystems.textsecure.api.push;
import java.io.InputStream;
public interface TrustStore {
public InputStream getKeyStoreInputStream();
public String getKeyStorePassword();
}

View File

@ -31,6 +31,7 @@ import org.whispersystems.textsecure.api.push.PushAddress;
import org.whispersystems.textsecure.api.crypto.AttachmentCipherOutputStream; import org.whispersystems.textsecure.api.crypto.AttachmentCipherOutputStream;
import org.whispersystems.textsecure.api.push.ContactTokenDetails; import org.whispersystems.textsecure.api.push.ContactTokenDetails;
import org.whispersystems.textsecure.api.push.SignedPreKeyEntity; import org.whispersystems.textsecure.api.push.SignedPreKeyEntity;
import org.whispersystems.textsecure.api.push.TrustStore;
import org.whispersystems.textsecure.api.push.exceptions.UnregisteredUserException; import org.whispersystems.textsecure.api.push.exceptions.UnregisteredUserException;
import org.whispersystems.textsecure.internal.push.exceptions.MismatchedDevicesException; import org.whispersystems.textsecure.internal.push.exceptions.MismatchedDevicesException;
import org.whispersystems.textsecure.internal.push.exceptions.StaleDevicesException; import org.whispersystems.textsecure.internal.push.exceptions.StaleDevicesException;
@ -559,9 +560,4 @@ public class PushServiceSocket {
return location; return location;
} }
} }
public interface TrustStore {
public InputStream getKeyStoreInputStream();
public String getKeyStorePassword();
}
} }

View File

@ -3,11 +3,12 @@ package org.thoughtcrime.securesms.push;
import android.content.Context; import android.content.Context;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
import org.whispersystems.textsecure.api.push.TrustStore;
import org.whispersystems.textsecure.internal.push.PushServiceSocket; import org.whispersystems.textsecure.internal.push.PushServiceSocket;
import java.io.InputStream; import java.io.InputStream;
public class TextSecurePushTrustStore implements PushServiceSocket.TrustStore { public class TextSecurePushTrustStore implements TrustStore {
private final Context context; private final Context context;