Fix rebasing mistakes.

This commit is contained in:
akwizgran
2018-04-27 18:20:04 +01:00
parent fb6b487212
commit c55bef95ce
4 changed files with 37 additions and 38 deletions

View File

@@ -24,7 +24,7 @@ public abstract class ValidatorTestCase extends BrambleMockTestCase {
context.mock(MetadataEncoder.class);
protected final Clock clock = context.mock(Clock.class);
protected final Group group = getGroup(getClientId());
protected final Group group = getGroup(getClientId(), 123);
protected final GroupId groupId = group.getId();
protected final byte[] descriptor = group.getDescriptor();
protected final Message message = getMessage(groupId);

View File

@@ -29,7 +29,7 @@ import static org.briarproject.briar.api.introduction.IntroductionConstants.LABE
import static org.briarproject.briar.api.introduction.IntroductionConstants.LABEL_BOB_MAC_KEY;
import static org.briarproject.briar.api.introduction.IntroductionConstants.LABEL_MASTER_KEY;
import static org.briarproject.briar.api.introduction.IntroductionConstants.LABEL_SESSION_ID;
import static org.briarproject.briar.api.introduction.IntroductionManager.CLIENT_VERSION;
import static org.briarproject.briar.api.introduction.IntroductionManager.MAJOR_VERSION;
import static org.briarproject.briar.introduction.IntroduceeSession.Local;
@Immutable
@@ -94,7 +94,7 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
LABEL_MASTER_KEY,
remoteEphemeralPublicKey,
keyPair,
new byte[] {CLIENT_VERSION},
new byte[] {MAJOR_VERSION},
alice ? publicKey : remotePublicKey,
alice ? remotePublicKey : publicKey
);

View File

