Move handshake keys from LocalAuthor to Account.

This commit is contained in:
akwizgran
2019-04-26 15:08:40 +01:00
parent 251eb9e712
commit 56fbc93962
25 changed files with 582 additions and 540 deletions

View File

@@ -48,8 +48,8 @@ public class BlogManagerIntegrationTest
author0 = identityManager0.getLocalAuthor();
author1 = identityManager1.getLocalAuthor();
rssAuthor = c0.getAuthorFactory().createLocalAuthor(
getRandomString(MAX_AUTHOR_NAME_LENGTH), false);
String rssTitle = getRandomString(MAX_AUTHOR_NAME_LENGTH);
rssAuthor = c0.getAuthorFactory().createLocalAuthor(rssTitle);
blogManager0 = c0.getBlogManager();
blogManager1 = c1.getBlogManager();

View File

@@ -1,7 +1,7 @@
package org.briarproject.briar.feed;
import org.briarproject.bramble.api.identity.Account;
import org.briarproject.bramble.api.identity.IdentityManager;
import org.briarproject.bramble.api.identity.LocalAuthor;
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
import org.briarproject.bramble.contact.ContactModule;
import org.briarproject.bramble.crypto.CryptoExecutorModule;
@@ -51,8 +51,8 @@ public class FeedManagerIntegrationTest extends BriarTestCase {
injectEagerSingletons(component);
IdentityManager identityManager = component.getIdentityManager();
LocalAuthor localAuthor = identityManager.createLocalAuthor("feedTest");
identityManager.registerLocalAuthor(localAuthor);
Account account = identityManager.createAccount("feedTest");
identityManager.registerAccount(account);
lifecycleManager = component.getLifecycleManager();
lifecycleManager.startServices(getSecretKey());

View File

@@ -70,7 +70,7 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
public void testForumPostFitsIntoRecord() throws Exception {
// Create a maximum-length author
String authorName = getRandomString(MAX_AUTHOR_NAME_LENGTH);
LocalAuthor author = authorFactory.createLocalAuthor(authorName, false);
LocalAuthor author = authorFactory.createLocalAuthor(authorName);
// Create a maximum-length forum post
GroupId groupId = new GroupId(getRandomId());
long timestamp = Long.MAX_VALUE;

View File

@@ -5,9 +5,9 @@ import org.briarproject.bramble.api.contact.ContactManager;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.event.Event;
import org.briarproject.bramble.api.event.EventListener;
import org.briarproject.bramble.api.identity.Account;
import org.briarproject.bramble.api.identity.Author;
import org.briarproject.bramble.api.identity.IdentityManager;
import org.briarproject.bramble.api.identity.LocalAuthor;
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.sync.GroupId;
@@ -75,13 +75,14 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
@Test
public void testWriteAndRead() throws Exception {
// Create the identities
LocalAuthor aliceAuthor =
alice.getIdentityManager().createLocalAuthor("Alice");
LocalAuthor bobAuthor =
bob.getIdentityManager().createLocalAuthor("Bob");
Account aliceAccount =
alice.getIdentityManager().createAccount("Alice");
Account bobAccount = bob.getIdentityManager().createAccount("Bob");
// Set up the devices and get the contact IDs
ContactId bobId = setUp(alice, aliceAuthor, bobAuthor, true);
ContactId aliceId = setUp(bob, bobAuthor, aliceAuthor, false);
ContactId bobId = setUp(alice, aliceAccount,
bobAccount.getLocalAuthor(), true);
ContactId aliceId = setUp(bob, bobAccount,
aliceAccount.getLocalAuthor(), false);
// Add a private message listener
PrivateMessageListener listener = new PrivateMessageListener();
bob.getEventBus().addListener(listener);
@@ -100,10 +101,10 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
}
private ContactId setUp(SimplexMessagingIntegrationTestComponent device,
LocalAuthor local, Author remote, boolean alice) throws Exception {
Account local, Author remote, boolean alice) throws Exception {
// Add an identity for the user
IdentityManager identityManager = device.getIdentityManager();
identityManager.registerLocalAuthor(local);
identityManager.registerAccount(local);
// Start the lifecycle manager
LifecycleManager lifecycleManager = device.getLifecycleManager();
lifecycleManager.startServices(getSecretKey());

View File

@@ -15,6 +15,7 @@ import org.briarproject.bramble.api.db.DatabaseComponent;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.event.Event;
import org.briarproject.bramble.api.event.EventListener;
import org.briarproject.bramble.api.identity.Account;
import org.briarproject.bramble.api.identity.IdentityManager;
import org.briarproject.bramble.api.identity.LocalAuthor;
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
@@ -274,12 +275,15 @@ public abstract class BriarIntegrationTest<C extends BriarIntegrationTestCompone
}
private void createAndRegisterIdentities() {
author0 = identityManager0.createLocalAuthor(AUTHOR0);
identityManager0.registerLocalAuthor(author0);
author1 = identityManager1.createLocalAuthor(AUTHOR1);
identityManager1.registerLocalAuthor(author1);
author2 = identityManager2.createLocalAuthor(AUTHOR2);
identityManager2.registerLocalAuthor(author2);
Account account0 = identityManager0.createAccount(AUTHOR0);
identityManager0.registerAccount(account0);
author0 = account0.getLocalAuthor();
Account account1 = identityManager0.createAccount(AUTHOR1);
identityManager1.registerAccount(account1);
author1 = account1.getLocalAuthor();
Account account2 = identityManager0.createAccount(AUTHOR2);
identityManager2.registerAccount(account2);
author2 = account2.getLocalAuthor();
}
protected void addDefaultContacts() throws Exception {

View File

@@ -9,8 +9,6 @@ import org.briarproject.briar.api.client.MessageTracker;
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.junit.Assert.assertEquals;
@@ -34,13 +32,12 @@ public class BriarTestUtils {
public static Author getRealAuthor(AuthorFactory authorFactory) {
String name = getRandomString(MAX_AUTHOR_NAME_LENGTH);
byte[] publicKey = getRandomBytes(MAX_PUBLIC_KEY_LENGTH);
return authorFactory.createAuthor(name, publicKey);
return authorFactory.createLocalAuthor(name);
}
public static LocalAuthor getRealLocalAuthor(AuthorFactory authorFactory) {
String name = getRandomString(MAX_AUTHOR_NAME_LENGTH);
return authorFactory.createLocalAuthor(name, false);
return authorFactory.createLocalAuthor(name);
}
}