Implement New Member and Join Announcements in GroupMessageFactory

This commit is contained in:
Torsten Grote
2016-10-19 18:28:35 -02:00
parent a6e3827127
commit e06726b2f9
4 changed files with 127 additions and 26 deletions

View File

@@ -3,7 +3,6 @@ package org.briarproject.api.clients;
import org.briarproject.api.nullsafety.NotNullByDefault;
import org.briarproject.api.sync.Message;
import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.concurrent.Immutable;

View File

@@ -5,7 +5,6 @@ import org.briarproject.api.identity.Author;
import org.briarproject.api.nullsafety.NotNullByDefault;
import org.briarproject.api.sync.Message;
import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.concurrent.Immutable;
@@ -14,16 +13,16 @@ import javax.annotation.concurrent.Immutable;
@NotNullByDefault
public class GroupMessage extends BaseMessage {
private final Author author;
private final Author member;
public GroupMessage(Message message, @Nullable MessageId parent,
Author author) {
Author member) {
super(message, parent);
this.author = author;
this.member = member;
}
public Author getAuthor() {
return author;
public Author getMember() {
return member;
}
}

View File

@@ -1,20 +1,58 @@
package org.briarproject.api.privategroup;
import org.briarproject.api.FormatException;
import org.briarproject.api.crypto.PrivateKey;
import org.briarproject.api.crypto.CryptoExecutor;
import org.briarproject.api.identity.Author;
import org.briarproject.api.identity.LocalAuthor;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.NotNull;
import java.security.GeneralSecurityException;
import org.jetbrains.annotations.Nullable;
public interface GroupMessageFactory {
@NotNull
/**
* Creates a new member announcement that contains the joiner's identity
* and is signed by the creator.
* <p>
* When a new member accepts an invitation to the group,
* the creator sends this new member announcement to the group.
*
* @param groupId The ID of the group the new member joined
* @param timestamp The current timestamp
* @param creator The creator of the group with {@param groupId}
* @param member The new member that has just accepted an invitation
*/
@CryptoExecutor
GroupMessage createNewMemberMessage(GroupId groupId, long timestamp,
LocalAuthor creator, Author member);
/**
* Creates a join announcement message
* that depends on a previous new member announcement.
*
* @param groupId The ID of the Group that is being joined
* @param timestamp Must be equal to the timestamp of the new member message
* @param member Our own LocalAuthor
* @param newMemberId The MessageId of the new member message
*/
@CryptoExecutor
GroupMessage createJoinMessage(GroupId groupId, long timestamp,
LocalAuthor member, MessageId newMemberId);
/**
* Creates a group message
*
* @param groupId The ID of the Group that is posted in
* @param timestamp Must be greater than the timestamps of the parentId
* post, if any, and the member's previous message
* @param parentId The ID of the message that is replied to
* @param author The author of the group message
* @param body The content of the group message
* @param previousMsgId The ID of the author's previous message
* in this group
*/
@CryptoExecutor
GroupMessage createGroupMessage(GroupId groupId, long timestamp,
MessageId parent, LocalAuthor author, String body)
throws FormatException, GeneralSecurityException;
@Nullable MessageId parentId, LocalAuthor author, String body,
MessageId previousMsgId);
}