mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 08:09:12 +01:00
Move from ACI to a generic ServiceId.
This commit is contained in:
@@ -22,7 +22,7 @@ public final class SenderKeyUtil {
|
||||
*/
|
||||
public static void rotateOurKey(@NonNull Context context, @NonNull DistributionId distributionId) {
|
||||
try (SignalSessionLock.Lock unused = ReentrantSessionLock.INSTANCE.acquire()) {
|
||||
ApplicationDependencies.getProtocolStore().aci().senderKeys().deleteAllFor(Recipient.self().requireServiceId(), distributionId);
|
||||
ApplicationDependencies.getProtocolStore().aci().senderKeys().deleteAllFor(SignalStore.account().requireAci().toString(), distributionId);
|
||||
SignalDatabase.senderKeyShared().deleteAllFor(distributionId);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public final class SenderKeyUtil {
|
||||
* Gets when the sender key session was created, or -1 if it doesn't exist.
|
||||
*/
|
||||
public static long getCreateTimeForOurKey(@NonNull Context context, @NonNull DistributionId distributionId) {
|
||||
SignalProtocolAddress address = new SignalProtocolAddress(Recipient.self().requireServiceId(), SignalStore.account().getDeviceId());
|
||||
SignalProtocolAddress address = new SignalProtocolAddress(SignalStore.account().requireAci().toString(), SignalStore.account().getDeviceId());
|
||||
return SignalDatabase.senderKeys().getCreatedTime(address, distributionId);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.whispersystems.libsignal.IdentityKey;
|
||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
import org.whispersystems.libsignal.state.IdentityKeyStore;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -110,8 +111,8 @@ public class SignalBaseIdentityKeyStore {
|
||||
boolean nonBlockingApproval)
|
||||
{
|
||||
Recipient recipient = Recipient.resolved(recipientId);
|
||||
if (recipient.hasServiceIdentifier()) {
|
||||
cache.save(recipient.requireServiceId(), recipientId, identityKey, verifiedStatus, firstUse, timestamp, nonBlockingApproval);
|
||||
if (recipient.hasServiceId()) {
|
||||
cache.save(recipient.requireServiceId().toString(), recipientId, identityKey, verifiedStatus, firstUse, timestamp, nonBlockingApproval);
|
||||
} else {
|
||||
Log.w(TAG, "[saveIdentity] No serviceId for " + recipient.getId());
|
||||
}
|
||||
@@ -120,7 +121,7 @@ public class SignalBaseIdentityKeyStore {
|
||||
public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, IdentityKeyStore.Direction direction) {
|
||||
Recipient self = Recipient.self();
|
||||
|
||||
boolean isSelf = address.getName().equals(self.requireAci().toString()) ||
|
||||
boolean isSelf = address.getName().equals(self.requireServiceId().toString()) ||
|
||||
address.getName().equals(self.requireE164());
|
||||
|
||||
if (isSelf) {
|
||||
@@ -150,19 +151,20 @@ public class SignalBaseIdentityKeyStore {
|
||||
}
|
||||
|
||||
public @NonNull Optional<IdentityRecord> getIdentityRecord(@NonNull Recipient recipient) {
|
||||
if (recipient.hasServiceIdentifier()) {
|
||||
IdentityStoreRecord record = cache.get(recipient.requireServiceId());
|
||||
if (recipient.hasServiceId()) {
|
||||
IdentityStoreRecord record = cache.get(recipient.requireServiceId().toString());
|
||||
return Optional.fromNullable(record).transform(r -> r.toIdentityRecord(recipient.getId()));
|
||||
} else {
|
||||
Log.w(TAG, "[getIdentityRecord] No serviceId for " + recipient.getId());
|
||||
Log.w(TAG, "[getIdentityRecord] No ServiceId for " + recipient.getId());
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
public @NonNull IdentityRecordList getIdentityRecords(@NonNull List<Recipient> recipients) {
|
||||
List<String> addressNames = recipients.stream()
|
||||
.filter(Recipient::hasServiceIdentifier)
|
||||
.filter(Recipient::hasServiceId)
|
||||
.map(Recipient::requireServiceId)
|
||||
.map(ServiceId::toString)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (addressNames.isEmpty()) {
|
||||
@@ -172,8 +174,8 @@ public class SignalBaseIdentityKeyStore {
|
||||
List<IdentityRecord> records = new ArrayList<>(recipients.size());
|
||||
|
||||
for (Recipient recipient : recipients) {
|
||||
if (recipient.hasServiceIdentifier()) {
|
||||
IdentityStoreRecord record = cache.get(recipient.requireServiceId());
|
||||
if (recipient.hasServiceId()) {
|
||||
IdentityStoreRecord record = cache.get(recipient.requireServiceId().toString());
|
||||
|
||||
if (record != null) {
|
||||
records.add(record.toIdentityRecord(recipient.getId()));
|
||||
@@ -189,8 +191,8 @@ public class SignalBaseIdentityKeyStore {
|
||||
public void setApproval(@NonNull RecipientId recipientId, boolean nonBlockingApproval) {
|
||||
Recipient recipient = Recipient.resolved(recipientId);
|
||||
|
||||
if (recipient.hasServiceIdentifier()) {
|
||||
cache.setApproval(recipient.requireServiceId(), recipientId, nonBlockingApproval);
|
||||
if (recipient.hasServiceId()) {
|
||||
cache.setApproval(recipient.requireServiceId().toString(), recipientId, nonBlockingApproval);
|
||||
} else {
|
||||
Log.w(TAG, "[setApproval] No serviceId for " + recipient.getId());
|
||||
}
|
||||
@@ -199,8 +201,8 @@ public class SignalBaseIdentityKeyStore {
|
||||
public void setVerified(@NonNull RecipientId recipientId, IdentityKey identityKey, VerifiedStatus verifiedStatus) {
|
||||
Recipient recipient = Recipient.resolved(recipientId);
|
||||
|
||||
if (recipient.hasServiceIdentifier()) {
|
||||
cache.setVerified(recipient.requireServiceId(), recipientId, identityKey, verifiedStatus);
|
||||
if (recipient.hasServiceId()) {
|
||||
cache.setVerified(recipient.requireServiceId().toString(), recipientId, identityKey, verifiedStatus);
|
||||
} else {
|
||||
Log.w(TAG, "[setVerified] No serviceId for " + recipient.getId());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import androidx.annotation.NonNull;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.SignalServiceDataStore;
|
||||
import org.whispersystems.signalservice.api.push.AccountIdentifier;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
public final class SignalServiceDataStoreImpl implements SignalServiceDataStore {
|
||||
|
||||
@@ -25,7 +25,7 @@ public final class SignalServiceDataStoreImpl implements SignalServiceDataStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public SignalServiceAccountDataStoreImpl get(@NonNull AccountIdentifier accountIdentifier) {
|
||||
public SignalServiceAccountDataStoreImpl get(@NonNull ServiceId accountIdentifier) {
|
||||
if (accountIdentifier.equals(SignalStore.account().getAci())) {
|
||||
return aciStore;
|
||||
} else if (accountIdentifier.equals(SignalStore.account().getPni())) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.whispersystems.libsignal.state.PreKeyRecord;
|
||||
import org.whispersystems.libsignal.state.PreKeyStore;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyStore;
|
||||
import org.whispersystems.signalservice.api.push.AccountIdentifier;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,9 +21,9 @@ public class TextSecurePreKeyStore implements PreKeyStore, SignedPreKeyStore {
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
@NonNull
|
||||
private final AccountIdentifier accountId;
|
||||
private final ServiceId accountId;
|
||||
|
||||
public TextSecurePreKeyStore(@NonNull AccountIdentifier accountId) {
|
||||
public TextSecurePreKeyStore(@NonNull ServiceId accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.thoughtcrime.securesms.crypto.storage;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -15,7 +13,7 @@ import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
import org.whispersystems.libsignal.protocol.CiphertextMessage;
|
||||
import org.whispersystems.libsignal.state.SessionRecord;
|
||||
import org.whispersystems.signalservice.api.SignalServiceSessionStore;
|
||||
import org.whispersystems.signalservice.api.push.AccountIdentifier;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -28,9 +26,9 @@ public class TextSecureSessionStore implements SignalServiceSessionStore {
|
||||
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
private final AccountIdentifier accountId;
|
||||
private final ServiceId accountId;
|
||||
|
||||
public TextSecureSessionStore(@NonNull AccountIdentifier accountId) {
|
||||
public TextSecureSessionStore(@NonNull ServiceId accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
@@ -135,8 +133,8 @@ public class TextSecureSessionStore implements SignalServiceSessionStore {
|
||||
synchronized (LOCK) {
|
||||
Recipient recipient = Recipient.resolved(recipientId);
|
||||
|
||||
if (recipient.hasAci()) {
|
||||
archiveSession(new SignalProtocolAddress(recipient.requireAci().toString(), deviceId));
|
||||
if (recipient.hasServiceId()) {
|
||||
archiveSession(new SignalProtocolAddress(recipient.requireServiceId().toString(), deviceId));
|
||||
}
|
||||
|
||||
if (recipient.hasE164()) {
|
||||
|
||||
Reference in New Issue
Block a user