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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations