Truncate all messages to valid length before sending.

This commit is contained in:
akwizgran
2016-10-19 14:23:24 +01:00
parent 9d2c56e75f
commit 06335c2c30
23 changed files with 279 additions and 163 deletions

View File

@@ -13,6 +13,9 @@ public interface BlogConstants {
/** The maximum length of a blog post's body in bytes. */
int MAX_BLOG_POST_BODY_LENGTH = MAX_MESSAGE_BODY_LENGTH - 1024;
/** The maximum length of a blog comment in bytes. */
int MAX_BLOG_COMMENT_LENGTH = MAX_BLOG_POST_BODY_LENGTH;
/** The internal name of personal blogs that are created automatically */
String PERSONAL_BLOG_NAME = "briar.PERSONAL_BLOG_NAME";

View File

@@ -1,61 +1,7 @@
package org.briarproject.api.blogs;
import org.briarproject.api.contact.Contact;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.db.DbException;
import org.briarproject.api.sharing.InvitationItem;
import org.briarproject.api.sharing.InvitationMessage;
import org.briarproject.api.sharing.SharingManager;
import org.briarproject.api.sync.ClientId;
import org.briarproject.api.sync.GroupId;
import java.util.Collection;
public interface BlogSharingManager extends SharingManager<Blog> {
/**
* Returns the unique ID of the blog sharing client.
*/
ClientId getClientId();
/**
* Sends an invitation to share the given blog with the given contact
* and sends an optional message along with it.
*/
void sendInvitation(GroupId groupId, ContactId contactId,
String message) throws DbException;
/**
* Responds to a pending blog invitation
*/
void respondToInvitation(Blog b, Contact c, boolean accept)
throws DbException;
/**
* Returns all blogs sharing messages sent by the Contact
* identified by contactId.
*/
Collection<InvitationMessage> getInvitationMessages(
ContactId contactId) throws DbException;
/**
* Returns all blogs to which the user has been invited.
*/
Collection<InvitationItem> getInvitations() throws DbException;
/**
* Returns all contacts who are sharing the given blog with us.
*/
Collection<Contact> getSharedBy(GroupId g) throws DbException;
/**
* Returns the IDs of all contacts with whom the given blog is shared.
*/
Collection<Contact> getSharedWith(GroupId g) throws DbException;
/**
* Returns true if the blog not already shared and no invitation is open
*/
boolean canBeShared(GroupId g, Contact c) throws DbException;
}

View File

@@ -1,51 +1,7 @@
package org.briarproject.api.forum;
import org.briarproject.api.contact.Contact;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.db.DbException;
import org.briarproject.api.sharing.InvitationItem;
import org.briarproject.api.sharing.InvitationMessage;
import org.briarproject.api.sharing.SharingManager;
import org.briarproject.api.sync.ClientId;
import org.briarproject.api.sync.GroupId;
import java.util.Collection;
public interface ForumSharingManager extends SharingManager<Forum> {
/** Returns the unique ID of the forum sharing client. */
ClientId getClientId();
/**
* Sends an invitation to share the given forum with the given contact
* and sends an optional message along with it.
*/
void sendInvitation(GroupId groupId, ContactId contactId,
String message) throws DbException;
/**
* Responds to a pending forum invitation
*/
void respondToInvitation(Forum f, Contact c, boolean accept)
throws DbException;
/**
* Returns all forum sharing messages sent by the Contact
* identified by contactId.
*/
Collection<InvitationMessage> getInvitationMessages(
ContactId contactId) throws DbException;
/** Returns all forums to which the user has been invited. */
Collection<InvitationItem> getInvitations() throws DbException;
/** Returns all contacts who are sharing the given forum with us. */
Collection<Contact> getSharedBy(GroupId g) throws DbException;
/** Returns the IDs of all contacts with whom the given forum is shared. */
Collection<Contact> getSharedWith(GroupId g) throws DbException;
/** Returns true if the forum not already shared and no invitation is open */
boolean canBeShared(GroupId g, Contact c) throws DbException;
}

View File

@@ -1,5 +1,7 @@
package org.briarproject.api.introduction;
import static org.briarproject.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
public interface IntroductionConstants {
/* Protocol roles */
@@ -30,8 +32,18 @@ public interface IntroductionConstants {
String SIGNATURE = "signature";
/* Validation Constants */
/**
* The length of the message authentication code in bytes.
*/
int MAC_LENGTH = 32;
/**
* The maximum length of the introducer's optional message to the
* introducees in UTF-8 bytes.
*/
int MAX_INTRODUCTION_MESSAGE_LENGTH = MAX_MESSAGE_BODY_LENGTH - 1024;
/* Introducer Local State Metadata */
String STATE = "state";
String ROLE = "role";

View File

@@ -1,10 +1,20 @@
package org.briarproject.api.sharing;
import static org.briarproject.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
public interface SharingConstants {
/** The length of a sharing session's random salt in bytes. */
/**
* The length of a sharing session's random salt in bytes.
*/
int SHARING_SALT_LENGTH = 32;
/**
* The maximum length of the optional message from the inviter to the
* invitee in UTF-8 bytes.
*/
int MAX_INVITATION_MESSAGE_LENGTH = MAX_MESSAGE_BODY_LENGTH - 1204;
String CONTACT_ID = "contactId";
String GROUP_ID = "groupId";
String TO_BE_SHARED_BY_US = "toBeSharedByUs";

View File

@@ -11,15 +11,17 @@ import java.util.Collection;
public interface SharingManager<S extends Shareable> extends MessageTracker {
/** Returns the unique ID of the group sharing client. */
/**
* Returns the unique ID of the group sharing client.
*/
ClientId getClientId();
/**
* Sends an invitation to share the given shareable with the given contact
* Sends an invitation to share the given group with the given contact
* and sends an optional message along with it.
*/
void sendInvitation(GroupId groupId, ContactId contactId,
String message) throws DbException;
String message) throws DbException;
/**
* Responds to a pending group invitation
@@ -28,22 +30,29 @@ public interface SharingManager<S extends Shareable> extends MessageTracker {
throws DbException;
/**
* Returns all group sharing messages sent by the Contact
* identified by contactId.
* Returns all group sharing messages sent by the given contact.
*/
Collection<InvitationMessage> getInvitationMessages(
ContactId contactId) throws DbException;
/** Returns all invitations to shareables. */
/**
* Returns all invitations to groups.
*/
Collection<InvitationItem> getInvitations() throws DbException;
/** Returns all contacts who are sharing the given group with us. */
/**
* Returns all contacts who are sharing the given group with us.
*/
Collection<Contact> getSharedBy(GroupId g) throws DbException;
/** Returns the IDs of all contacts with whom the given group is shared. */
/**
* Returns all contacts with whom the given group is shared.
*/
Collection<Contact> getSharedWith(GroupId g) throws DbException;
/** Returns true if the group not already shared and no invitation is open */
/**
* Returns true if the group not already shared and no invitation is open
*/
boolean canBeShared(GroupId g, Contact c) throws DbException;
}