mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
No need for an encrypted serializer any longer
This commit is contained in:
parent
e6a069af6d
commit
59092e2ec0
@ -31,7 +31,6 @@ import org.thoughtcrime.securesms.dependencies.InjectableType;
|
|||||||
import org.thoughtcrime.securesms.dependencies.SignalCommunicationModule;
|
import org.thoughtcrime.securesms.dependencies.SignalCommunicationModule;
|
||||||
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
||||||
import org.thoughtcrime.securesms.jobs.GcmRefreshJob;
|
import org.thoughtcrime.securesms.jobs.GcmRefreshJob;
|
||||||
import org.thoughtcrime.securesms.jobs.persistence.EncryptingJobSerializer;
|
|
||||||
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirementProvider;
|
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirementProvider;
|
||||||
import org.thoughtcrime.securesms.jobs.requirements.ServiceRequirementProvider;
|
import org.thoughtcrime.securesms.jobs.requirements.ServiceRequirementProvider;
|
||||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||||
@ -46,6 +45,7 @@ import org.webrtc.voiceengine.WebRtcAudioManager;
|
|||||||
import org.webrtc.voiceengine.WebRtcAudioUtils;
|
import org.webrtc.voiceengine.WebRtcAudioUtils;
|
||||||
import org.whispersystems.jobqueue.JobManager;
|
import org.whispersystems.jobqueue.JobManager;
|
||||||
import org.whispersystems.jobqueue.dependencies.DependencyInjector;
|
import org.whispersystems.jobqueue.dependencies.DependencyInjector;
|
||||||
|
import org.whispersystems.jobqueue.persistence.JavaJobSerializer;
|
||||||
import org.whispersystems.jobqueue.requirements.NetworkRequirementProvider;
|
import org.whispersystems.jobqueue.requirements.NetworkRequirementProvider;
|
||||||
import org.whispersystems.libsignal.logging.SignalProtocolLoggerProvider;
|
import org.whispersystems.libsignal.logging.SignalProtocolLoggerProvider;
|
||||||
import org.whispersystems.libsignal.util.AndroidSignalProtocolLogger;
|
import org.whispersystems.libsignal.util.AndroidSignalProtocolLogger;
|
||||||
@ -118,7 +118,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
this.jobManager = JobManager.newBuilder(this)
|
this.jobManager = JobManager.newBuilder(this)
|
||||||
.withName("TextSecureJobs")
|
.withName("TextSecureJobs")
|
||||||
.withDependencyInjector(this)
|
.withDependencyInjector(this)
|
||||||
.withJobSerializer(new EncryptingJobSerializer())
|
.withJobSerializer(new JavaJobSerializer())
|
||||||
.withRequirementProviders(new MasterSecretRequirementProvider(this),
|
.withRequirementProviders(new MasterSecretRequirementProvider(this),
|
||||||
new ServiceRequirementProvider(this),
|
new ServiceRequirementProvider(this),
|
||||||
new NetworkRequirementProvider(this))
|
new NetworkRequirementProvider(this))
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.jobs.persistence;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
||||||
import org.thoughtcrime.securesms.util.ParcelUtil;
|
|
||||||
import org.whispersystems.jobqueue.EncryptionKeys;
|
|
||||||
import org.whispersystems.jobqueue.Job;
|
|
||||||
import org.whispersystems.jobqueue.persistence.JavaJobSerializer;
|
|
||||||
import org.whispersystems.jobqueue.persistence.JobSerializer;
|
|
||||||
import org.whispersystems.libsignal.InvalidMessageException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class EncryptingJobSerializer implements JobSerializer {
|
|
||||||
|
|
||||||
private final JavaJobSerializer delegate;
|
|
||||||
|
|
||||||
public EncryptingJobSerializer() {
|
|
||||||
this.delegate = new JavaJobSerializer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String serialize(Job job) throws IOException {
|
|
||||||
String plaintext = delegate.serialize(job);
|
|
||||||
|
|
||||||
if (job.getEncryptionKeys() != null) {
|
|
||||||
MasterSecret masterSecret = ParcelUtil.deserialize(job.getEncryptionKeys().getEncoded(),
|
|
||||||
MasterSecret.CREATOR);
|
|
||||||
MasterCipher masterCipher = new MasterCipher(masterSecret);
|
|
||||||
|
|
||||||
return masterCipher.encryptBody(plaintext);
|
|
||||||
} else {
|
|
||||||
return plaintext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Job deserialize(EncryptionKeys keys, boolean encrypted, String serialized) throws IOException {
|
|
||||||
try {
|
|
||||||
String plaintext;
|
|
||||||
|
|
||||||
if (encrypted) {
|
|
||||||
MasterSecret masterSecret = ParcelUtil.deserialize(keys.getEncoded(), MasterSecret.CREATOR);
|
|
||||||
MasterCipher masterCipher = new MasterCipher(masterSecret);
|
|
||||||
plaintext = masterCipher.decryptBody(serialized);
|
|
||||||
} else {
|
|
||||||
plaintext = serialized;
|
|
||||||
}
|
|
||||||
|
|
||||||
return delegate.deserialize(keys, encrypted, plaintext);
|
|
||||||
} catch (InvalidMessageException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user