mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Preliminaries for private group invitation protocol.
This commit is contained in:
@@ -24,14 +24,24 @@ class MessageFactoryImpl implements MessageFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message createMessage(GroupId groupId, long timestamp, byte[] body) {
|
||||
public Message createMessage(GroupId g, long timestamp, byte[] body) {
|
||||
if (body.length > MAX_MESSAGE_BODY_LENGTH)
|
||||
throw new IllegalArgumentException();
|
||||
byte[] raw = new byte[MESSAGE_HEADER_LENGTH + body.length];
|
||||
System.arraycopy(groupId.getBytes(), 0, raw, 0, UniqueId.LENGTH);
|
||||
System.arraycopy(g.getBytes(), 0, raw, 0, UniqueId.LENGTH);
|
||||
ByteUtils.writeUint64(timestamp, raw, UniqueId.LENGTH);
|
||||
System.arraycopy(body, 0, raw, MESSAGE_HEADER_LENGTH, body.length);
|
||||
MessageId id = new MessageId(crypto.hash(MessageId.LABEL, raw));
|
||||
return new Message(id, groupId, timestamp, raw);
|
||||
return new Message(id, g, timestamp, raw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message createMessage(MessageId m, byte[] raw) {
|
||||
if (raw.length < MESSAGE_HEADER_LENGTH)
|
||||
throw new IllegalArgumentException();
|
||||
byte[] groupId = new byte[UniqueId.LENGTH];
|
||||
System.arraycopy(raw, 0, groupId, 0, UniqueId.LENGTH);
|
||||
long timestamp = ByteUtils.readUint64(raw, UniqueId.LENGTH);
|
||||
return new Message(m, new GroupId(groupId), timestamp, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,8 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
||||
MessageContext context = v.validateMessage(m, g);
|
||||
storeMessageContextAsync(m, g.getClientId(), context);
|
||||
} catch (InvalidMessageException e) {
|
||||
if (LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.log(INFO, e.toString(), e);
|
||||
Queue<MessageId> invalidate = new LinkedList<MessageId>();
|
||||
invalidate.add(m.getId());
|
||||
invalidateNextMessageAsync(invalidate);
|
||||
|
||||
Reference in New Issue
Block a user