mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Move from ACI to a generic ServiceId.
This commit is contained in:
@@ -35,8 +35,9 @@ import org.whispersystems.signalservice.api.payments.CurrencyConversions;
|
||||
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
|
||||
import org.whispersystems.signalservice.api.profiles.SignalServiceProfileWrite;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.AccountIdentifier;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.PNI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceIdType;
|
||||
import org.whispersystems.signalservice.api.push.SignedPreKeyEntity;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NoContentException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
@@ -420,18 +421,18 @@ public class SignalServiceAccountManager {
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setPreKeys(AccountIdentifier accountId, IdentityKey identityKey, SignedPreKeyRecord signedPreKey, List<PreKeyRecord> oneTimePreKeys)
|
||||
public void setPreKeys(ServiceIdType serviceIdType, IdentityKey identityKey, SignedPreKeyRecord signedPreKey, List<PreKeyRecord> oneTimePreKeys)
|
||||
throws IOException
|
||||
{
|
||||
this.pushServiceSocket.registerPreKeys(accountId, identityKey, signedPreKey, oneTimePreKeys);
|
||||
this.pushServiceSocket.registerPreKeys(serviceIdType, identityKey, signedPreKey, oneTimePreKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The server's count of currently available (eg. unused) prekeys for this user.
|
||||
* @throws IOException
|
||||
*/
|
||||
public int getPreKeysCount(AccountIdentifier accountId) throws IOException {
|
||||
return this.pushServiceSocket.getAvailablePreKeys(accountId);
|
||||
public int getPreKeysCount(ServiceIdType serviceIdType) throws IOException {
|
||||
return this.pushServiceSocket.getAvailablePreKeys(serviceIdType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,22 +441,22 @@ public class SignalServiceAccountManager {
|
||||
* @param signedPreKey The client's new signed prekey.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setSignedPreKey(AccountIdentifier accountId, SignedPreKeyRecord signedPreKey) throws IOException {
|
||||
this.pushServiceSocket.setCurrentSignedPreKey(accountId, signedPreKey);
|
||||
public void setSignedPreKey(ServiceIdType serviceIdType, SignedPreKeyRecord signedPreKey) throws IOException {
|
||||
this.pushServiceSocket.setCurrentSignedPreKey(serviceIdType, signedPreKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The server's view of the client's current signed prekey.
|
||||
* @throws IOException
|
||||
*/
|
||||
public SignedPreKeyEntity getSignedPreKey(AccountIdentifier accountId) throws IOException {
|
||||
return this.pushServiceSocket.getCurrentSignedPreKey(accountId);
|
||||
public SignedPreKeyEntity getSignedPreKey(ServiceIdType serviceIdType) throws IOException {
|
||||
return this.pushServiceSocket.getCurrentSignedPreKey(serviceIdType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if the identifier corresponds to a registered user, otherwise false.
|
||||
*/
|
||||
public boolean isIdentifierRegistered(AccountIdentifier identifier) throws IOException {
|
||||
public boolean isIdentifierRegistered(ServiceId identifier) throws IOException {
|
||||
return pushServiceSocket.isIdentifierRegistered(identifier);
|
||||
}
|
||||
|
||||
@@ -815,11 +816,11 @@ public class SignalServiceAccountManager {
|
||||
profileAvatarData);
|
||||
}
|
||||
|
||||
public Optional<ProfileKeyCredential> resolveProfileKeyCredential(ACI aci, ProfileKey profileKey, Locale locale)
|
||||
public Optional<ProfileKeyCredential> resolveProfileKeyCredential(ServiceId serviceId, ProfileKey profileKey, Locale locale)
|
||||
throws NonSuccessfulResponseCodeException, PushNetworkException
|
||||
{
|
||||
try {
|
||||
ProfileAndCredential credential = this.pushServiceSocket.retrieveVersionedProfileAndCredential(aci.uuid(), profileKey, Optional.absent(), locale).get(10, TimeUnit.SECONDS);
|
||||
ProfileAndCredential credential = this.pushServiceSocket.retrieveVersionedProfileAndCredential(serviceId.uuid(), profileKey, Optional.absent(), locale).get(10, TimeUnit.SECONDS);
|
||||
return credential.getProfileKeyCredential();
|
||||
} catch (InterruptedException | TimeoutException e) {
|
||||
throw new PushNetworkException(e);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.whispersystems.signalservice.api;
|
||||
|
||||
import org.whispersystems.signalservice.api.push.AccountIdentifier;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
/**
|
||||
* And extension of the normal protocol store interface that has additional methods that are needed
|
||||
@@ -11,7 +11,7 @@ public interface SignalServiceDataStore {
|
||||
/**
|
||||
* @return A {@link SignalServiceAccountDataStore} for the specified account.
|
||||
*/
|
||||
SignalServiceAccountDataStore get(AccountIdentifier accountIdentifier);
|
||||
SignalServiceAccountDataStore get(ServiceId accountIdentifier);
|
||||
|
||||
/**
|
||||
* @return A {@link SignalServiceAccountDataStore} for the ACI account.
|
||||
|
||||
@@ -21,10 +21,10 @@ import org.whispersystems.signalservice.api.messages.SignalServiceStickerManifes
|
||||
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
|
||||
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.MissingConfigurationException;
|
||||
import org.whispersystems.signalservice.api.util.CredentialsProvider;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
|
||||
import org.whispersystems.signalservice.internal.push.PushServiceSocket;
|
||||
import org.whispersystems.signalservice.internal.push.SignalServiceEnvelopeEntity;
|
||||
@@ -43,7 +43,6 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The primary interface for receiving Signal Service messages.
|
||||
@@ -91,13 +90,13 @@ public class SignalServiceMessageReceiver {
|
||||
SignalServiceProfile.RequestType requestType,
|
||||
Locale locale)
|
||||
{
|
||||
ACI aci = address.getAci();
|
||||
ServiceId serviceId = address.getServiceId();
|
||||
|
||||
if (profileKey.isPresent()) {
|
||||
if (requestType == SignalServiceProfile.RequestType.PROFILE_AND_CREDENTIAL) {
|
||||
return socket.retrieveVersionedProfileAndCredential(aci.uuid(), profileKey.get(), unidentifiedAccess, locale);
|
||||
return socket.retrieveVersionedProfileAndCredential(serviceId.uuid(), profileKey.get(), unidentifiedAccess, locale);
|
||||
} else {
|
||||
return FutureTransformers.map(socket.retrieveVersionedProfile(aci.uuid(), profileKey.get(), unidentifiedAccess, locale), profile -> {
|
||||
return FutureTransformers.map(socket.retrieveVersionedProfile(serviceId.uuid(), profileKey.get(), unidentifiedAccess, locale), profile -> {
|
||||
return new ProfileAndCredential(profile,
|
||||
SignalServiceProfile.RequestType.PROFILE,
|
||||
Optional.absent());
|
||||
|
||||
@@ -64,6 +64,7 @@ import org.whispersystems.signalservice.api.messages.multidevice.ViewedMessage;
|
||||
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.DistributionId;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.MalformedResponseException;
|
||||
@@ -118,7 +119,6 @@ import org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec;
|
||||
import org.whispersystems.signalservice.internal.util.Util;
|
||||
import org.whispersystems.util.Base64;
|
||||
import org.whispersystems.util.ByteArrayUtil;
|
||||
import org.whispersystems.util.FlagUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -795,7 +795,7 @@ public class SignalServiceMessageSender {
|
||||
DataMessage.Quote.Builder quoteBuilder = DataMessage.Quote.newBuilder()
|
||||
.setId(message.getQuote().get().getId())
|
||||
.setText(message.getQuote().get().getText())
|
||||
.setAuthorUuid(message.getQuote().get().getAuthor().getAci().toString());
|
||||
.setAuthorUuid(message.getQuote().get().getAuthor().getServiceId().toString());
|
||||
|
||||
if (!message.getQuote().get().getMentions().isEmpty()) {
|
||||
for (SignalServiceDataMessage.Mention mention : message.getQuote().get().getMentions()) {
|
||||
@@ -891,7 +891,7 @@ public class SignalServiceMessageSender {
|
||||
.setEmoji(message.getReaction().get().getEmoji())
|
||||
.setRemove(message.getReaction().get().isRemove())
|
||||
.setTargetSentTimestamp(message.getReaction().get().getTargetSentTimestamp())
|
||||
.setTargetAuthorUuid(message.getReaction().get().getTargetAuthor().getAci().toString());
|
||||
.setTargetAuthorUuid(message.getReaction().get().getTargetAuthor().getServiceId().toString());
|
||||
|
||||
builder.setReaction(reactionBuilder.build());
|
||||
builder.setRequiredProtocolVersion(Math.max(DataMessage.ProtocolVersion.REACTIONS_VALUE, builder.getRequiredProtocolVersion()));
|
||||
@@ -1071,7 +1071,7 @@ public class SignalServiceMessageSender {
|
||||
if (result.getSuccess() != null) {
|
||||
SyncMessage.Sent.UnidentifiedDeliveryStatus.Builder builder = SyncMessage.Sent.UnidentifiedDeliveryStatus.newBuilder();
|
||||
|
||||
builder.setDestinationUuid(result.getAddress().getAci().toString());
|
||||
builder.setDestinationUuid(result.getAddress().getServiceId().toString());
|
||||
|
||||
if (result.getAddress().getNumber().isPresent()) {
|
||||
builder.setDestinationE164(result.getAddress().getNumber().get());
|
||||
@@ -1084,7 +1084,7 @@ public class SignalServiceMessageSender {
|
||||
}
|
||||
|
||||
if (recipient.isPresent()) {
|
||||
sentMessage.setDestinationUuid(recipient.get().getAci().toString());
|
||||
sentMessage.setDestinationUuid(recipient.get().getServiceId().toString());
|
||||
|
||||
if (recipient.get().getNumber().isPresent()) {
|
||||
sentMessage.setDestinationE164(recipient.get().getNumber().get());
|
||||
@@ -1112,7 +1112,7 @@ public class SignalServiceMessageSender {
|
||||
for (ReadMessage readMessage : readMessages) {
|
||||
SyncMessage.Read.Builder readBuilder = SyncMessage.Read.newBuilder().setTimestamp(readMessage.getTimestamp());
|
||||
|
||||
readBuilder.setSenderUuid(readMessage.getSender().getAci().toString());
|
||||
readBuilder.setSenderUuid(readMessage.getSender().getServiceId().toString());
|
||||
|
||||
if (readMessage.getSender().getNumber().isPresent()) {
|
||||
readBuilder.setSenderE164(readMessage.getSender().getNumber().get());
|
||||
@@ -1131,7 +1131,7 @@ public class SignalServiceMessageSender {
|
||||
for (ViewedMessage readMessage : readMessages) {
|
||||
SyncMessage.Viewed.Builder viewedBuilder = SyncMessage.Viewed.newBuilder().setTimestamp(readMessage.getTimestamp());
|
||||
|
||||
viewedBuilder.setSenderUuid(readMessage.getSender().getAci().toString());
|
||||
viewedBuilder.setSenderUuid(readMessage.getSender().getServiceId().toString());
|
||||
|
||||
if (readMessage.getSender().getNumber().isPresent()) {
|
||||
viewedBuilder.setSenderE164(readMessage.getSender().getNumber().get());
|
||||
@@ -1148,7 +1148,7 @@ public class SignalServiceMessageSender {
|
||||
SyncMessage.Builder builder = createSyncMessageBuilder();
|
||||
SyncMessage.ViewOnceOpen.Builder viewOnceBuilder = SyncMessage.ViewOnceOpen.newBuilder().setTimestamp(readMessage.getTimestamp());
|
||||
|
||||
viewOnceBuilder.setSenderUuid(readMessage.getSender().getAci().toString());
|
||||
viewOnceBuilder.setSenderUuid(readMessage.getSender().getServiceId().toString());
|
||||
|
||||
if (readMessage.getSender().getNumber().isPresent()) {
|
||||
viewOnceBuilder.setSenderE164(readMessage.getSender().getNumber().get());
|
||||
@@ -1165,7 +1165,7 @@ public class SignalServiceMessageSender {
|
||||
SyncMessage.Blocked.Builder blockedMessage = SyncMessage.Blocked.newBuilder();
|
||||
|
||||
for (SignalServiceAddress address : blocked.getAddresses()) {
|
||||
blockedMessage.addUuids(address.getAci().toString());
|
||||
blockedMessage.addUuids(address.getServiceId().toString());
|
||||
if (address.getNumber().isPresent()) {
|
||||
blockedMessage.addNumbers(address.getNumber().get());
|
||||
}
|
||||
@@ -1268,7 +1268,7 @@ public class SignalServiceMessageSender {
|
||||
if (message.getPerson().get().getNumber().isPresent()) {
|
||||
responseMessage.setThreadE164(message.getPerson().get().getNumber().get());
|
||||
}
|
||||
responseMessage.setThreadUuid(message.getPerson().get().getAci().toString());
|
||||
responseMessage.setThreadUuid(message.getPerson().get().getServiceId().toString());
|
||||
}
|
||||
|
||||
switch (message.getType()) {
|
||||
@@ -1301,7 +1301,7 @@ public class SignalServiceMessageSender {
|
||||
SyncMessage.OutgoingPayment.Builder paymentMessage = SyncMessage.OutgoingPayment.newBuilder();
|
||||
|
||||
if (message.getRecipient().isPresent()) {
|
||||
paymentMessage.setRecipientUuid(message.getRecipient().get().getAci().toString());
|
||||
paymentMessage.setRecipientUuid(message.getRecipient().get().getServiceId().toString());
|
||||
}
|
||||
|
||||
if (message.getNote().isPresent()) {
|
||||
@@ -1353,7 +1353,7 @@ public class SignalServiceMessageSender {
|
||||
|
||||
verifiedMessageBuilder.setNullMessage(ByteString.copyFrom(nullMessage));
|
||||
verifiedMessageBuilder.setIdentityKey(ByteString.copyFrom(verifiedMessage.getIdentityKey().serialize()));
|
||||
verifiedMessageBuilder.setDestinationUuid(verifiedMessage.getDestination().getAci().toString());
|
||||
verifiedMessageBuilder.setDestinationUuid(verifiedMessage.getDestination().getServiceId().toString());
|
||||
|
||||
if (verifiedMessage.getDestination().getNumber().isPresent()) {
|
||||
verifiedMessageBuilder.setDestinationE164(verifiedMessage.getDestination().getNumber().get());
|
||||
@@ -1745,12 +1745,12 @@ public class SignalServiceMessageSender {
|
||||
|
||||
Preconditions.checkArgument(recipients.size() == unidentifiedAccess.size(), "[" + timestamp + "] Unidentified access mismatch!");
|
||||
|
||||
Map<ACI, UnidentifiedAccess> accessByAci = new HashMap<>();
|
||||
Iterator<SignalServiceAddress> addressIterator = recipients.iterator();
|
||||
Iterator<UnidentifiedAccess> accessIterator = unidentifiedAccess.iterator();
|
||||
Map<ServiceId, UnidentifiedAccess> accessBySid = new HashMap<>();
|
||||
Iterator<SignalServiceAddress> addressIterator = recipients.iterator();
|
||||
Iterator<UnidentifiedAccess> accessIterator = unidentifiedAccess.iterator();
|
||||
|
||||
while (addressIterator.hasNext()) {
|
||||
accessByAci.put(addressIterator.next().getAci(), accessIterator.next());
|
||||
accessBySid.put(addressIterator.next().getServiceId(), accessIterator.next());
|
||||
}
|
||||
|
||||
for (int i = 0; i < RETRY_COUNT; i++) {
|
||||
@@ -1758,7 +1758,7 @@ public class SignalServiceMessageSender {
|
||||
Set<SignalProtocolAddress> sharedWith = store.getSenderKeySharedWith(distributionId);
|
||||
List<SignalServiceAddress> needsSenderKey = targetInfo.destinations.stream()
|
||||
.filter(a -> !sharedWith.contains(a))
|
||||
.map(a -> ACI.parseOrThrow(a.getName()))
|
||||
.map(a -> ServiceId.parseOrThrow(a.getName()))
|
||||
.distinct()
|
||||
.map(SignalServiceAddress::new)
|
||||
.collect(Collectors.toList());
|
||||
@@ -1767,7 +1767,7 @@ public class SignalServiceMessageSender {
|
||||
SenderKeyDistributionMessage message = getOrCreateNewGroupSession(distributionId);
|
||||
List<Optional<UnidentifiedAccessPair>> access = needsSenderKey.stream()
|
||||
.map(r -> {
|
||||
UnidentifiedAccess targetAccess = accessByAci.get(r.getAci());
|
||||
UnidentifiedAccess targetAccess = accessBySid.get(r.getServiceId());
|
||||
return Optional.of(new UnidentifiedAccessPair(targetAccess, targetAccess));
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
@@ -1779,8 +1779,8 @@ public class SignalServiceMessageSender {
|
||||
.map(SendMessageResult::getAddress)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Set<String> successAcis = successes.stream().map(a -> a.getAci().toString()).collect(Collectors.toSet());
|
||||
Set<SignalProtocolAddress> successAddresses = targetInfo.destinations.stream().filter(a -> successAcis.contains(a.getName())).collect(Collectors.toSet());
|
||||
Set<String> successSids = successes.stream().map(a -> a.getServiceId().toString()).collect(Collectors.toSet());
|
||||
Set<SignalProtocolAddress> successAddresses = targetInfo.destinations.stream().filter(a -> successSids.contains(a.getName())).collect(Collectors.toSet());
|
||||
|
||||
store.markSenderKeySharedWith(distributionId, successAddresses);
|
||||
|
||||
@@ -1794,12 +1794,12 @@ public class SignalServiceMessageSender {
|
||||
.filter(r -> !r.isSuccess())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Set<ACI> failedAddresses = trueFailures.stream()
|
||||
.map(result -> result.getAddress().getAci())
|
||||
.collect(Collectors.toSet());
|
||||
Set<ServiceId> failedAddresses = trueFailures.stream()
|
||||
.map(result -> result.getAddress().getServiceId())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<SendMessageResult> fakeNetworkFailures = recipients.stream()
|
||||
.filter(r -> !failedAddresses.contains(r.getAci()))
|
||||
.filter(r -> !failedAddresses.contains(r.getServiceId()))
|
||||
.map(SendMessageResult::networkFailure)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -1914,7 +1914,7 @@ public class SignalServiceMessageSender {
|
||||
|
||||
List<SendMessageResult> success = recipients.keySet()
|
||||
.stream()
|
||||
.filter(r -> !unregistered.contains(r.getAci()))
|
||||
.filter(r -> !unregistered.contains(r.getServiceId()))
|
||||
.map(a -> SendMessageResult.success(a, recipients.get(a), true, store.isMultiDevice(), -1, Optional.of(content)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -2064,7 +2064,7 @@ public class SignalServiceMessageSender {
|
||||
List<SignalProtocolAddress> addresses = new ArrayList<>(devices.size());
|
||||
|
||||
for (int staleDeviceId : devices) {
|
||||
addresses.add(new SignalProtocolAddress(recipient.getAci().toString(), staleDeviceId));
|
||||
addresses.add(new SignalProtocolAddress(recipient.getServiceId().toString(), staleDeviceId));
|
||||
|
||||
if (recipient.getNumber().isPresent()) {
|
||||
addresses.add(new SignalProtocolAddress(recipient.getNumber().get(), staleDeviceId));
|
||||
|
||||
@@ -100,7 +100,7 @@ public class SignalServiceCipher {
|
||||
PushTransportDetails transport = new PushTransportDetails();
|
||||
SignalProtocolAddress localProtocolAddress = new SignalProtocolAddress(localAddress.getIdentifier(), localDeviceId);
|
||||
SignalGroupCipher groupCipher = new SignalGroupCipher(sessionLock, new GroupCipher(signalProtocolStore, localProtocolAddress));
|
||||
SignalSealedSessionCipher sessionCipher = new SignalSealedSessionCipher(sessionLock, new SealedSessionCipher(signalProtocolStore, localAddress.getAci().uuid(), localAddress.getNumber().orNull(), localDeviceId));
|
||||
SignalSealedSessionCipher sessionCipher = new SignalSealedSessionCipher(sessionLock, new SealedSessionCipher(signalProtocolStore, localAddress.getServiceId().uuid(), localAddress.getNumber().orNull(), localDeviceId));
|
||||
CiphertextMessage message = groupCipher.encrypt(distributionId.asUuid(), transport.getPaddedMessageBody(unpaddedMessage));
|
||||
UnidentifiedSenderMessageContent messageContent = new UnidentifiedSenderMessageContent(message,
|
||||
senderCertificate,
|
||||
@@ -117,7 +117,7 @@ public class SignalServiceCipher {
|
||||
{
|
||||
if (unidentifiedAccess.isPresent()) {
|
||||
SignalSessionCipher sessionCipher = new SignalSessionCipher(sessionLock, new SessionCipher(signalProtocolStore, destination));
|
||||
SignalSealedSessionCipher sealedSessionCipher = new SignalSealedSessionCipher(sessionLock, new SealedSessionCipher(signalProtocolStore, localAddress.getAci().uuid(), localAddress.getNumber().orNull(), localDeviceId));
|
||||
SignalSealedSessionCipher sealedSessionCipher = new SignalSealedSessionCipher(sessionLock, new SealedSessionCipher(signalProtocolStore, localAddress.getServiceId().uuid(), localAddress.getNumber().orNull(), localDeviceId));
|
||||
|
||||
return content.processSealedSender(sessionCipher, sealedSessionCipher, destination, unidentifiedAccess.get().getUnidentifiedCertificate());
|
||||
} else {
|
||||
@@ -208,7 +208,7 @@ public class SignalServiceCipher {
|
||||
paddedMessage = new PlaintextContent(ciphertext).getBody();
|
||||
metadata = new SignalServiceMetadata(envelope.getSourceAddress(), envelope.getSourceDevice(), envelope.getTimestamp(), envelope.getServerReceivedTimestamp(), envelope.getServerDeliveredTimestamp(), false, envelope.getServerGuid(), Optional.absent());
|
||||
} else if (envelope.isUnidentifiedSender()) {
|
||||
SignalSealedSessionCipher sealedSessionCipher = new SignalSealedSessionCipher(sessionLock, new SealedSessionCipher(signalProtocolStore, localAddress.getAci().uuid(), localAddress.getNumber().orNull(), localDeviceId));
|
||||
SignalSealedSessionCipher sealedSessionCipher = new SignalSealedSessionCipher(sessionLock, new SealedSessionCipher(signalProtocolStore, localAddress.getServiceId().uuid(), localAddress.getNumber().orNull(), localDeviceId));
|
||||
DecryptionResult result = sealedSessionCipher.decrypt(certificateValidator, ciphertext, envelope.getServerReceivedTimestamp());
|
||||
SignalServiceAddress resultAddress = new SignalServiceAddress(ACI.parseOrThrow(result.getSenderUuid()), result.getSenderE164());
|
||||
Optional<byte[]> groupId = result.getGroupId();
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.whispersystems.libsignal.InvalidMessageException;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.util.OptionalUtil;
|
||||
|
||||
@@ -610,17 +611,17 @@ public class SignalServiceDataMessage {
|
||||
}
|
||||
|
||||
public static class Mention {
|
||||
private final ACI aci;
|
||||
private final int start;
|
||||
private final int length;
|
||||
private final ServiceId aci;
|
||||
private final int start;
|
||||
private final int length;
|
||||
|
||||
public Mention(ACI aci, int start, int length) {
|
||||
public Mention(ServiceId aci, int start, int length) {
|
||||
this.aci = aci;
|
||||
this.start = start;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public ACI getAci() {
|
||||
public ServiceId getAci() {
|
||||
return aci;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.Envelope;
|
||||
import org.whispersystems.signalservice.internal.serialize.protos.SignalServiceEnvelopeProto;
|
||||
import org.whispersystems.util.Base64;
|
||||
@@ -71,7 +70,7 @@ public class SignalServiceEnvelope {
|
||||
.setServerTimestamp(serverReceivedTimestamp);
|
||||
|
||||
if (sender.isPresent()) {
|
||||
builder.setSourceUuid(sender.get().getAci().toString());
|
||||
builder.setSourceUuid(sender.get().getServiceId().toString());
|
||||
|
||||
if (sender.get().getNumber().isPresent()) {
|
||||
builder.setSourceE164(sender.get().getNumber().get());
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DeviceContactsOutputStream extends ChunkedOutputStream {
|
||||
private void writeContactDetails(DeviceContact contact) throws IOException {
|
||||
SignalServiceProtos.ContactDetails.Builder contactDetails = SignalServiceProtos.ContactDetails.newBuilder();
|
||||
|
||||
contactDetails.setUuid(contact.getAddress().getAci().toString());
|
||||
contactDetails.setUuid(contact.getAddress().getServiceId().toString());
|
||||
|
||||
if (contact.getAddress().getNumber().isPresent()) {
|
||||
contactDetails.setNumber(contact.getAddress().getNumber().get());
|
||||
@@ -69,7 +69,7 @@ public class DeviceContactsOutputStream extends ChunkedOutputStream {
|
||||
|
||||
SignalServiceProtos.Verified.Builder verifiedBuilder = SignalServiceProtos.Verified.newBuilder()
|
||||
.setIdentityKey(ByteString.copyFrom(contact.getVerified().get().getIdentityKey().serialize()))
|
||||
.setDestinationUuid(contact.getVerified().get().getDestination().getAci().toString())
|
||||
.setDestinationUuid(contact.getVerified().get().getDestination().getServiceId().toString())
|
||||
.setState(state);
|
||||
|
||||
if (contact.getVerified().get().getDestination().getNumber().isPresent()) {
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.whispersystems.signalservice.api.messages.multidevice;
|
||||
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -21,26 +21,29 @@ public class SentTranscriptMessage {
|
||||
private final long timestamp;
|
||||
private final long expirationStartTimestamp;
|
||||
private final SignalServiceDataMessage message;
|
||||
private final Map<String, Boolean> unidentifiedStatusByAci;
|
||||
private final Map<String, Boolean> unidentifiedStatusBySid;
|
||||
private final Map<String, Boolean> unidentifiedStatusByE164;
|
||||
private final Set<SignalServiceAddress> recipients;
|
||||
private final boolean isRecipientUpdate;
|
||||
|
||||
public SentTranscriptMessage(Optional<SignalServiceAddress> destination, long timestamp, SignalServiceDataMessage message,
|
||||
long expirationStartTimestamp, Map<SignalServiceAddress, Boolean> unidentifiedStatus,
|
||||
public SentTranscriptMessage(Optional<SignalServiceAddress> destination,
|
||||
long timestamp,
|
||||
SignalServiceDataMessage message,
|
||||
long expirationStartTimestamp,
|
||||
Map<SignalServiceAddress, Boolean> unidentifiedStatus,
|
||||
boolean isRecipientUpdate)
|
||||
{
|
||||
this.destination = destination;
|
||||
this.timestamp = timestamp;
|
||||
this.message = message;
|
||||
this.expirationStartTimestamp = expirationStartTimestamp;
|
||||
this.unidentifiedStatusByAci = new HashMap<>();
|
||||
this.unidentifiedStatusBySid = new HashMap<>();
|
||||
this.unidentifiedStatusByE164 = new HashMap<>();
|
||||
this.recipients = unidentifiedStatus.keySet();
|
||||
this.isRecipientUpdate = isRecipientUpdate;
|
||||
|
||||
for (Map.Entry<SignalServiceAddress, Boolean> entry : unidentifiedStatus.entrySet()) {
|
||||
unidentifiedStatusByAci.put(entry.getKey().getAci().toString(), entry.getValue());
|
||||
unidentifiedStatusBySid.put(entry.getKey().getServiceId().toString(), entry.getValue());
|
||||
|
||||
if (entry.getKey().getNumber().isPresent()) {
|
||||
unidentifiedStatusByE164.put(entry.getKey().getNumber().get(), entry.getValue());
|
||||
@@ -64,13 +67,13 @@ public class SentTranscriptMessage {
|
||||
return message;
|
||||
}
|
||||
|
||||
public boolean isUnidentified(ACI aci) {
|
||||
return isUnidentified(aci.toString());
|
||||
public boolean isUnidentified(ServiceId serviceId) {
|
||||
return isUnidentified(serviceId.toString());
|
||||
}
|
||||
|
||||
public boolean isUnidentified(String destination) {
|
||||
if (unidentifiedStatusByAci.containsKey(destination)) {
|
||||
return unidentifiedStatusByAci.get(destination);
|
||||
if (unidentifiedStatusBySid.containsKey(destination)) {
|
||||
return unidentifiedStatusBySid.get(destination);
|
||||
} else if (unidentifiedStatusByE164.containsKey(destination)) {
|
||||
return unidentifiedStatusByE164.get(destination);
|
||||
} else {
|
||||
|
||||
@@ -2,19 +2,15 @@ package org.whispersystems.signalservice.api.push;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* An ACI is an "Account Identity". They're just UUIDs, but given multiple different things could be UUIDs, this wrapper exists to give us type safety around
|
||||
* this *specific type* of UUID.
|
||||
*/
|
||||
public final class ACI extends AccountIdentifier {
|
||||
public final class ACI extends ServiceId {
|
||||
|
||||
public static final ACI UNKNOWN = ACI.from(UuidUtil.UNKNOWN_UUID);
|
||||
|
||||
@@ -22,51 +18,15 @@ public final class ACI extends AccountIdentifier {
|
||||
return new ACI(uuid);
|
||||
}
|
||||
|
||||
public static Optional<ACI> parse(String raw) {
|
||||
return UuidUtil.parse(raw).transform(ACI::from);
|
||||
}
|
||||
|
||||
public static ACI parseOrThrow(String raw) {
|
||||
return from(UUID.fromString(raw));
|
||||
}
|
||||
|
||||
public static ACI parseOrThrow(byte[] raw) {
|
||||
return from(UuidUtil.parseOrThrow(raw));
|
||||
}
|
||||
|
||||
public static ACI parseOrNull(String raw) {
|
||||
UUID uuid = UuidUtil.parseOrNull(raw);
|
||||
return uuid != null ? from(uuid) : null;
|
||||
}
|
||||
|
||||
public static ACI parseOrNull(byte[] raw) {
|
||||
UUID uuid = UuidUtil.parseOrNull(raw);
|
||||
return uuid != null ? from(uuid) : null;
|
||||
}
|
||||
|
||||
public static ACI parseOrUnknown(String raw) {
|
||||
ACI aci = parseOrNull(raw);
|
||||
return aci != null ? aci : UNKNOWN;
|
||||
}
|
||||
|
||||
public static ACI fromByteString(ByteString bytes) {
|
||||
return parseOrThrow(bytes.toByteArray());
|
||||
}
|
||||
|
||||
public static ACI fromByteStringOrNull(ByteString bytes) {
|
||||
UUID uuid = UuidUtil.fromByteStringOrNull(bytes);
|
||||
return uuid != null ? from(uuid) : null;
|
||||
}
|
||||
|
||||
public static ACI fromByteStringOrUnknown(ByteString bytes) {
|
||||
ACI uuid = fromByteStringOrNull(bytes);
|
||||
return uuid != null ? uuid : UNKNOWN;
|
||||
}
|
||||
|
||||
public static List<ACI> filterKnown(Collection<ACI> acis) {
|
||||
return acis.stream().filter(aci -> !aci.equals(UNKNOWN)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private ACI(UUID uuid) {
|
||||
super(uuid);
|
||||
}
|
||||
@@ -79,13 +39,13 @@ public final class ACI extends AccountIdentifier {
|
||||
return UuidUtil.toByteArray(uuid);
|
||||
}
|
||||
|
||||
public boolean isUnknown() {
|
||||
return this.equals(UNKNOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAci() {
|
||||
return true;
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof ServiceId) {
|
||||
return uuid.equals(((ServiceId) other).uuid);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,15 +53,6 @@ public final class ACI extends AccountIdentifier {
|
||||
return uuid.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof ACI) {
|
||||
return uuid.equals(((ACI) other).uuid);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return uuid.toString();
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package org.whispersystems.signalservice.api.push;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A wrapper around a UUID that represents an identifier for an account. Today, that is either an {@link ACI} or a {@link PNI}.
|
||||
*/
|
||||
public abstract class AccountIdentifier {
|
||||
|
||||
protected final UUID uuid;
|
||||
|
||||
protected AccountIdentifier(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public UUID uuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public abstract boolean isAci();
|
||||
|
||||
public final boolean isPni() {
|
||||
return !isAci();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return uuid.toString();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import java.util.UUID;
|
||||
* A PNI is a "Phone Number Identity". They're just UUIDs, but given multiple different things could be UUIDs, this wrapper exists to give us type safety around
|
||||
* this *specific type* of UUID.
|
||||
*/
|
||||
public final class PNI extends AccountIdentifier {
|
||||
public final class PNI extends ServiceId {
|
||||
|
||||
public static PNI from(UUID uuid) {
|
||||
return new PNI(uuid);
|
||||
@@ -27,11 +27,6 @@ public final class PNI extends AccountIdentifier {
|
||||
super(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAci() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return uuid.hashCode();
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package org.whispersystems.signalservice.api.push;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
|
||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* A wrapper around a UUID that represents an identifier for an account. Today, that is either an {@link ACI} or a {@link PNI}.
|
||||
* However, that doesn't mean every {@link ServiceId} is an <em>instance</em> of one of those classes. In reality, we often
|
||||
* do not know which we have. And it shouldn't really matter.
|
||||
*
|
||||
* The only times you truly know, and the only times you should actually care, is during CDS refreshes or specific inbound messages
|
||||
* that link them together.
|
||||
*/
|
||||
public class ServiceId {
|
||||
|
||||
public static final ServiceId UNKNOWN = ServiceId.from(UuidUtil.UNKNOWN_UUID);
|
||||
|
||||
protected final UUID uuid;
|
||||
|
||||
protected ServiceId(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public static ServiceId from(UUID uuid) {
|
||||
return new ServiceId(uuid);
|
||||
}
|
||||
|
||||
public static ServiceId parseOrThrow(String raw) {
|
||||
return from(UUID.fromString(raw));
|
||||
}
|
||||
|
||||
public static ServiceId parseOrThrow(byte[] raw) {
|
||||
return from(UuidUtil.parseOrThrow(raw));
|
||||
}
|
||||
|
||||
public static ServiceId parseOrNull(String raw) {
|
||||
UUID uuid = UuidUtil.parseOrNull(raw);
|
||||
return uuid != null ? from(uuid) : null;
|
||||
}
|
||||
|
||||
public static ServiceId parseOrNull(byte[] raw) {
|
||||
UUID uuid = UuidUtil.parseOrNull(raw);
|
||||
return uuid != null ? from(uuid) : null;
|
||||
}
|
||||
|
||||
public static ServiceId parseOrUnknown(String raw) {
|
||||
ServiceId aci = parseOrNull(raw);
|
||||
return aci != null ? aci : UNKNOWN;
|
||||
}
|
||||
|
||||
public static ServiceId fromByteString(ByteString bytes) {
|
||||
return parseOrThrow(bytes.toByteArray());
|
||||
}
|
||||
|
||||
public static ServiceId fromByteStringOrNull(ByteString bytes) {
|
||||
UUID uuid = UuidUtil.fromByteStringOrNull(bytes);
|
||||
return uuid != null ? from(uuid) : null;
|
||||
}
|
||||
|
||||
public static ServiceId fromByteStringOrUnknown(ByteString bytes) {
|
||||
ServiceId uuid = fromByteStringOrNull(bytes);
|
||||
return uuid != null ? uuid : UNKNOWN;
|
||||
}
|
||||
|
||||
public UUID uuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public boolean isUnknown() {
|
||||
return uuid.equals(UNKNOWN.uuid);
|
||||
}
|
||||
|
||||
public SignalProtocolAddress toProtocolAddress(int deviceId) {
|
||||
return new SignalProtocolAddress(uuid.toString(), deviceId);
|
||||
}
|
||||
|
||||
public ByteString toByteString() {
|
||||
return UuidUtil.toByteString(uuid);
|
||||
}
|
||||
|
||||
public byte[] toByteArray() {
|
||||
return UuidUtil.toByteArray(uuid);
|
||||
}
|
||||
|
||||
public static List<ServiceId> filterKnown(Collection<ServiceId> serviceIds) {
|
||||
return serviceIds.stream().filter(sid -> !sid.equals(UNKNOWN)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return uuid.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ServiceId)) return false;
|
||||
final ServiceId serviceId = (ServiceId) o;
|
||||
return Objects.equals(uuid, serviceId.uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return uuid.hashCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.whispersystems.signalservice.api.push;
|
||||
|
||||
public enum ServiceIdType {
|
||||
ACI("aci"), PNI("pni");
|
||||
|
||||
private final String queryParamName;
|
||||
|
||||
ServiceIdType(String queryParamName) {
|
||||
this.queryParamName = queryParamName;
|
||||
}
|
||||
|
||||
public String queryParam() {
|
||||
return queryParamName;
|
||||
}
|
||||
}
|
||||
@@ -20,50 +20,50 @@ public class SignalServiceAddress {
|
||||
|
||||
public static final int DEFAULT_DEVICE_ID = 1;
|
||||
|
||||
private final ACI aci;
|
||||
private final ServiceId serviceId;
|
||||
private final Optional<String> e164;
|
||||
|
||||
/**
|
||||
* Construct a PushAddress.
|
||||
*
|
||||
* @param aci The UUID of the user, if available.
|
||||
* @param serviceId The UUID of the user, if available.
|
||||
* @param e164 The phone number of the user, if available.
|
||||
*/
|
||||
public SignalServiceAddress(ACI aci, Optional<String> e164) {
|
||||
this.aci = Preconditions.checkNotNull(aci);
|
||||
this.e164 = e164;
|
||||
public SignalServiceAddress(ServiceId serviceId, Optional<String> e164) {
|
||||
this.serviceId = Preconditions.checkNotNull(serviceId);
|
||||
this.e164 = e164;
|
||||
}
|
||||
|
||||
public SignalServiceAddress(ACI aci) {
|
||||
this.aci = Preconditions.checkNotNull(aci);
|
||||
this.e164 = Optional.absent();
|
||||
public SignalServiceAddress(ServiceId serviceId) {
|
||||
this.serviceId = Preconditions.checkNotNull(serviceId);
|
||||
this.e164 = Optional.absent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor that will consider a UUID/E164 string absent if it is null or empty.
|
||||
*/
|
||||
public SignalServiceAddress(ACI aci, String e164) {
|
||||
this(aci, OptionalUtil.absentIfEmpty(e164));
|
||||
public SignalServiceAddress(ServiceId serviceId, String e164) {
|
||||
this(serviceId, OptionalUtil.absentIfEmpty(e164));
|
||||
}
|
||||
|
||||
public Optional<String> getNumber() {
|
||||
return e164;
|
||||
}
|
||||
|
||||
public ACI getAci() {
|
||||
return aci;
|
||||
public ServiceId getServiceId() {
|
||||
return serviceId;
|
||||
}
|
||||
|
||||
public boolean hasValidAci() {
|
||||
return !aci.uuid().equals(UuidUtil.UNKNOWN_UUID);
|
||||
public boolean hasValidServiceId() {
|
||||
return !serviceId.isUnknown();
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return aci.toString();
|
||||
return serviceId.toString();
|
||||
}
|
||||
|
||||
public boolean matches(SignalServiceAddress other) {
|
||||
return this.aci.equals(other.aci);
|
||||
return this.serviceId.equals(other.serviceId);
|
||||
}
|
||||
|
||||
public static boolean isValidAddress(String rawUuid, String e164) {
|
||||
@@ -82,10 +82,10 @@ public class SignalServiceAddress {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final SignalServiceAddress that = (SignalServiceAddress) o;
|
||||
return aci.equals(that.aci) && e164.equals(that.e164);
|
||||
return serviceId.equals(that.serviceId) && e164.equals(that.e164);
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return Objects.hash(aci, e164);
|
||||
return Objects.hash(serviceId, e164);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
|
||||
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
|
||||
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.MalformedResponseException;
|
||||
import org.whispersystems.signalservice.internal.ServiceResponse;
|
||||
@@ -29,7 +30,6 @@ import org.whispersystems.signalservice.internal.websocket.WebSocketProtos;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
@@ -61,8 +61,8 @@ public final class ProfileService {
|
||||
SignalServiceProfile.RequestType requestType,
|
||||
Locale locale)
|
||||
{
|
||||
ACI aci = address.getAci();
|
||||
SecureRandom random = new SecureRandom();
|
||||
ServiceId serviceId = address.getServiceId();
|
||||
SecureRandom random = new SecureRandom();
|
||||
ProfileKeyCredentialRequestContext requestContext = null;
|
||||
|
||||
WebSocketProtos.WebSocketRequestMessage.Builder builder = WebSocketProtos.WebSocketRequestMessage.newBuilder()
|
||||
@@ -70,18 +70,18 @@ public final class ProfileService {
|
||||
.setVerb("GET");
|
||||
|
||||
if (profileKey.isPresent()) {
|
||||
ProfileKeyVersion profileKeyIdentifier = profileKey.get().getProfileKeyVersion(aci.uuid());
|
||||
ProfileKeyVersion profileKeyIdentifier = profileKey.get().getProfileKeyVersion(serviceId.uuid());
|
||||
String version = profileKeyIdentifier.serialize();
|
||||
|
||||
if (requestType == SignalServiceProfile.RequestType.PROFILE_AND_CREDENTIAL) {
|
||||
requestContext = clientZkProfileOperations.createProfileKeyCredentialRequestContext(random, aci.uuid(), profileKey.get());
|
||||
requestContext = clientZkProfileOperations.createProfileKeyCredentialRequestContext(random, serviceId.uuid(), profileKey.get());
|
||||
|
||||
ProfileKeyCredentialRequest request = requestContext.getRequest();
|
||||
String credentialRequest = Hex.toStringCondensed(request.serialize());
|
||||
|
||||
builder.setPath(String.format("/v1/profile/%s/%s/%s", aci, version, credentialRequest));
|
||||
builder.setPath(String.format("/v1/profile/%s/%s/%s", serviceId, version, credentialRequest));
|
||||
} else {
|
||||
builder.setPath(String.format("/v1/profile/%s/%s", aci, version));
|
||||
builder.setPath(String.format("/v1/profile/%s/%s", serviceId, version));
|
||||
}
|
||||
} else {
|
||||
builder.setPath(String.format("/v1/profile/%s", address.getIdentifier()));
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.util.OptionalUtil;
|
||||
import org.whispersystems.signalservice.api.util.ProtoUtil;
|
||||
import org.whispersystems.signalservice.internal.storage.protos.AccountRecord;
|
||||
import org.whispersystems.signalservice.internal.storage.protos.GroupV2Record;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -346,7 +345,7 @@ public final class SignalAccountRecord implements SignalRecord {
|
||||
if (contact.isPresent()) {
|
||||
AccountRecord.PinnedConversation.Contact.Builder contactBuilder = AccountRecord.PinnedConversation.Contact.newBuilder();
|
||||
|
||||
contactBuilder.setUuid(contact.get().getAci().toString());
|
||||
contactBuilder.setUuid(contact.get().getServiceId().toString());
|
||||
|
||||
if (contact.get().getNumber().isPresent()) {
|
||||
contactBuilder.setE164(contact.get().getNumber().get());
|
||||
|
||||
@@ -9,10 +9,8 @@ import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.util.OptionalUtil;
|
||||
import org.whispersystems.signalservice.api.util.ProtoUtil;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
import org.whispersystems.signalservice.internal.storage.protos.ContactRecord;
|
||||
import org.whispersystems.signalservice.internal.storage.protos.ContactRecord.IdentityState;
|
||||
import org.whispersystems.signalservice.internal.storage.protos.GroupV2Record;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
@@ -71,7 +69,7 @@ public final class SignalContactRecord implements SignalRecord {
|
||||
diff.add("E164");
|
||||
}
|
||||
|
||||
if (!Objects.equals(this.getAddress().getAci(), that.getAddress().getAci())) {
|
||||
if (!Objects.equals(this.getAddress().getServiceId(), that.getAddress().getServiceId())) {
|
||||
diff.add("UUID");
|
||||
}
|
||||
|
||||
@@ -216,7 +214,7 @@ public final class SignalContactRecord implements SignalRecord {
|
||||
this.builder = ContactRecord.newBuilder();
|
||||
}
|
||||
|
||||
builder.setServiceUuid(address.getAci().toString());
|
||||
builder.setServiceUuid(address.getServiceId().toString());
|
||||
builder.setServiceE164(address.getNumber().or(""));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ import org.whispersystems.signalservice.api.payments.CurrencyConversions;
|
||||
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
|
||||
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
|
||||
import org.whispersystems.signalservice.api.profiles.SignalServiceProfileWrite;
|
||||
import org.whispersystems.signalservice.api.push.AccountIdentifier;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.ServiceIdType;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.SignedPreKeyEntity;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
||||
@@ -330,7 +331,7 @@ public class PushServiceSocket {
|
||||
return JsonUtil.fromJson(makeServiceRequest(WHO_AM_I, "GET", null), WhoAmIResponse.class);
|
||||
}
|
||||
|
||||
public boolean isIdentifierRegistered(AccountIdentifier identifier) throws IOException {
|
||||
public boolean isIdentifierRegistered(ServiceId identifier) throws IOException {
|
||||
try {
|
||||
makeServiceRequestWithoutAuthentication(String.format(IDENTIFIER_REGISTERED_PATH, identifier.toString()), "HEAD", null);
|
||||
return true;
|
||||
@@ -563,7 +564,7 @@ public class PushServiceSocket {
|
||||
makeServiceRequest(String.format(UUID_ACK_MESSAGE_PATH, uuid), "DELETE", null);
|
||||
}
|
||||
|
||||
public void registerPreKeys(AccountIdentifier accountId,
|
||||
public void registerPreKeys(ServiceIdType serviceIdType,
|
||||
IdentityKey identityKey,
|
||||
SignedPreKeyRecord signedPreKey,
|
||||
List<PreKeyRecord> records)
|
||||
@@ -582,13 +583,13 @@ public class PushServiceSocket {
|
||||
signedPreKey.getKeyPair().getPublicKey(),
|
||||
signedPreKey.getSignature());
|
||||
|
||||
makeServiceRequest(String.format(Locale.US, PREKEY_PATH, "", accountId.isAci() ? "aci" : "pni"),
|
||||
makeServiceRequest(String.format(Locale.US, PREKEY_PATH, "", serviceIdType.queryParam()),
|
||||
"PUT",
|
||||
JsonUtil.toJson(new PreKeyState(entities, signedPreKeyEntity, identityKey)));
|
||||
}
|
||||
|
||||
public int getAvailablePreKeys(AccountIdentifier accountId) throws IOException {
|
||||
String path = String.format(PREKEY_METADATA_PATH, accountId.isAci() ? "aci" : "pni");
|
||||
public int getAvailablePreKeys(ServiceIdType serviceIdType) throws IOException {
|
||||
String path = String.format(PREKEY_METADATA_PATH, serviceIdType.queryParam());
|
||||
String responseText = makeServiceRequest(path, "GET", null);
|
||||
PreKeyStatus preKeyStatus = JsonUtil.fromJson(responseText, PreKeyStatus.class);
|
||||
|
||||
@@ -678,9 +679,9 @@ public class PushServiceSocket {
|
||||
}
|
||||
}
|
||||
|
||||
public SignedPreKeyEntity getCurrentSignedPreKey(AccountIdentifier accountId) throws IOException {
|
||||
public SignedPreKeyEntity getCurrentSignedPreKey(ServiceIdType serviceIdType) throws IOException {
|
||||
try {
|
||||
String path = String.format(SIGNED_PREKEY_PATH, accountId.isAci() ? "aci" : "pni");
|
||||
String path = String.format(SIGNED_PREKEY_PATH, serviceIdType.queryParam());
|
||||
String responseText = makeServiceRequest(path, "GET", null);
|
||||
return JsonUtil.fromJson(responseText, SignedPreKeyEntity.class);
|
||||
} catch (NotFoundException e) {
|
||||
@@ -689,8 +690,8 @@ public class PushServiceSocket {
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentSignedPreKey(AccountIdentifier accountId, SignedPreKeyRecord signedPreKey) throws IOException {
|
||||
String path = String.format(SIGNED_PREKEY_PATH, accountId.isAci() ? "aci" : "pni");
|
||||
public void setCurrentSignedPreKey(ServiceIdType serviceIdType, SignedPreKeyRecord signedPreKey) throws IOException {
|
||||
String path = String.format(SIGNED_PREKEY_PATH, serviceIdType.queryParam());
|
||||
SignedPreKeyEntity signedPreKeyEntity = new SignedPreKeyEntity(signedPreKey.getId(),
|
||||
signedPreKey.getKeyPair().getPublicKey(),
|
||||
signedPreKey.getSignature());
|
||||
|
||||
@@ -21,9 +21,9 @@ public class SendGroupMessageResponse {
|
||||
Set<ACI> acis = new HashSet<>(uuids404.length);
|
||||
|
||||
for (String raw : uuids404) {
|
||||
Optional<ACI> parsed = ACI.parse(raw);
|
||||
if (parsed.isPresent()) {
|
||||
acis.add(parsed.get());
|
||||
ACI parsed = ACI.parseOrNull(raw);
|
||||
if (parsed != null) {
|
||||
acis.add(parsed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.whispersystems.signalservice.internal.serialize;
|
||||
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.internal.serialize.protos.AddressProto;
|
||||
|
||||
@@ -13,7 +14,7 @@ public final class SignalServiceAddressProtobufSerializer {
|
||||
public static AddressProto toProtobuf(SignalServiceAddress signalServiceAddress) {
|
||||
AddressProto.Builder builder = AddressProto.newBuilder();
|
||||
|
||||
builder.setUuid(signalServiceAddress.getAci().toByteString());
|
||||
builder.setUuid(signalServiceAddress.getServiceId().toByteString());
|
||||
|
||||
if(signalServiceAddress.getNumber().isPresent()){
|
||||
builder.setE164(signalServiceAddress.getNumber().get());
|
||||
@@ -23,9 +24,9 @@ public final class SignalServiceAddressProtobufSerializer {
|
||||
}
|
||||
|
||||
public static SignalServiceAddress fromProtobuf(AddressProto addressProto) {
|
||||
ACI aci = ACI.parseOrThrow(addressProto.getUuid().toByteArray());
|
||||
Optional<String> number = addressProto.hasE164() ? Optional.of(addressProto.getE164()) : Optional.absent();
|
||||
ServiceId serviceId = ServiceId.parseOrThrow(addressProto.getUuid().toByteArray());
|
||||
Optional<String> number = addressProto.hasE164() ? Optional.of(addressProto.getE164()) : Optional.absent();
|
||||
|
||||
return new SignalServiceAddress(aci, number);
|
||||
return new SignalServiceAddress(serviceId, number);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.whispersystems.signalservice.internal.serialize;
|
||||
import org.junit.Test;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.internal.serialize.protos.AddressProto;
|
||||
|
||||
@@ -14,7 +15,7 @@ public final class SignalServiceAddressProtobufSerializerTest {
|
||||
|
||||
@Test
|
||||
public void serialize_and_deserialize_uuid_address() {
|
||||
SignalServiceAddress address = new SignalServiceAddress(ACI.from(UUID.randomUUID()), Optional.absent());
|
||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.from(UUID.randomUUID()), Optional.absent());
|
||||
AddressProto addressProto = org.whispersystems.signalservice.internal.serialize.SignalServiceAddressProtobufSerializer.toProtobuf(address);
|
||||
SignalServiceAddress deserialized = org.whispersystems.signalservice.internal.serialize.SignalServiceAddressProtobufSerializer.fromProtobuf(addressProto);
|
||||
|
||||
@@ -23,7 +24,7 @@ public final class SignalServiceAddressProtobufSerializerTest {
|
||||
|
||||
@Test
|
||||
public void serialize_and_deserialize_both_address() {
|
||||
SignalServiceAddress address = new SignalServiceAddress(ACI.from(UUID.randomUUID()), Optional.of("+15552345678"));
|
||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.from(UUID.randomUUID()), Optional.of("+15552345678"));
|
||||
AddressProto addressProto = org.whispersystems.signalservice.internal.serialize.SignalServiceAddressProtobufSerializer.toProtobuf(address);
|
||||
SignalServiceAddress deserialized = org.whispersystems.signalservice.internal.serialize.SignalServiceAddressProtobufSerializer.fromProtobuf(addressProto);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user