Search in sources :

Example 26 with ACI

use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.

the class RecipientIdCacheTest method remains_in_cache_when_used_before_reaching_cache_limit.

@Test
public void remains_in_cache_when_used_before_reaching_cache_limit() {
    RecipientId recipientId1 = recipientId();
    ACI aci1 = ACI.from(UUID.randomUUID());
    recipientIdCache.put(recipient(recipientId1, aci1, null));
    for (int i = 0; i < TEST_CACHE_LIMIT - 1; i++) {
        recipientIdCache.put(recipient(recipientId(), ACI.from(UUID.randomUUID()), null));
    }
    assertEquals(recipientId1, recipientIdCache.get(aci1, null));
    recipientIdCache.put(recipient(recipientId(), ACI.from(UUID.randomUUID()), null));
    assertEquals(recipientId1, recipientIdCache.get(aci1, null));
}
Also used : ACI(org.whispersystems.signalservice.api.push.ACI) Test(org.junit.Test)

Example 27 with ACI

use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.

the class RecipientIdCacheTest method cache_hit_by_both.

@Test
public void cache_hit_by_both() {
    RecipientId recipientId1 = recipientId();
    ACI aci1 = ACI.from(UUID.randomUUID());
    String e164 = "+1555123456";
    recipientIdCache.put(recipient(recipientId1, aci1, e164));
    RecipientId recipientId = recipientIdCache.get(aci1, e164);
    assertEquals(recipientId1, recipientId);
}
Also used : ACI(org.whispersystems.signalservice.api.push.ACI) Test(org.junit.Test)

Example 28 with ACI

use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.

the class RecipientIdCacheTest method cache_hit_by_e164_uuid_not_supplied_on_get.

@Test
public void cache_hit_by_e164_uuid_not_supplied_on_get() {
    RecipientId recipientId1 = recipientId();
    ACI aci1 = ACI.from(UUID.randomUUID());
    recipientIdCache.put(recipient(recipientId1, aci1, "+15551234567"));
    RecipientId recipientId = recipientIdCache.get(null, "+15551234567");
    assertEquals(recipientId1, recipientId);
}
Also used : ACI(org.whispersystems.signalservice.api.push.ACI) Test(org.junit.Test)

Example 29 with ACI

use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.

the class GroupsV2StateProcessor method forGroup.

public StateProcessorForGroup forGroup(@NonNull GroupMasterKey groupMasterKey) {
    ACI selfAci = SignalStore.account().requireAci();
    ProfileAndMessageHelper profileAndMessageHelper = new ProfileAndMessageHelper(context, selfAci, groupMasterKey, GroupId.v2(groupMasterKey), recipientDatabase);
    return new StateProcessorForGroup(selfAci, context, groupDatabase, groupsV2Api, groupsV2Authorization, groupMasterKey, profileAndMessageHelper);
}
Also used : ACI(org.whispersystems.signalservice.api.push.ACI)

Example 30 with ACI

use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.

the class SignalServiceAccountManager method setVersionedProfile.

/**
 * @return The avatar URL path, if one was written.
 */
