Java Code Examples for org.whispersystems.signalservice.api.crypto.ProfileCipherOutputStream

The following examples show how to use org.whispersystems.signalservice.api.crypto.ProfileCipherOutputStream. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public Optional<String> setProfileAvatar(ProfileKey key, StreamDetails avatar)
    throws IOException
{
  if (FeatureFlags.DISALLOW_OLD_PROFILE_SETTING) {
    throw new AssertionError();
  }

  ProfileAvatarData profileAvatarData = null;

  if (avatar != null) {
    profileAvatarData = new ProfileAvatarData(avatar.getStream(),
                                              ProfileCipherOutputStream.getCiphertextLength(avatar.getLength()),
                                              avatar.getContentType(),
                                              new ProfileCipherOutputStreamFactory(key));
  }

  return this.pushServiceSocket.setProfileAvatar(profileAvatarData);
}
 
Example 2
/**
 * @return The avatar URL path, if one was written.
 */
public Optional<String> setVersionedProfile(UUID uuid, ProfileKey profileKey, String name, StreamDetails avatar)
    throws IOException
{
  if (name == null) name = "";

  byte[]            ciphertextName    = new ProfileCipher(profileKey).encryptName(name.getBytes(StandardCharsets.UTF_8), ProfileCipher.NAME_PADDED_LENGTH);
  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(uuid).serialize(),
                                                                           ciphertextName,
                                                                           hasAvatar,
                                                                           profileKey.getCommitment(uuid).serialize()),
                                                                           profileAvatarData);
}
 
Example 3
public void setProfileAvatar(byte[] key, StreamDetails avatar)
    throws IOException
{
  ProfileAvatarData profileAvatarData = null;

  if (avatar != null) {
    profileAvatarData = new ProfileAvatarData(avatar.getStream(),
                                              ProfileCipherOutputStream.getCiphertextLength(avatar.getLength()),
                                              avatar.getContentType(),
                                              new ProfileCipherOutputStreamFactory(key));
  }

  this.pushServiceSocket.setProfileAvatar(profileAvatarData);
}
 
Example 4
@Override
public DigestingOutputStream createFor(OutputStream wrap) throws IOException {
  return new ProfileCipherOutputStream(wrap, key);
}
 
Example 5
@Override
public DigestingOutputStream createFor(OutputStream wrap) throws IOException {
  return new ProfileCipherOutputStream(wrap, key);
}
 
Example 6
@Override
public DigestingOutputStream createFor(OutputStream wrap) throws IOException {
  return new ProfileCipherOutputStream(wrap, key);
}