Search in sources :

Example 1 with Group

use of org.signal.storageservice.protos.groups.Group in project Signal-Android by WhisperSystems.

the class GroupsV2Operations_decrypt_group_Test method decrypt_description_field_11.

@Test
public void decrypt_description_field_11() throws VerificationFailedException, InvalidGroupStateException {
    Group group = Group.newBuilder().setDescription(groupOperations.encryptDescription("Description!")).build();
    DecryptedGroup decryptedGroup = groupOperations.decryptGroup(group);
    assertEquals("Description!", decryptedGroup.getDescription());
}
Also used : Group(org.signal.storageservice.protos.groups.Group) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 2 with Group

use of org.signal.storageservice.protos.groups.Group in project Signal-Android by WhisperSystems.

the class GroupsV2Operations_decrypt_group_Test method avatar_field_passed_through_3.

@Test
public void avatar_field_passed_through_3() throws VerificationFailedException, InvalidGroupStateException {
    Group group = Group.newBuilder().setAvatar("AvatarCdnKey").build();
    DecryptedGroup decryptedGroup = groupOperations.decryptGroup(group);
    assertEquals("AvatarCdnKey", decryptedGroup.getAvatar());
}
Also used : Group(org.signal.storageservice.protos.groups.Group) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 3 with Group

use of org.signal.storageservice.protos.groups.Group in project Signal-Android by WhisperSystems.

the class GroupsV2Operations_decrypt_group_Test method pass_through_access_control_field_5.

@Test
public void pass_through_access_control_field_5() throws VerificationFailedException, InvalidGroupStateException {
    AccessControl accessControl = AccessControl.newBuilder().setMembers(AccessControl.AccessRequired.ADMINISTRATOR).setAttributes(AccessControl.AccessRequired.MEMBER).setAddFromInviteLink(AccessControl.AccessRequired.UNSATISFIABLE).build();
    Group group = Group.newBuilder().setAccessControl(accessControl).build();
    DecryptedGroup decryptedGroup = groupOperations.decryptGroup(group);
    assertEquals(accessControl, decryptedGroup.getAccessControl());
}
Also used : Group(org.signal.storageservice.protos.groups.Group) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) AccessControl(org.signal.storageservice.protos.groups.AccessControl) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 4 with Group

use of org.signal.storageservice.protos.groups.Group in project Signal-Android by WhisperSystems.

the class GroupsV2Api method putNewGroup.

public void putNewGroup(GroupsV2Operations.NewGroup newGroup, GroupsV2AuthorizationString authorization) throws IOException {
    Group group = newGroup.getNewGroupMessage();
    if (newGroup.getAvatar().isPresent()) {
        String cdnKey = uploadAvatar(newGroup.getAvatar().get(), newGroup.getGroupSecretParams(), authorization);
        group = Group.newBuilder(group).setAvatar(cdnKey).build();
    }
    socket.putNewGroupsV2Group(group, authorization);
}
Also used : Group(org.signal.storageservice.protos.groups.Group) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) ByteString(com.google.protobuf.ByteString)

Example 5 with Group

use of org.signal.storageservice.protos.groups.Group in project Signal-Android by WhisperSystems.

the class GroupsV2Operations method createNewGroup.

/**
 * Creates a new group with the title and avatar.
 *
 * @param self    You will be member 0 and the only admin.
 * @param members Members must not contain self. Members will be non-admin members of the group.
 */
public NewGroup createNewGroup(final GroupSecretParams groupSecretParams, final String title, final Optional<byte[]> avatar, final GroupCandidate self, final Set<GroupCandidate> members, final Member.Role memberRole, final int disappearingMessageTimerSeconds) {
    if (members.contains(self)) {
        throw new IllegalArgumentException("Members must not contain self");
    }
    final GroupOperations groupOperations = forGroup(groupSecretParams);
    Group.Builder group = Group.newBuilder().setRevision(0).setPublicKey(ByteString.copyFrom(groupSecretParams.getPublicParams().serialize())).setTitle(groupOperations.encryptTitle(title)).setDisappearingMessagesTimer(groupOperations.encryptTimer(disappearingMessageTimerSeconds)).setAccessControl(AccessControl.newBuilder().setAttributes(AccessControl.AccessRequired.MEMBER).setMembers(AccessControl.AccessRequired.MEMBER));
    group.addMembers(groupOperations.member(self.getProfileKeyCredential().get(), Member.Role.ADMINISTRATOR));
    for (GroupCandidate credential : members) {
        ProfileKeyCredential profileKeyCredential = credential.getProfileKeyCredential().orNull();
        if (profileKeyCredential != null) {
            group.addMembers(groupOperations.member(profileKeyCredential, memberRole));
        } else {
            group.addPendingMembers(groupOperations.invitee(credential.getUuid(), memberRole));
        }
    }
    return new NewGroup(groupSecretParams, group.build(), avatar);
}
Also used : Group(org.signal.storageservice.protos.groups.Group) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) ProfileKeyCredential(org.signal.zkgroup.profiles.ProfileKeyCredential)

Aggregations

Group (org.signal.storageservice.protos.groups.Group)13 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)13 Test (org.junit.Test)11 UUID (java.util.UUID)3 ByteString (com.google.protobuf.ByteString)2 ProfileKey (org.signal.zkgroup.profiles.ProfileKey)2 AccessControl (org.signal.storageservice.protos.groups.AccessControl)1 ProfileKeyCredential (org.signal.zkgroup.profiles.ProfileKeyCredential)1