use of org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore in project Signal-Android by WhisperSystems.
the class IdentityUtil method getRemoteIdentityKey.
@UiThread
public static ListenableFuture<Optional<IdentityKey>> getRemoteIdentityKey(final Context context, final MasterSecret masterSecret, final Recipient recipient) {
final SettableFuture<Optional<IdentityKey>> future = new SettableFuture<>();
new AsyncTask<Recipient, Void, Optional<IdentityKey>>() {
@Override
protected Optional<IdentityKey> doInBackground(Recipient... recipient) {
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
SignalProtocolAddress axolotlAddress = new SignalProtocolAddress(recipient[0].getNumber(), SignalServiceAddress.DEFAULT_DEVICE_ID);
SessionRecord record = sessionStore.loadSession(axolotlAddress);
if (record == null) {
return Optional.absent();
}
return Optional.fromNullable(record.getSessionState().getRemoteIdentityKey());
}
@Override
protected void onPostExecute(Optional<IdentityKey> result) {
future.set(result);
}
}.execute(recipient);
return future;
}
use of org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore in project Signal-Android by signalapp.
the class SessionUtil method archiveSiblingSessions.
public static void archiveSiblingSessions(Context context, SignalProtocolAddress address) {
TextSecureSessionStore sessionStore = new TextSecureSessionStore(context);
sessionStore.archiveSiblingSessions(address);
}
use of org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore in project Signal-Android by signalapp.
the class PushDecryptJob method handleSynchronizeSentEndSessionMessage.
private long handleSynchronizeSentEndSessionMessage(@NonNull SentTranscriptMessage message) {
SmsDatabase database = DatabaseFactory.getSmsDatabase(context);
Recipient recipient = getSyncMessageDestination(message);
OutgoingTextMessage outgoingTextMessage = new OutgoingTextMessage(recipient, "", -1);
OutgoingEndSessionMessage outgoingEndSessionMessage = new OutgoingEndSessionMessage(outgoingTextMessage);
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient);
if (!recipient.isGroupRecipient()) {
SessionStore sessionStore = new TextSecureSessionStore(context);
sessionStore.deleteAllSessions(recipient.getAddress().toPhoneString());
SecurityEvent.broadcastSecurityUpdateEvent(context);
long messageId = database.insertMessageOutbox(threadId, outgoingEndSessionMessage, false, message.getTimestamp(), null);
database.markAsSent(messageId, true);
}
return threadId;
}
use of org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore in project Signal-Android by WhisperSystems.
the class ApplicationDependencyProvider method provideProtocolStore.
@Override
@NonNull
public SignalServiceDataStoreImpl provideProtocolStore() {
ACI localAci = SignalStore.account().getAci();
PNI localPni = SignalStore.account().getPni();
if (localAci == null) {
throw new IllegalStateException("No ACI set!");
}
if (localPni == null) {
throw new IllegalStateException("No PNI set!");
}
if (!SignalStore.account().hasPniIdentityKey()) {
SignalStore.account().generatePniIdentityKeyIfNecessary();
CreateSignedPreKeyJob.enqueueIfNeeded();
}
SignalBaseIdentityKeyStore baseIdentityStore = new SignalBaseIdentityKeyStore(context);
SignalServiceAccountDataStoreImpl aciStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localAci), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getAciIdentityKey()), new TextSecureSessionStore(localAci), new SignalSenderKeyStore(context));
SignalServiceAccountDataStoreImpl pniStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localPni), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getPniIdentityKey()), new TextSecureSessionStore(localPni), new SignalSenderKeyStore(context));
return new SignalServiceDataStoreImpl(context, aciStore, pniStore);
}
use of org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore in project Signal-Android by signalapp.
the class ApplicationDependencyProvider method provideProtocolStore.
@Override
@NonNull
public SignalServiceDataStoreImpl provideProtocolStore() {
ACI localAci = SignalStore.account().getAci();
PNI localPni = SignalStore.account().getPni();
if (localAci == null) {
throw new IllegalStateException("No ACI set!");
}
if (localPni == null) {
throw new IllegalStateException("No PNI set!");
}
if (!SignalStore.account().hasPniIdentityKey()) {
SignalStore.account().generatePniIdentityKeyIfNecessary();
CreateSignedPreKeyJob.enqueueIfNeeded();
}
SignalBaseIdentityKeyStore baseIdentityStore = new SignalBaseIdentityKeyStore(context);
SignalServiceAccountDataStoreImpl aciStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localAci), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getAciIdentityKey()), new TextSecureSessionStore(localAci), new SignalSenderKeyStore(context));
SignalServiceAccountDataStoreImpl pniStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localPni), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getPniIdentityKey()), new TextSecureSessionStore(localPni), new SignalSenderKeyStore(context));
return new SignalServiceDataStoreImpl(context, aciStore, pniStore);
}
Aggregations