public Optional<String> setVersionedProfile(ACI aci, ProfileKey profileKey, String name, String about, String aboutEmoji, Optional<SignalServiceProtos.PaymentAddress> paymentsAddress, StreamDetails avatar, List<String> visibleBadgeIds) throws IOException {
    if (name == null)
        name = "";
    ProfileCipher profileCipher = new ProfileCipher(profileKey);
    byte[] ciphertextName = profileCipher.encryptString(name, ProfileCipher.getTargetNameLength(name));
    byte[] ciphertextAbout = profileCipher.encryptString(about, ProfileCipher.getTargetAboutLength(about));
    byte[] ciphertextEmoji = profileCipher.encryptString(aboutEmoji, ProfileCipher.EMOJI_PADDED_LENGTH);
    byte[] ciphertextMobileCoinAddress = paymentsAddress.transform(address -> profileCipher.encryptWithLength(address.toByteArray(), ProfileCipher.PAYMENTS_ADDRESS_CONTENT_SIZE)).orNull();
    boolean hasAvatar = avatar != null;
    ProfileAvatarData profileAvatarData = null;
    if (hasAvatar) {
        profileAvatarData = new ProfileAvatarData(avatar.getStream(), ProfileCipherOutputStream.getCiphertextLength(avatar.getLength()), avatar.getContentType(), new ProfileCipherOutputStreamFactory(profileKey));
    }
    return this.pushServiceSocket.writeProfile(new SignalServiceProfileWrite(profileKey.getProfileKeyVersion(aci.uuid()).serialize(), ciphertextName, ciphertextAbout, ciphertextEmoji, ciphertextMobileCoinAddress, hasAvatar, profileKey.getCommitment(aci.uuid()).serialize(), visibleBadgeIds), profileAvatarData);
}
Also used : ReadOperation(org.whispersystems.signalservice.internal.storage.protos.ReadOperation) ServiceIdType(org.whispersystems.signalservice.api.push.ServiceIdType) Quote(org.whispersystems.signalservice.internal.contacts.crypto.Quote) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) StorageManifest(org.whispersystems.signalservice.internal.storage.protos.StorageManifest) ProfileCipher(org.whispersystems.signalservice.api.crypto.ProfileCipher) ProfileAndCredential(org.whispersystems.signalservice.api.profiles.ProfileAndCredential) StorageKey(org.whispersystems.signalservice.api.storage.StorageKey) Preconditions(org.whispersystems.libsignal.util.guava.Preconditions) Map(java.util.Map) SignalStorageModels(org.whispersystems.signalservice.api.storage.SignalStorageModels) AuthCredentials(org.whispersystems.signalservice.internal.push.AuthCredentials) ProvisionMessage(org.whispersystems.signalservice.internal.push.ProvisioningProtos.ProvisionMessage) RequestVerificationCodeResponse(org.whispersystems.signalservice.internal.push.RequestVerificationCodeResponse) SignalStorageCipher(org.whispersystems.signalservice.api.storage.SignalStorageCipher) SignalServiceProtos(org.whispersystems.signalservice.internal.push.SignalServiceProtos) RemoteAttestationUtil(org.whispersystems.signalservice.internal.push.RemoteAttestationUtil) ACI(org.whispersystems.signalservice.api.push.ACI) Set(java.util.Set) GroupsV2Operations(org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations) IdentityKey(org.whispersystems.libsignal.IdentityKey) CredentialsProvider(org.whispersystems.signalservice.api.util.CredentialsProvider) ProfileCipherOutputStream(org.whispersystems.signalservice.api.crypto.ProfileCipherOutputStream) Base64(org.whispersystems.util.Base64) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IdentityKeyPair(org.whispersystems.libsignal.IdentityKeyPair) StorageManifestKey(org.whispersystems.signalservice.api.storage.StorageManifestKey) SignalStorageRecord(org.whispersystems.signalservice.api.storage.SignalStorageRecord) NoContentException(org.whispersystems.signalservice.api.push.exceptions.NoContentException) Single(io.reactivex.rxjava3.core.Single) SignalServiceProfileWrite(org.whispersystems.signalservice.api.profiles.SignalServiceProfileWrite) PreKeyRecord(org.whispersystems.libsignal.state.PreKeyRecord) InvalidKeyException(org.whispersystems.libsignal.InvalidKeyException) ArrayList(java.util.ArrayList) WhoAmIResponse(org.whispersystems.signalservice.internal.push.WhoAmIResponse) ECPublicKey(org.whispersystems.libsignal.ecc.ECPublicKey) DeviceInfo(org.whispersystems.signalservice.api.messages.multidevice.DeviceInfo) StaticCredentialsProvider(org.whispersystems.signalservice.internal.util.StaticCredentialsProvider) UnauthenticatedQuoteException(org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedQuoteException) ProfileKeyCredential(org.signal.zkgroup.profiles.ProfileKeyCredential) PushNetworkException(org.whispersystems.signalservice.api.push.exceptions.PushNetworkException) StreamDetails(org.whispersystems.signalservice.api.util.StreamDetails) IOException(java.io.IOException) ProfileAvatarData(org.whispersystems.signalservice.internal.push.ProfileAvatarData) GroupsV2Api(org.whispersystems.signalservice.api.groupsv2.GroupsV2Api) Optional(org.whispersystems.libsignal.util.guava.Optional) ExecutionException(java.util.concurrent.ExecutionException) PrimaryProvisioningCipher(org.whispersystems.signalservice.internal.crypto.PrimaryProvisioningCipher) ServiceId(org.whispersystems.signalservice.api.push.ServiceId) RemoteConfigResponse(org.whispersystems.signalservice.internal.push.RemoteConfigResponse) StorageItems(org.whispersystems.signalservice.internal.storage.protos.StorageItems) MasterKey(org.whispersystems.signalservice.api.kbs.MasterKey) TurnServerInfo(org.whispersystems.signalservice.api.messages.calls.TurnServerInfo) ManifestRecord(org.whispersystems.signalservice.internal.storage.protos.ManifestRecord) WriteOperation(org.whispersystems.signalservice.internal.storage.protos.WriteOperation) Util(org.whispersystems.signalservice.internal.util.Util) TimeoutException(java.util.concurrent.TimeoutException) SignedPreKeyRecord(org.whispersystems.libsignal.state.SignedPreKeyRecord) NotFoundException(org.whispersystems.signalservice.api.push.exceptions.NotFoundException) DiscoveryRequest(org.whispersystems.signalservice.internal.contacts.entities.DiscoveryRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) Locale(java.util.Locale) NonSuccessfulResponseCodeException(org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException) InvalidCiphertextException(org.whispersystems.signalservice.api.crypto.InvalidCiphertextException) CdshAuthResponse(org.whispersystems.signalservice.internal.push.CdshAuthResponse) StorageId(org.whispersystems.signalservice.api.storage.StorageId) ContactDiscoveryCipher(org.whispersystems.signalservice.internal.contacts.crypto.ContactDiscoveryCipher) VerifyAccountResponse(org.whispersystems.signalservice.internal.push.VerifyAccountResponse) PushServiceSocket(org.whispersystems.signalservice.internal.push.PushServiceSocket) VerifyDeviceResponse(org.whispersystems.signalservice.api.messages.multidevice.VerifyDeviceResponse) SignatureException(java.security.SignatureException) Collection(java.util.Collection) KeyStore(java.security.KeyStore) UUID(java.util.UUID) SignalServiceConfiguration(org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration) ByteString(com.google.protobuf.ByteString) DiscoveryResponse(org.whispersystems.signalservice.internal.contacts.entities.DiscoveryResponse) List(java.util.List) CurrencyConversions(org.whispersystems.signalservice.api.payments.CurrencyConversions) ProfileCipherOutputStreamFactory(org.whispersystems.signalservice.internal.push.http.ProfileCipherOutputStreamFactory) ProvisioningVersion(org.whispersystems.signalservice.internal.push.ProvisioningProtos.ProvisioningVersion) CdshService(org.whispersystems.signalservice.api.services.CdshService) AccountAttributes(org.whispersystems.signalservice.api.account.AccountAttributes) DataInputStream(java.io.DataInputStream) MessageDigest(java.security.MessageDigest) HashMap(java.util.HashMap) ClientZkOperations(org.whispersystems.signalservice.api.groupsv2.ClientZkOperations) UnauthenticatedResponseException(org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException) Log(org.whispersystems.libsignal.logging.Log) LinkedList(java.util.LinkedList) SignalStorageManifest(org.whispersystems.signalservice.api.storage.SignalStorageManifest) PNI(org.whispersystems.signalservice.api.push.PNI) SignedPreKeyEntity(org.whispersystems.signalservice.api.push.SignedPreKeyEntity) RemoteAttestation(org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestation) ServiceResponse(org.whispersystems.signalservice.internal.ServiceResponse) TimeUnit(java.util.concurrent.TimeUnit) StorageItem(org.whispersystems.signalservice.internal.storage.protos.StorageItem) Collections(java.util.Collections) ProfileCipherOutputStreamFactory(org.whispersystems.signalservice.internal.push.http.ProfileCipherOutputStreamFactory) SignalServiceProfileWrite(org.whispersystems.signalservice.api.profiles.SignalServiceProfileWrite) ProfileCipher(org.whispersystems.signalservice.api.crypto.ProfileCipher) ProfileAvatarData(org.whispersystems.signalservice.internal.push.ProfileAvatarData)

Aggregations

ACI (org.whispersystems.signalservice.api.push.ACI)32 Test (org.junit.Test)13 IOException (java.io.IOException)7 WorkerThread (androidx.annotation.WorkerThread)6 HashMap (java.util.HashMap)5 NonNull (androidx.annotation.NonNull)4 ByteString (com.google.protobuf.ByteString)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 DataInputStream (java.io.DataInputStream)4 Map (java.util.Map)4 PNI (org.whispersystems.signalservice.api.push.PNI)4 ServiceResponse (org.whispersystems.signalservice.internal.ServiceResponse)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 SignatureException (java.security.SignatureException)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 List (java.util.List)3 UUID (java.util.UUID)3 RecipientDatabase (org.thoughtcrime.securesms.database.RecipientDatabase)3 UnauthenticatedResponseException (org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException)3