mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Private group invitation protocol.
This commit is contained in:
@@ -14,38 +14,63 @@ import java.util.Collection;
|
||||
@NotNullByDefault
|
||||
public interface PrivateGroupManager extends MessageTracker {
|
||||
|
||||
/** The unique ID of the private group client. */
|
||||
/**
|
||||
* The unique ID of the private group client.
|
||||
*/
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.privategroup");
|
||||
|
||||
/**
|
||||
* Adds a new private group and joins it.
|
||||
*
|
||||
* @param group The private group to add
|
||||
* @param joinMsg The creator's own join message
|
||||
* @param joinMsg The new member's join message
|
||||
*/
|
||||
void addPrivateGroup(PrivateGroup group, GroupMessage joinMsg)
|
||||
throws DbException;
|
||||
|
||||
/** Removes a dissolved private group. */
|
||||
/**
|
||||
* Adds a new private group and joins it.
|
||||
*
|
||||
* @param group The private group to add
|
||||
* @param joinMsg The new member's join message
|
||||
*/
|
||||
void addPrivateGroup(Transaction txn, PrivateGroup group,
|
||||
GroupMessage joinMsg) throws DbException;
|
||||
|
||||
/**
|
||||
* Removes a dissolved private group.
|
||||
*/
|
||||
void removePrivateGroup(GroupId g) throws DbException;
|
||||
|
||||
/** Gets the MessageId of your previous message sent to the group */
|
||||
/**
|
||||
* Gets the MessageId of your previous message sent to the group
|
||||
*/
|
||||
MessageId getPreviousMsgId(GroupId g) throws DbException;
|
||||
|
||||
/** Returns the timestamp of the message with the given ID */
|
||||
/**
|
||||
* Returns the timestamp of the message with the given ID
|
||||
*/
|
||||
// TODO change to getPreviousMessageHeader()
|
||||
long getMessageTimestamp(MessageId id) throws DbException;
|
||||
|
||||
/** Marks the group with GroupId g as resolved */
|
||||
/**
|
||||
* Marks the group with GroupId g as resolved
|
||||
*/
|
||||
void markGroupDissolved(Transaction txn, GroupId g) throws DbException;
|
||||
|
||||
/** Returns true if the private group has been dissolved. */
|
||||
/**
|
||||
* Returns true if the private group has been dissolved.
|
||||
*/
|
||||
boolean isDissolved(GroupId g) throws DbException;
|
||||
|
||||
/** Stores (and sends) a local group message. */
|
||||
/**
|
||||
* Stores (and sends) a local group message.
|
||||
*/
|
||||
GroupMessageHeader addLocalMessage(GroupMessage p) throws DbException;
|
||||
|
||||
/** Returns the private group with the given ID. */
|
||||
/**
|
||||
* Returns the private group with the given ID.
|
||||
*/
|
||||
PrivateGroup getPrivateGroup(GroupId g) throws DbException;
|
||||
|
||||
/**
|
||||
@@ -53,25 +78,35 @@ public interface PrivateGroupManager extends MessageTracker {
|
||||
*/
|
||||
PrivateGroup getPrivateGroup(Transaction txn, GroupId g) throws DbException;
|
||||
|
||||
/** Returns all private groups the user is a member of. */
|
||||
/**
|
||||
* Returns all private groups the user is a member of.
|
||||
*/
|
||||
Collection<PrivateGroup> getPrivateGroups() throws DbException;
|
||||
|
||||
/** Returns the body of the group message with the given ID. */
|
||||
/**
|
||||
* Returns the body of the group message with the given ID.
|
||||
*/
|
||||
String getMessageBody(MessageId m) throws DbException;
|
||||
|
||||
/** Returns the headers of all group messages in the given group. */
|
||||
/**
|
||||
* Returns the headers of all group messages in the given group.
|
||||
*/
|
||||
Collection<GroupMessageHeader> getHeaders(GroupId g) throws DbException;
|
||||
|
||||
/** Returns all members of the group with ID g */
|
||||
/**
|
||||
* Returns all members of the group with ID g
|
||||
*/
|
||||
Collection<GroupMember> getMembers(GroupId g) throws DbException;
|
||||
|
||||
/** Returns true if the given Author a is member of the group with ID g */
|
||||
/**
|
||||
* Returns true if the given Author a is member of the group with ID g
|
||||
*/
|
||||
boolean isMember(Transaction txn, GroupId g, Author a) throws DbException;
|
||||
|
||||
/**
|
||||
* Registers a hook to be called when members are added
|
||||
* or groups are removed.
|
||||
* */
|
||||
*/
|
||||
void registerPrivateGroupHook(PrivateGroupHook hook);
|
||||
|
||||
@NotNullByDefault
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package org.briarproject.api.privategroup.invitation;
|
||||
|
||||
public interface GroupInvitationConstants {
|
||||
|
||||
// Group Metadata Keys
|
||||
String CONTACT_ID = "contactId";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.briarproject.api.privategroup.invitation;
|
||||
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.crypto.CryptoExecutor;
|
||||
import org.briarproject.api.data.BdfList;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
public interface GroupInvitationFactory {
|
||||
|
||||
/**
|
||||
* Returns a signature to include when inviting a member to join a private
|
||||
* group. If the member accepts the invitation, the signature will be
|
||||
* included in the member's join message.
|
||||
*/
|
||||
@CryptoExecutor
|
||||
byte[] signInvitation(Contact c, GroupId privateGroupId, long timestamp,
|
||||
byte[] privateKey);
|
||||
|
||||
/**
|
||||
* Returns a token to be signed by the creator when inviting a member to
|
||||
* join a private group. If the member accepts the invitation, the
|
||||
* signature will be included in the member's join message.
|
||||
*/
|
||||
BdfList createInviteToken(AuthorId creatorId, AuthorId memberId,
|
||||
GroupId privateGroupId, long timestamp);
|
||||
}
|
||||
@@ -13,10 +13,8 @@ public class GroupInvitationItem extends InvitationItem<PrivateGroup> {
|
||||
|
||||
private final Contact creator;
|
||||
|
||||
public GroupInvitationItem(PrivateGroup shareable, boolean subscribed,
|
||||
Contact creator) {
|
||||
super(shareable, subscribed);
|
||||
|
||||
public GroupInvitationItem(PrivateGroup privateGroup, Contact creator) {
|
||||
super(privateGroup, false);
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.briarproject.api.privategroup.invitation;
|
||||
|
||||
import org.briarproject.api.clients.MessageTracker;
|
||||
import org.briarproject.api.clients.SessionId;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.privategroup.PrivateGroup;
|
||||
import org.briarproject.api.sharing.InvitationMessage;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
@@ -12,38 +12,51 @@ import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface GroupInvitationManager extends MessageTracker {
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** The unique ID of the private group invitation client. */
|
||||
@NotNullByDefault
|
||||
public interface GroupInvitationManager {
|
||||
|
||||
/**
|
||||
* The unique ID of the private group invitation client.
|
||||
*/
|
||||
ClientId CLIENT_ID =
|
||||
new ClientId("org.briarproject.briar.privategroup.invitation");
|
||||
|
||||
/**
|
||||
* Sends an invitation to share the given forum with the given contact
|
||||
* and sends an optional message along with it.
|
||||
* Sends an invitation to share the given private group with the given
|
||||
* contact, including an optional message.
|
||||
*/
|
||||
void sendInvitation(GroupId groupId, ContactId contactId,
|
||||
String message) throws DbException;
|
||||
void sendInvitation(GroupId g, ContactId c, @Nullable String message,
|
||||
long timestamp, byte[] signature) throws DbException;
|
||||
|
||||
/**
|
||||
* Responds to a pending private group invitation
|
||||
* Responds to a pending private group invitation from the given contact.
|
||||
*/
|
||||
void respondToInvitation(PrivateGroup g, Contact c, boolean accept)
|
||||
void respondToInvitation(ContactId c, PrivateGroup g, boolean accept)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Responds to a pending private group invitation
|
||||
* Responds to a pending private group invitation from the given contact.
|
||||
*/
|
||||
void respondToInvitation(SessionId id, boolean accept) throws DbException;
|
||||
void respondToInvitation(ContactId c, SessionId s, boolean accept)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all private group invitation messages related to the contact
|
||||
* identified by contactId.
|
||||
* Returns all private group invitation messages related to the given
|
||||
* contact.
|
||||
*/
|
||||
Collection<InvitationMessage> getInvitationMessages(
|
||||
ContactId contactId) throws DbException;
|
||||
Collection<InvitationMessage> getInvitationMessages(ContactId c)
|
||||
throws DbException;
|
||||
|
||||
/** Returns all private groups to which the user has been invited. */
|
||||
/**
|
||||
* Returns all private groups to which the user has been invited.
|
||||
*/
|
||||
Collection<GroupInvitationItem> getInvitations() throws DbException;
|
||||
|
||||
/**
|
||||
* Returns true if the given contact can be invited to the given private
|
||||
* group.
|
||||
*/
|
||||
boolean isInvitationAllowed(Contact c, GroupId g) throws DbException;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.briarproject.api.sharing.InvitationRequest;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
@@ -19,8 +19,8 @@ public class GroupInvitationRequest extends InvitationRequest {
|
||||
private final Author creator;
|
||||
|
||||
public GroupInvitationRequest(MessageId id, SessionId sessionId,
|
||||
GroupId groupId, Author creator, ContactId contactId,
|
||||
String groupName, String message, boolean available, long time,
|
||||
GroupId groupId, ContactId contactId, @Nullable String message,
|
||||
String groupName, Author creator, boolean available, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read) {
|
||||
super(id, sessionId, groupId, contactId, message, available, time,
|
||||
local, sent, seen, read);
|
||||
|
||||
@@ -2,39 +2,21 @@ package org.briarproject.api.privategroup.invitation;
|
||||
|
||||
import org.briarproject.api.clients.SessionId;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.sharing.InvitationResponse;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class GroupInvitationResponse extends InvitationResponse {
|
||||
|
||||
private final String groupName;
|
||||
private final Author creator;
|
||||
|
||||
public GroupInvitationResponse(MessageId id, SessionId sessionId,
|
||||
GroupId groupId, String groupName, Author creator,
|
||||
ContactId contactId, boolean accept, long time, boolean local,
|
||||
boolean sent, boolean seen, boolean read) {
|
||||
GroupId groupId, ContactId contactId, boolean accept, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read) {
|
||||
super(id, sessionId, groupId, contactId, accept, time, local, sent,
|
||||
seen, read);
|
||||
this.groupName = groupName;
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public Author getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user