mirror of
https://github.com/oxen-io/session-android.git
synced 2025-03-28 10:02:14 +00:00
37 lines
1.4 KiB
Java
37 lines
1.4 KiB
Java
package org.whispersystems.textsecure.api;
|
|
|
|
import org.whispersystems.libaxolotl.InvalidMessageException;
|
|
import org.whispersystems.libaxolotl.state.AxolotlStore;
|
|
import org.whispersystems.textsecure.api.crypto.AttachmentCipherInputStream;
|
|
import org.whispersystems.textsecure.api.messages.TextSecureAttachmentPointer;
|
|
import org.whispersystems.textsecure.push.PushServiceSocket;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
|
|
public class TextSecureMessageReceiver {
|
|
|
|
private final String signalingKey;
|
|
private final AxolotlStore axolotlStore;
|
|
private final PushServiceSocket socket;
|
|
|
|
public TextSecureMessageReceiver(String signalingKey, String url,
|
|
PushServiceSocket.TrustStore trustStore,
|
|
String user, String password,
|
|
AxolotlStore axolotlStore)
|
|
{
|
|
this.axolotlStore = axolotlStore;
|
|
this.signalingKey = signalingKey;
|
|
this.socket = new PushServiceSocket(url, trustStore, user, password);
|
|
}
|
|
|
|
public InputStream retrieveAttachment(TextSecureAttachmentPointer pointer, File destination)
|
|
throws IOException, InvalidMessageException
|
|
{
|
|
socket.retrieveAttachment(pointer.getRelay().orNull(), pointer.getId(), destination);
|
|
return new AttachmentCipherInputStream(destination, pointer.getKey());
|
|
}
|
|
|
|
}
|