diff --git a/briar-api/src/net/sf/briar/api/protocol/UnverifiedMessage.java b/briar-api/src/net/sf/briar/api/protocol/UnverifiedMessage.java index 89e30e743835baa0e82c8849c4648e156a47b571..8d46431f86db03a6473343038e9cd749951f6982 100644 --- a/briar-api/src/net/sf/briar/api/protocol/UnverifiedMessage.java +++ b/briar-api/src/net/sf/briar/api/protocol/UnverifiedMessage.java @@ -1,61 +1,111 @@ package net.sf.briar.api.protocol; /** A {@link Message} that has not yet had its signatures verified. */ -public interface UnverifiedMessage { +public class UnverifiedMessage { + + private final MessageId parent; + private final Group group; + private final Author author; + private final String subject; + private final long timestamp; + private final byte[] raw, authorSig, groupSig; + private final int bodyStart, bodyLength, signedByAuthor, signedByGroup; + + public UnverifiedMessage(MessageId parent, Group group, Author author, + String subject, long timestamp, byte[] raw, byte[] authorSig, + byte[] groupSig, int bodyStart, int bodyLength, int signedByAuthor, + int signedByGroup) { + this.parent = parent; + this.group = group; + this.author = author; + this.subject = subject; + this.timestamp = timestamp; + this.raw = raw; + this.authorSig = authorSig; + this.groupSig = groupSig; + this.bodyStart = bodyStart; + this.bodyLength = bodyLength; + this.signedByAuthor = signedByAuthor; + this.signedByGroup = signedByGroup; + } /** * Returns the identifier of the message's parent, or null if this is the * first message in a thread. */ - MessageId getParent(); + public MessageId getParent() { + return parent; + } /** * Returns the {@link Group} to which the message belongs, or null if this * is a private message. */ - Group getGroup(); + public Group getGroup() { + return group; + } /** * Returns the message's {@link Author}, or null if this is an anonymous * message. */ - Author getAuthor(); + public Author getAuthor() { + return author; + } /** Returns the message's subject line. */ - String getSubject(); + public String getSubject() { + return subject; + } /** Returns the timestamp created by the message's {@link Author}. */ - long getTimestamp(); + public long getTimestamp() { + return timestamp; + } /** Returns the serialised message. */ - byte[] getSerialised(); + public byte[] getSerialised() { + return raw; + } /** * Returns the author's signature, or null if this is an anonymous message. */ - byte[] getAuthorSignature(); + 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. */ - byte[] getGroupSignature(); + public byte[] getGroupSignature() { + return groupSig; + } /** Returns the offset of the message body within the serialised message. */ - int getBodyStart(); + public int getBodyStart() { + return bodyStart; + } /** Returns the length of the message body in bytes. */ - int getBodyLength(); + public int getBodyLength() { + return bodyLength; + } /** * Returns the length in bytes of the data covered by the author's * signature. */ - int getLengthSignedByAuthor(); + public int getLengthSignedByAuthor() { + return signedByAuthor; + } /** * Returns the length in bytes of the data covered by the group's * signature. */ - int getLengthSignedByGroup(); + public int getLengthSignedByGroup() { + return signedByGroup; + } } \ No newline at end of file diff --git a/briar-core/src/net/sf/briar/protocol/MessageReader.java b/briar-core/src/net/sf/briar/protocol/MessageReader.java index eb000103e8a7528b9fbfe3613d19d033199c7adb..8c6eb2d4061abb85b7fc5a38e79a97b6de4f68d3 100644 --- a/briar-core/src/net/sf/briar/protocol/MessageReader.java +++ b/briar-core/src/net/sf/briar/protocol/MessageReader.java @@ -83,8 +83,8 @@ class MessageReader implements StructReader<UnverifiedMessage> { r.removeConsumer(counting); r.removeConsumer(copying); byte[] raw = copying.getCopy(); - return new UnverifiedMessageImpl(parent, group, author, subject, - timestamp, raw, authorSig, groupSig, bodyStart, body.length, + return new UnverifiedMessage(parent, group, author, subject, timestamp, + raw, authorSig, groupSig, bodyStart, body.length, signedByAuthor, signedByGroup); } } diff --git a/briar-core/src/net/sf/briar/protocol/UnverifiedMessageImpl.java b/briar-core/src/net/sf/briar/protocol/UnverifiedMessageImpl.java deleted file mode 100644 index 57cdb0fc69dbc46775c2c43e8626b990fc5719bf..0000000000000000000000000000000000000000 --- a/briar-core/src/net/sf/briar/protocol/UnverifiedMessageImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package net.sf.briar.protocol; - -import net.sf.briar.api.protocol.Author; -import net.sf.briar.api.protocol.Group; -import net.sf.briar.api.protocol.MessageId; -import net.sf.briar.api.protocol.UnverifiedMessage; - -class UnverifiedMessageImpl implements UnverifiedMessage { - - private final MessageId parent; - private final Group group; - private final Author author; - private final String subject; - private final long timestamp; - private final byte[] raw, authorSig, groupSig; - private final int bodyStart, bodyLength, signedByAuthor, signedByGroup; - - UnverifiedMessageImpl(MessageId parent, Group group, Author author, - String subject, long timestamp, byte[] raw, byte[] authorSig, - byte[] groupSig, int bodyStart, int bodyLength, int signedByAuthor, - int signedByGroup) { - this.parent = parent; - this.group = group; - this.author = author; - this.subject = subject; - this.timestamp = timestamp; - this.raw = raw; - this.authorSig = authorSig; - this.groupSig = groupSig; - this.bodyStart = bodyStart; - this.bodyLength = bodyLength; - this.signedByAuthor = signedByAuthor; - this.signedByGroup = signedByGroup; - } - - public MessageId getParent() { - return parent; - } - - public Group getGroup() { - return group; - } - - public Author getAuthor() { - return author; - } - - public String getSubject() { - return subject; - } - - public long getTimestamp() { - return timestamp; - } - - public byte[] getSerialised() { - return raw; - } - - public byte[] getAuthorSignature() { - return authorSig; - } - - public byte[] getGroupSignature() { - return groupSig; - } - - public int getBodyStart() { - return bodyStart; - } - - public int getBodyLength() { - return bodyLength; - } - - public int getLengthSignedByAuthor() { - return signedByAuthor; - } - - public int getLengthSignedByGroup() { - return signedByGroup; - } -}