@@ -42,13 +42,11 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import javax.inject.Inject;
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
import static org.briarproject.briar.api.introduction.Role.INTRODUCEE;
import static org.briarproject.briar.api.introduction.Role.INTRODUCER;
import static org.briarproject.briar.introduction.IntroducerState.START;
@@ -66,9 +64,6 @@ class IntroductionManagerImpl extends ConversationClientImpl
implements IntroductionManager, Client, ContactHook,
ClientVersioningHook {
private static final Logger LOG =
Logger.getLogger(IntroductionManagerImpl.class.getName());
private final ClientVersioningManager clientVersioningManager;
private final ContactGroupFactory contactGroupFactory;
private final ContactManager contactManager;
@@ -83,8 +78,12 @@ class IntroductionManagerImpl extends ConversationClientImpl
private final Group localGroup;
@Inject
IntroductionManagerImpl(DatabaseComponent db, ClientHelper clientHelper,
ClientVersioningManager clientVersioningManager,MetadataParser metadataParser, MessageTracker messageTracker,
IntroductionManagerImpl(
DatabaseComponent db,
ClientHelper clientHelper,
ClientVersioningManager clientVersioningManager,
MetadataParser metadataParser,
MessageTracker messageTracker,
ContactGroupFactory contactGroupFactory,
ContactManager contactManager,
MessageParser messageParser,
@@ -106,7 +105,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
this.crypto = crypto;
this.identityManager = identityManager;
this.localGroup =
contactGroupFactory.createLocalGroup(CLIENT_ID, CLIENT_VERSION);
contactGroupFactory.createLocalGroup(CLIENT_ID, MAJOR_VERSION);
}
@Override
@@ -144,7 +143,6 @@ class IntroductionManagerImpl extends ConversationClientImpl
abortOrRemoveSessionWithIntroducee(txn, c);
// Remove the contact group (all messages will be removed with it)
db.removeGroup(txn, getContactGroup(c));
}
@@ -159,17 +157,16 @@ class IntroductionManagerImpl extends ConversationClientImpl
@Override
public Group getContactGroup(Contact c) {
return contactGroupFactory
.createContactGroup(CLIENT_ID, CLIENT_VERSION, c);
.createContactGroup(CLIENT_ID, MAJOR_VERSION, c);
}
@Override
protected boolean incomingMessage(Transaction txn, Message m, BdfList body,
BdfDictionary bdfMeta) throws DbException, FormatException {
// Parse the metadata
// Parse the metadata
MessageMetadata meta = messageParser.parseMetadata(bdfMeta);
// Look up the session, if there is one
SessionId sessionId = meta.getSessionId();
IntroduceeSession newIntroduceeSession = null;
if (sessionId == null) {
if (meta.getMessageType() != REQUEST) throw new AssertionError();
@@ -180,7 +177,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
// Handle the message
Session session;
MessageId storageId;
if (ss == null){
if (ss == null) {
if (meta.getMessageType() != REQUEST) throw new FormatException();
if (newIntroduceeSession == null) throw new AssertionError();
storageId = createStorageId(txn);
@@ -191,12 +188,12 @@ class IntroductionManagerImpl extends ConversationClientImpl
Role role = sessionParser.getRole(ss.bdfSession);
if (role == INTRODUCER) {
session = handleMessage(txn, m, body, meta.getMessageType(),
sessionParser.parseIntroducerSession(ss.bdfSession),
introducerEngine);
sessionParser.parseIntroducerSession(ss.bdfSession),
introducerEngine);
} else if (role == INTRODUCEE) {
session = handleMessage(txn, m, body, meta.getMessageType(),
sessionParser.parseIntroduceeSession(m.getGroupId(),
ss.bdfSession), introduceeEngine);
sessionParser.parseIntroduceeSession(m.getGroupId(),
ss.bdfSession), introduceeEngine);
} else throw new AssertionError();
}
// Store the updated session
@@ -407,14 +404,13 @@ class IntroductionManagerImpl extends ConversationClientImpl
List<IntroductionMessage> messages;
Transaction txn = db.startTransaction(true);
try {
Contact contact =db.getContact(txn, c);
Contact contact = db.getContact(txn, c);
GroupId contactGroupId = getContactGroup(contact).getId();
BdfDictionary query = messageParser.getMessagesVisibleInUiQuery();
Map<MessageId, BdfDictionary> results = clientHelper.getMessageMetadataAsDictionary(txn, contactGroupId, query);
messages = new ArrayList<>(results.size());
for (Entry<
MessageId ,
BdfDictionary > e : results.entrySet()) {
Map<MessageId, BdfDictionary> results = clientHelper
.getMessageMetadataAsDictionary(txn, contactGroupId, query);
messages = new ArrayList<>(results.size());
for (Entry<MessageId, BdfDictionary> e : results.entrySet()) {
MessageId m = e.getKey();
MessageMetadata meta =
messageParser.parseMetadata(e.getValue());
@@ -425,7 +421,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
if (type == REQUEST) {
messages.add(
parseInvitationRequest(txn, contactGroupId, m,
meta, status, ss.bdfSession));
meta, status, ss.bdfSession));
} else if (type == ACCEPT) {
messages.add(
parseInvitationResponse(contactGroupId, m, meta,
@@ -445,7 +441,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
return messages;
}
private IntroductionRequest parseInvitationRequest(Transaction txn, GroupId contactGroupId, MessageId m, MessageMetadata meta,
private IntroductionRequest parseInvitationRequest(Transaction txn,
GroupId contactGroupId, MessageId m, MessageMetadata meta,
MessageStatus status, BdfDictionary bdfSession)
throws DbException, FormatException {
Role role = sessionParser.getRole(bdfSession);
@@ -516,9 +513,9 @@ class IntroductionManagerImpl extends ConversationClientImpl
Map<MessageId, BdfDictionary> sessions;
try {
sessions = clientHelper
.getMessageMetadataAsDictionary(txn,localGroup.getId(),
.getMessageMetadataAsDictionary(txn, localGroup.getId(),
query);
} catch (FormatException e){
} catch (FormatException e) {
throw new DbException(e);
}
for (MessageId id : sessions.keySet()) {
@@ -529,20 +526,20 @@ class IntroductionManagerImpl extends ConversationClientImpl
private void abortOrRemoveSessionWithIntroducee(Transaction txn,
Contact c) throws DbException {
BdfDictionary query = sessionEncoder.getIntroducerSessionsQuery();
Map<MessageId, BdfDictionary> sessions;
Map<MessageId, BdfDictionary> sessions;
try {
sessions = clientHelper
.getMessageMetadataAsDictionary(txn,
localGroup.getId(),
query);
.getMessageMetadataAsDictionary(txn, localGroup.getId(),
query);
} catch (FormatException e) {
throw new DbException();
}
LocalAuthor localAuthor = identityManager.getLocalAuthor(txn);for (Entry<MessageId, BdfDictionary> session : sessions.entrySet()) {
LocalAuthor localAuthor = identityManager.getLocalAuthor(txn);
for (Entry<MessageId, BdfDictionary> session : sessions.entrySet()) {
IntroducerSession s;
try {
s = sessionParser.parseIntroducerSession(session.getValue());
} catch (FormatException e){
} catch (FormatException e) {
throw new DbException();
}
if (s.getIntroduceeA().author.equals(c.getAuthor())) {

View File

@@ -25,12 +25,14 @@ import javax.inject.Inject;
import static org.briarproject.bramble.api.crypto.CryptoConstants.MAC_BYTES;
import static org.briarproject.bramble.api.crypto.CryptoConstants.MAX_SIGNATURE_BYTES;
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
import static org.briarproject.bramble.test.TestUtils.getGroup;
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
import static org.briarproject.bramble.test.TestUtils.getRandomId;
import static org.briarproject.bramble.test.TestUtils.getTransportPropertiesMap;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAX_REQUEST_MESSAGE_LENGTH;
import static org.briarproject.briar.api.introduction.IntroductionManager.CLIENT_ID;
import static org.briarproject.briar.api.introduction.IntroductionManager.MAJOR_VERSION;
import static org.briarproject.briar.introduction.MessageType.ABORT;
import static org.briarproject.briar.introduction.MessageType.REQUEST;
import static org.briarproject.briar.test.BriarTestUtils.getRealAuthor;
@@ -57,8 +59,8 @@ public class MessageEncoderParserIntegrationTest extends BrambleTestCase {
private final MessageParser messageParser;
private final IntroductionValidator validator;
private final GroupId groupId = new GroupId(getRandomId());
private final Group group = new Group(groupId, CLIENT_ID, getRandomId());
private final Group group = getGroup(CLIENT_ID, MAJOR_VERSION);
private final GroupId groupId = group.getId();
private final long timestamp = 42L;
private final SessionId sessionId = new SessionId(getRandomId());
private final MessageId previousMsgId = new MessageId(getRandomId());