mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +01:00
Converted UnverifiedMessage from an interface to a value class.
This commit is contained in:
@@ -1,61 +1,111 @@
|
|||||||
package net.sf.briar.api.protocol;
|
package net.sf.briar.api.protocol;
|
||||||
|
|
||||||
/** A {@link Message} that has not yet had its signatures verified. */
|
/** 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
|
* Returns the identifier of the message's parent, or null if this is the
|
||||||
* first message in a thread.
|
* 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
|
* Returns the {@link Group} to which the message belongs, or null if this
|
||||||
* is a private message.
|
* is a private message.
|
||||||
*/
|
*/
|
||||||
Group getGroup();
|
public Group getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the message's {@link Author}, or null if this is an anonymous
|
* Returns the message's {@link Author}, or null if this is an anonymous
|
||||||
* message.
|
* message.
|
||||||
*/
|
*/
|
||||||
Author getAuthor();
|
public Author getAuthor() {
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the message's subject line. */
|
/** Returns the message's subject line. */
|
||||||
String getSubject();
|
public String getSubject() {
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the timestamp created by the message's {@link Author}. */
|
/** Returns the timestamp created by the message's {@link Author}. */
|
||||||
long getTimestamp();
|
public long getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the serialised message. */
|
/** Returns the serialised message. */
|
||||||
byte[] getSerialised();
|
public byte[] getSerialised() {
|
||||||
|
return raw;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the author's signature, or null if this is an anonymous message.
|
* 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
|
* Returns the group's signature, or null if this is a private message or
|
||||||
* a message belonging to an unrestricted group.
|
* 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. */
|
/** 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. */
|
/** 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
|
* Returns the length in bytes of the data covered by the author's
|
||||||
* signature.
|
* signature.
|
||||||
*/
|
*/
|
||||||
int getLengthSignedByAuthor();
|
public int getLengthSignedByAuthor() {
|
||||||
|
return signedByAuthor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the length in bytes of the data covered by the group's
|
* Returns the length in bytes of the data covered by the group's
|
||||||
* signature.
|
* signature.
|
||||||
*/
|
*/
|
||||||
int getLengthSignedByGroup();
|
public int getLengthSignedByGroup() {
|
||||||
|
return signedByGroup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -83,8 +83,8 @@ class MessageReader implements StructReader<UnverifiedMessage> {
|
|||||||
r.removeConsumer(counting);
|
r.removeConsumer(counting);
|
||||||
r.removeConsumer(copying);
|
r.removeConsumer(copying);
|
||||||
byte[] raw = copying.getCopy();
|
byte[] raw = copying.getCopy();
|
||||||
return new UnverifiedMessageImpl(parent, group, author, subject,
|
return new UnverifiedMessage(parent, group, author, subject, timestamp,
|
||||||
timestamp, raw, authorSig, groupSig, bodyStart, body.length,
|
raw, authorSig, groupSig, bodyStart, body.length,
|
||||||
signedByAuthor, signedByGroup);
|
signedByAuthor, signedByGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user