mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Removed restricted groups (may be restored after beta testing).
This commit is contained in:
@@ -17,7 +17,6 @@ import net.sf.briar.api.messaging.Ack;
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import net.sf.briar.api.messaging.GroupStatus;
|
||||
import net.sf.briar.api.messaging.LocalGroup;
|
||||
import net.sf.briar.api.messaging.Message;
|
||||
import net.sf.briar.api.messaging.MessageId;
|
||||
import net.sf.briar.api.messaging.Offer;
|
||||
@@ -62,12 +61,6 @@ public interface DatabaseComponent {
|
||||
/** Stores a pseudonym that the user can use to sign messages. */
|
||||
void addLocalAuthor(LocalAuthor a) throws DbException;
|
||||
|
||||
/**
|
||||
* Stores a restricted group to which the user can post messages. Storing
|
||||
* a group does not create a subscription to it.
|
||||
*/
|
||||
void addLocalGroup(LocalGroup g) throws DbException;
|
||||
|
||||
/** Stores a locally generated group message. */
|
||||
void addLocalGroupMessage(Message m) throws DbException;
|
||||
|
||||
@@ -194,9 +187,6 @@ public interface DatabaseComponent {
|
||||
/** Returns all pseudonyms that the user can use to sign messages. */
|
||||
Collection<LocalAuthor> getLocalAuthors() throws DbException;
|
||||
|
||||
/** Returns all restricted groups to which the user can post messages. */
|
||||
Collection<LocalGroup> getLocalGroups() throws DbException;
|
||||
|
||||
/** Returns the local transport properties for all transports. */
|
||||
Map<TransportId, TransportProperties> getLocalProperties()
|
||||
throws DbException;
|
||||
|
||||
@@ -5,12 +5,12 @@ public class Group {
|
||||
|
||||
private final GroupId id;
|
||||
private final String name;
|
||||
private final byte[] publicKey;
|
||||
private final byte[] salt;
|
||||
|
||||
public Group(GroupId id, String name, byte[] publicKey) {
|
||||
public Group(GroupId id, String name, byte[] salt) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.publicKey = publicKey;
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
/** Returns the group's unique identifier. */
|
||||
@@ -23,18 +23,12 @@ public class Group {
|
||||
return name;
|
||||
}
|
||||
|
||||
/** Returns true if the group is restricted. */
|
||||
public boolean isRestricted() {
|
||||
return publicKey != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the group is restricted, returns the public key used to verify the
|
||||
* signatures on all messages sent to the group. If the group is
|
||||
* unrestricted, returns null.
|
||||
* Returns the salt used to distinguish the group from other groups with
|
||||
* the same name.
|
||||
*/
|
||||
public byte[] getPublicKey() {
|
||||
return publicKey;
|
||||
public byte[] getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,13 +4,9 @@ import java.io.IOException;
|
||||
|
||||
public interface GroupFactory {
|
||||
|
||||
/** Creates an unrestricted group. */
|
||||
/** Creates a group with the given name and a random salt. */
|
||||
Group createGroup(String name) throws IOException;
|
||||
|
||||
/** Creates a restricted group. */
|
||||
Group createGroup(String name, byte[] publicKey) throws IOException;
|
||||
|
||||
/** Creates a restricted group to which the local user can post messages. */
|
||||
LocalGroup createLocalGroup(String name, byte[] publicKey,
|
||||
byte[] privateKey) throws IOException;
|
||||
/** Creates a group with the given name and salt. */
|
||||
Group createGroup(String name, byte[] salt) throws IOException;
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package net.sf.briar.api.messaging;
|
||||
|
||||
/** A restricted group to which the local user can post messages. */
|
||||
public class LocalGroup extends Group {
|
||||
|
||||
private final byte[] privateKey;
|
||||
|
||||
public LocalGroup(GroupId id, String name, byte[] publicKey,
|
||||
byte[] privateKey) {
|
||||
super(id, name, publicKey);
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
/** Returns the private key used to sign all messages sent to the group. */
|
||||
public byte[] getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
}
|
||||
@@ -12,24 +12,13 @@ public interface MessageFactory {
|
||||
Message createPrivateMessage(MessageId parent, String contentType,
|
||||
byte[] body) throws IOException, GeneralSecurityException;
|
||||
|
||||
/** Creates an anonymous message to an unrestricted group. */
|
||||
/** Creates an anonymous group message. */
|
||||
Message createAnonymousMessage(MessageId parent, Group group,
|
||||
String contentType, byte[] body) throws IOException,
|
||||
GeneralSecurityException;
|
||||
|
||||
/** Creates an anonymous message to a restricted group. */
|
||||
Message createAnonymousMessage(MessageId parent, Group group,
|
||||
PrivateKey groupKey, String contentType, byte[] body)
|
||||
throws IOException, GeneralSecurityException;
|
||||
|
||||
/** Creates a pseudonymous message to an unrestricted group. */
|
||||
/** Creates a pseudonymous group message. */
|
||||
Message createPseudonymousMessage(MessageId parent, Group group,
|
||||
Author author, PrivateKey authorKey, String contentType,
|
||||
Author author, PrivateKey privateKey, String contentType,
|
||||
byte[] body) throws IOException, GeneralSecurityException;
|
||||
|
||||
/** Creates a pseudonymous message to a restricted group. */
|
||||
Message createPseudonymousMessage(MessageId parent, Group group,
|
||||
PrivateKey groupKey, Author author, PrivateKey authorKey,
|
||||
String contentType, byte[] body) throws IOException,
|
||||
GeneralSecurityException;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ public interface MessagingConstants {
|
||||
/** The maximum length of a group's name in UTF-8 bytes. */
|
||||
int MAX_GROUP_NAME_LENGTH = 50;
|
||||
|
||||
/** The length of a group's random salt in bytes. */
|
||||
int GROUP_SALT_LENGTH = 32;
|
||||
|
||||
/**
|
||||
* The maximum length of a message body in bytes. To allow for future
|
||||
* changes in the protocol, this is smaller than the maximum packet length
|
||||
@@ -31,7 +34,7 @@ public interface MessagingConstants {
|
||||
int MAX_SUBJECT_LENGTH = 100;
|
||||
|
||||
/** The length of a message's random salt in bytes. */
|
||||
int SALT_LENGTH = 8;
|
||||
int MESSAGE_SALT_LENGTH = 32;
|
||||
|
||||
/**
|
||||
* The timestamp of the oldest message in the database is rounded using
|
||||
|
||||
@@ -10,13 +10,12 @@ public class UnverifiedMessage {
|
||||
private final Author author;
|
||||
private final String contentType, subject;
|
||||
private final long timestamp;
|
||||
private final byte[] raw, authorSig, groupSig;
|
||||
private final int bodyStart, bodyLength, signedByAuthor, signedByGroup;
|
||||
private final byte[] raw, signature;
|
||||
private final int bodyStart, bodyLength, signedLength;
|
||||
|
||||
public UnverifiedMessage(MessageId parent, Group group, Author author,
|
||||
String contentType, String subject, long timestamp, byte[] raw,
|
||||
byte[] authorSig, byte[] groupSig, int bodyStart, int bodyLength,
|
||||
int signedByAuthor, int signedByGroup) {
|
||||
byte[] signature, int bodyStart, int bodyLength, int signedLength) {
|
||||
this.parent = parent;
|
||||
this.group = group;
|
||||
this.author = author;
|
||||
@@ -24,12 +23,10 @@ public class UnverifiedMessage {
|
||||
this.subject = subject;
|
||||
this.timestamp = timestamp;
|
||||
this.raw = raw;
|
||||
this.authorSig = authorSig;
|
||||
this.groupSig = groupSig;
|
||||
this.signature = signature;
|
||||
this.bodyStart = bodyStart;
|
||||
this.bodyLength = bodyLength;
|
||||
this.signedByAuthor = signedByAuthor;
|
||||
this.signedByGroup = signedByGroup;
|
||||
this.signedLength = signedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,16 +80,8 @@ public class UnverifiedMessage {
|
||||
/**
|
||||
* Returns the author's signature, or null if this is an anonymous message.
|
||||
*/
|
||||
public byte[] getAuthorSignature() {
|
||||
return authorSig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the group's signature, or null if this is a private message or
|
||||
* a message belonging to an unrestricted group.
|
||||
*/
|
||||
public byte[] getGroupSignature() {
|
||||
return groupSig;
|
||||
public byte[] getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
/** Returns the offset of the message body within the serialised message. */
|
||||
@@ -109,15 +98,7 @@ public class UnverifiedMessage {
|
||||
* Returns the length in bytes of the data covered by the author's
|
||||
* signature.
|
||||
*/
|
||||
public int getLengthSignedByAuthor() {
|
||||
return signedByAuthor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length in bytes of the data covered by the group's
|
||||
* signature.
|
||||
*/
|
||||
public int getLengthSignedByGroup() {
|
||||
return signedByGroup;
|
||||
public int getSignedLength() {
|
||||
return signedLength;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user