mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 22:59:54 +01:00
merged with master
This commit is contained in:
@@ -14,6 +14,7 @@ import org.briarproject.api.sync.PacketWriterFactory;
|
|||||||
import org.briarproject.api.transport.KeyManager;
|
import org.briarproject.api.transport.KeyManager;
|
||||||
import org.briarproject.api.transport.StreamReaderFactory;
|
import org.briarproject.api.transport.StreamReaderFactory;
|
||||||
import org.briarproject.api.transport.StreamWriterFactory;
|
import org.briarproject.api.transport.StreamWriterFactory;
|
||||||
|
import org.briarproject.clients.ClientsModule;
|
||||||
import org.briarproject.contact.ContactModule;
|
import org.briarproject.contact.ContactModule;
|
||||||
import org.briarproject.crypto.CryptoModule;
|
import org.briarproject.crypto.CryptoModule;
|
||||||
import org.briarproject.data.DataModule;
|
import org.briarproject.data.DataModule;
|
||||||
@@ -33,7 +34,7 @@ import dagger.Component;
|
|||||||
LifecycleModule.class, ContactModule.class, CryptoModule.class,
|
LifecycleModule.class, ContactModule.class, CryptoModule.class,
|
||||||
DatabaseModule.class, EventModule.class, SyncModule.class,
|
DatabaseModule.class, EventModule.class, SyncModule.class,
|
||||||
DataModule.class, TransportModule.class, IdentityModule.class,
|
DataModule.class, TransportModule.class, IdentityModule.class,
|
||||||
MessagingModule.class})
|
MessagingModule.class, ClientsModule.class})
|
||||||
public interface SimplexMessagingComponent {
|
public interface SimplexMessagingComponent {
|
||||||
void inject(SimplexMessagingIntegrationTest testCase);
|
void inject(SimplexMessagingIntegrationTest testCase);
|
||||||
LifecycleManager getLifeCycleManager();
|
LifecycleManager getLifeCycleManager();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.briarproject.sync;
|
package org.briarproject.sync;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.BriarTestCase;
|
||||||
|
import org.briarproject.ImmediateExecutor;
|
||||||
import org.briarproject.TestDatabaseModule;
|
import org.briarproject.TestDatabaseModule;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.TestUtils;
|
||||||
import org.briarproject.api.TransportId;
|
import org.briarproject.api.TransportId;
|
||||||
@@ -8,7 +9,7 @@ import org.briarproject.api.contact.ContactId;
|
|||||||
import org.briarproject.api.contact.ContactManager;
|
import org.briarproject.api.contact.ContactManager;
|
||||||
import org.briarproject.api.crypto.SecretKey;
|
import org.briarproject.api.crypto.SecretKey;
|
||||||
import org.briarproject.api.db.DatabaseComponent;
|
import org.briarproject.api.db.DatabaseComponent;
|
||||||
import org.briarproject.api.db.StorageStatus;
|
import org.briarproject.api.db.Transaction;
|
||||||
import org.briarproject.api.event.Event;
|
import org.briarproject.api.event.Event;
|
||||||
import org.briarproject.api.event.EventBus;
|
import org.briarproject.api.event.EventBus;
|
||||||
import org.briarproject.api.event.EventListener;
|
import org.briarproject.api.event.EventListener;
|
||||||
@@ -31,7 +32,6 @@ import org.briarproject.api.transport.KeyManager;
|
|||||||
import org.briarproject.api.transport.StreamContext;
|
import org.briarproject.api.transport.StreamContext;
|
||||||
import org.briarproject.api.transport.StreamReaderFactory;
|
import org.briarproject.api.transport.StreamReaderFactory;
|
||||||
import org.briarproject.api.transport.StreamWriterFactory;
|
import org.briarproject.api.transport.StreamWriterFactory;
|
||||||
import org.briarproject.plugins.ImmediateExecutor;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -79,6 +79,140 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
|||||||
read(write());
|
read(write());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private byte[] write() throws Exception {
|
||||||
|
// Instantiate Alice's services
|
||||||
|
LifecycleManager lifecycleManager = alice.getLifeCycleManager();
|
||||||
|
DatabaseComponent db = alice.getDatabaseComponent();
|
||||||
|
IdentityManager identityManager = alice.getIdentityManager();
|
||||||
|
ContactManager contactManager = alice.getContactManager();
|
||||||
|
MessagingManager messagingManager = alice.getMessagingManager();
|
||||||
|
KeyManager keyManager = alice.getKeyManager();
|
||||||
|
PrivateMessageFactory privateMessageFactory =
|
||||||
|
alice.getPrivateMessageFactory();
|
||||||
|
PacketWriterFactory packetWriterFactory =
|
||||||
|
alice.getPacketWriterFactory();
|
||||||
|
EventBus eventBus = alice.getEventBus();
|
||||||
|
StreamWriterFactory streamWriterFactory =
|
||||||
|
alice.getStreamWriterFactory();
|
||||||
|
|
||||||
|
// Start the lifecycle manager
|
||||||
|
lifecycleManager.startServices();
|
||||||
|
lifecycleManager.waitForStartup();
|
||||||
|
// Add a transport
|
||||||
|
Transaction txn = db.startTransaction();
|
||||||
|
try {
|
||||||
|
db.addTransport(txn, transportId, MAX_LATENCY);
|
||||||
|
txn.setComplete();
|
||||||
|
} finally {
|
||||||
|
db.endTransaction(txn);
|
||||||
|
}
|
||||||
|
// Add an identity for Alice
|
||||||
|
LocalAuthor aliceAuthor = new LocalAuthor(aliceId, "Alice",
|
||||||
|
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp);
|
||||||
|
identityManager.addLocalAuthor(aliceAuthor);
|
||||||
|
// Add Bob as a contact
|
||||||
|
Author bobAuthor = new Author(bobId, "Bob",
|
||||||
|
new byte[MAX_PUBLIC_KEY_LENGTH]);
|
||||||
|
ContactId contactId = contactManager.addContact(bobAuthor, aliceId,
|
||||||
|
master, timestamp, true, true);
|
||||||
|
|
||||||
|
// Send Bob a message
|
||||||
|
GroupId groupId = messagingManager.getConversationId(contactId);
|
||||||
|
byte[] body = "Hi Bob!".getBytes("UTF-8");
|
||||||
|
PrivateMessage message = privateMessageFactory.createPrivateMessage(
|
||||||
|
groupId, timestamp, null, "text/plain", body);
|
||||||
|
messagingManager.addLocalMessage(message);
|
||||||
|
// Get a stream context
|
||||||
|
StreamContext ctx = keyManager.getStreamContext(contactId, transportId);
|
||||||
|
assertNotNull(ctx);
|
||||||
|
// Create a stream writer
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
OutputStream streamWriter = streamWriterFactory.createStreamWriter(
|
||||||
|
out, ctx);
|
||||||
|
// Create an outgoing sync session
|
||||||
|
PacketWriter packetWriter = packetWriterFactory.createPacketWriter(
|
||||||
|
streamWriter);
|
||||||
|
SyncSession session = new SimplexOutgoingSession(db,
|
||||||
|
new ImmediateExecutor(), eventBus, contactId, transportId,
|
||||||
|
MAX_LATENCY, packetWriter);
|
||||||
|
// Write whatever needs to be written
|
||||||
|
session.run();
|
||||||
|
streamWriter.close();
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
lifecycleManager.stopServices();
|
||||||
|
lifecycleManager.waitForShutdown();
|
||||||
|
|
||||||
|
// Return the contents of the stream
|
||||||
|
return out.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void read(byte[] stream) throws Exception {
|
||||||
|
// Instantiate Bob's services
|
||||||
|
LifecycleManager lifecycleManager = bob.getLifeCycleManager();
|
||||||
|
DatabaseComponent db = bob.getDatabaseComponent();
|
||||||
|
IdentityManager identityManager = bob.getIdentityManager();
|
||||||
|
ContactManager contactManager = bob.getContactManager();
|
||||||
|
KeyManager keyManager = bob.getKeyManager();
|
||||||
|
StreamReaderFactory streamReaderFactory = bob.getStreamReaderFactory();
|
||||||
|
PacketReaderFactory packetReaderFactory = bob.getPacketReaderFactory();
|
||||||
|
EventBus eventBus = bob.getEventBus();
|
||||||
|
// Bob needs a MessagingManager even though we're not using it directly
|
||||||
|
bob.getMessagingManager();
|
||||||
|
|
||||||
|
// Start the lifecyle manager
|
||||||
|
lifecycleManager.startServices();
|
||||||
|
lifecycleManager.waitForStartup();
|
||||||
|
// Add a transport
|
||||||
|
Transaction txn = db.startTransaction();
|
||||||
|
try {
|
||||||
|
db.addTransport(txn, transportId, MAX_LATENCY);
|
||||||
|
txn.setComplete();
|
||||||
|
} finally {
|
||||||
|
db.endTransaction(txn);
|
||||||
|
}
|
||||||
|
// Add an identity for Bob
|
||||||
|
LocalAuthor bobAuthor = new LocalAuthor(bobId, "Bob",
|
||||||
|
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp);
|
||||||
|
identityManager.addLocalAuthor(bobAuthor);
|
||||||
|
// Add Alice as a contact
|
||||||
|
Author aliceAuthor = new Author(aliceId, "Alice",
|
||||||
|
new byte[MAX_PUBLIC_KEY_LENGTH]);
|
||||||
|
ContactId contactId = contactManager.addContact(aliceAuthor, bobId,
|
||||||
|
master, timestamp, false, true);
|
||||||
|
|
||||||
|
// Set up an event listener
|
||||||
|
MessageListener listener = new MessageListener();
|
||||||
|
bob.getEventBus().addListener(listener);
|
||||||
|
// Read and recognise the tag
|
||||||
|
ByteArrayInputStream in = new ByteArrayInputStream(stream);
|
||||||
|
byte[] tag = new byte[TAG_LENGTH];
|
||||||
|
int read = in.read(tag);
|
||||||
|
assertEquals(tag.length, read);
|
||||||
|
StreamContext ctx = keyManager.getStreamContext(transportId, tag);
|
||||||
|
assertNotNull(ctx);
|
||||||
|
// Create a stream reader
|
||||||
|
InputStream streamReader = streamReaderFactory.createStreamReader(
|
||||||
|
in, ctx);
|
||||||
|
// Create an incoming sync session
|
||||||
|
PacketReader packetReader = packetReaderFactory.createPacketReader(
|
||||||
|
streamReader);
|
||||||
|
SyncSession session = new IncomingSession(db, new ImmediateExecutor(),
|
||||||
|
eventBus, contactId, transportId, packetReader);
|
||||||
|
// No messages should have been added yet
|
||||||
|
assertFalse(listener.messageAdded);
|
||||||
|
// Read whatever needs to be read
|
||||||
|
session.run();
|
||||||
|
streamReader.close();
|
||||||
|
// The private message from Alice should have been added
|
||||||
|
assertTrue(listener.messageAdded);
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
lifecycleManager.stopServices();
|
||||||
|
lifecycleManager.waitForShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private byte[] write() throws Exception {
|
private byte[] write() throws Exception {
|
||||||
// Instantiate Alice's services
|
// Instantiate Alice's services
|
||||||
LifecycleManager lifecycleManager = alice.getLifeCycleManager();
|
LifecycleManager lifecycleManager = alice.getLifeCycleManager();
|
||||||
@@ -201,6 +335,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
|||||||
lifecycleManager.stopServices();
|
lifecycleManager.stopServices();
|
||||||
lifecycleManager.waitForShutdown();
|
lifecycleManager.waitForShutdown();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<string-array name="roboguice_modules">
|
|
||||||
<item>org.briarproject.android.AndroidModule</item>
|
|
||||||
<item>org.briarproject.clients.ClientsModule</item>
|
|
||||||
<item>org.briarproject.contact.ContactModule</item>
|
|
||||||
<item>org.briarproject.crypto.CryptoModule</item>
|
|
||||||
<item>org.briarproject.data.DataModule</item>
|
|
||||||
<item>org.briarproject.db.DatabaseModule</item>
|
|
||||||
<item>org.briarproject.event.EventModule</item>
|
|
||||||
<item>org.briarproject.forum.ForumModule</item>
|
|
||||||
<item>org.briarproject.identity.IdentityModule</item>
|
|
||||||
<item>org.briarproject.invitation.InvitationModule</item>
|
|
||||||
<item>org.briarproject.lifecycle.LifecycleModule</item>
|
|
||||||
<item>org.briarproject.messaging.MessagingModule</item>
|
|
||||||
<item>org.briarproject.plugins.AndroidPluginsModule</item>
|
|
||||||
<item>org.briarproject.properties.PropertiesModule</item>
|
|
||||||
<item>org.briarproject.sync.SyncModule</item>
|
|
||||||
<item>org.briarproject.system.AndroidSystemModule</item>
|
|
||||||
<item>org.briarproject.transport.TransportModule</item>
|
|
||||||
<item>org.briarproject.settings.SettingsModule</item>
|
|
||||||
</string-array>
|
|
||||||
</resources>
|
|
||||||
@@ -14,6 +14,7 @@ import org.briarproject.android.identity.CreateIdentityActivity;
|
|||||||
import org.briarproject.android.invitation.AddContactActivity;
|
import org.briarproject.android.invitation.AddContactActivity;
|
||||||
import org.briarproject.android.panic.PanicPreferencesActivity;
|
import org.briarproject.android.panic.PanicPreferencesActivity;
|
||||||
import org.briarproject.android.panic.PanicResponderActivity;
|
import org.briarproject.android.panic.PanicResponderActivity;
|
||||||
|
import org.briarproject.clients.ClientsModule;
|
||||||
import org.briarproject.contact.ContactModule;
|
import org.briarproject.contact.ContactModule;
|
||||||
import org.briarproject.crypto.CryptoModule;
|
import org.briarproject.crypto.CryptoModule;
|
||||||
import org.briarproject.data.DataModule;
|
import org.briarproject.data.DataModule;
|
||||||
@@ -44,7 +45,7 @@ import dagger.Component;
|
|||||||
EventModule.class, DataModule.class, ContactModule.class,
|
EventModule.class, DataModule.class, ContactModule.class,
|
||||||
AndroidSystemModule.class, AndroidPluginsModule.class,
|
AndroidSystemModule.class, AndroidPluginsModule.class,
|
||||||
PropertiesModule.class, TransportModule.class, SyncModule.class,
|
PropertiesModule.class, TransportModule.class, SyncModule.class,
|
||||||
SettingsModule.class})
|
SettingsModule.class, ClientsModule.class})
|
||||||
public interface AndroidComponent {
|
public interface AndroidComponent {
|
||||||
void inject(SplashScreenActivity activity);
|
void inject(SplashScreenActivity activity);
|
||||||
void inject(SetupActivity activity);
|
void inject(SetupActivity activity);
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.briarproject.clients;
|
package org.briarproject.clients;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
|
||||||
import org.briarproject.api.FormatException;
|
import org.briarproject.api.FormatException;
|
||||||
import org.briarproject.api.clients.ClientHelper;
|
import org.briarproject.api.clients.ClientHelper;
|
||||||
import org.briarproject.api.data.BdfDictionary;
|
import org.briarproject.api.data.BdfDictionary;
|
||||||
@@ -30,6 +28,8 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
||||||
|
|
||||||
class ClientHelperImpl implements ClientHelper {
|
class ClientHelperImpl implements ClientHelper {
|
||||||
|
|||||||
@@ -1,19 +1,36 @@
|
|||||||
package org.briarproject.clients;
|
package org.briarproject.clients;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
|
|
||||||
import org.briarproject.api.clients.ClientHelper;
|
import org.briarproject.api.clients.ClientHelper;
|
||||||
import org.briarproject.api.clients.MessageQueueManager;
|
|
||||||
import org.briarproject.api.clients.PrivateGroupFactory;
|
import org.briarproject.api.clients.PrivateGroupFactory;
|
||||||
import org.briarproject.api.clients.QueueMessageFactory;
|
import org.briarproject.api.data.BdfReaderFactory;
|
||||||
|
import org.briarproject.api.data.BdfWriterFactory;
|
||||||
|
import org.briarproject.api.data.MetadataEncoder;
|
||||||
|
import org.briarproject.api.data.MetadataParser;
|
||||||
|
import org.briarproject.api.db.DatabaseComponent;
|
||||||
|
import org.briarproject.api.sync.GroupFactory;
|
||||||
|
import org.briarproject.api.sync.MessageFactory;
|
||||||
|
|
||||||
public class ClientsModule extends AbstractModule {
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
|
||||||
@Override
|
@Module
|
||||||
protected void configure() {
|
public class ClientsModule {
|
||||||
bind(ClientHelper.class).to(ClientHelperImpl.class);
|
|
||||||
bind(MessageQueueManager.class).to(MessageQueueManagerImpl.class);
|
@Provides
|
||||||
bind(PrivateGroupFactory.class).to(PrivateGroupFactoryImpl.class);
|
ClientHelper provideClientHelper(DatabaseComponent db,
|
||||||
bind(QueueMessageFactory.class).to(QueueMessageFactoryImpl.class);
|
MessageFactory messageFactory, BdfReaderFactory bdfReaderFactory,
|
||||||
|
BdfWriterFactory bdfWriterFactory, MetadataParser metadataParser,
|
||||||
|
MetadataEncoder metadataEncoder) {
|
||||||
|
return new ClientHelperImpl(db, messageFactory, bdfReaderFactory,
|
||||||
|
bdfWriterFactory, metadataParser, metadataEncoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
PrivateGroupFactory providePrivateGroupFactory(GroupFactory groupFactory,
|
||||||
|
BdfWriterFactory bdfWriterFactory) {
|
||||||
|
return new PrivateGroupFactoryImpl(groupFactory, bdfWriterFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
bind(QueueMessageFactory.class).to(QueueMessageFactoryImpl.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,9 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
<<<<<<< 08099714bab27d1ed48a8bee431a35a38098ecec
|
|
||||||
class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
|
||||||
=======
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
||||||
import static org.briarproject.api.db.StorageStatus.ACTIVE;
|
|
||||||
import static org.briarproject.api.db.StorageStatus.ADDING;
|
|
||||||
import static org.briarproject.api.db.StorageStatus.REMOVING;
|
|
||||||
|
|
||||||
class ContactManagerImpl implements ContactManager, Service,
|
|
||||||
RemoveIdentityHook {
|
|
||||||
|
|
||||||
private static final Logger LOG =
|
|
||||||
Logger.getLogger(ContactManagerImpl.class.getName());
|
|
||||||
>>>>>>> Switched Roboguice/Guice out for Dagger 2
|
|
||||||
|
|
||||||
private final DatabaseComponent db;
|
private final DatabaseComponent db;
|
||||||
private final KeyManager keyManager;
|
private final KeyManager keyManager;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ public class ContactModule {
|
|||||||
ContactManager getContactManager(LifecycleManager lifecycleManager,
|
ContactManager getContactManager(LifecycleManager lifecycleManager,
|
||||||
IdentityManager identityManager,
|
IdentityManager identityManager,
|
||||||
ContactManagerImpl contactManager) {
|
ContactManagerImpl contactManager) {
|
||||||
lifecycleManager.register(contactManager);
|
|
||||||
identityManager.registerRemoveIdentityHook(contactManager);
|
identityManager.registerRemoveIdentityHook(contactManager);
|
||||||
return contactManager;
|
return contactManager;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,10 @@ public class ForumModule {
|
|||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ForumManager provideForumManager(DatabaseComponent db,
|
ForumManager provideForumManager(DatabaseComponent db,
|
||||||
ContactManager contactManager,
|
ContactManager contactManager, BdfReaderFactory bdfReaderFactory,
|
||||||
BdfReaderFactory bdfReaderFactory, MetadataEncoder metadataEncoder,
|
MetadataEncoder metadataEncoder, MetadataParser metadataParser) {
|
||||||
MetadataParser metadataParser) {
|
return new ForumManagerImpl(db, bdfReaderFactory, metadataEncoder,
|
||||||
return new ForumManagerImpl(db, contactManager, bdfReaderFactory,
|
metadataParser);
|
||||||
metadataEncoder, metadataParser);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|||||||
@@ -37,12 +37,8 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
<<<<<<< 08099714bab27d1ed48a8bee431a35a38098ecec
|
|
||||||
=======
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
>>>>>>> Switched Roboguice/Guice out for Dagger 2
|
|
||||||
import static org.briarproject.api.forum.ForumConstants.FORUM_SALT_LENGTH;
|
import static org.briarproject.api.forum.ForumConstants.FORUM_SALT_LENGTH;
|
||||||
import static org.briarproject.api.forum.ForumConstants.MAX_FORUM_NAME_LENGTH;
|
import static org.briarproject.api.forum.ForumConstants.MAX_FORUM_NAME_LENGTH;
|
||||||
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
||||||
|
|||||||
@@ -11,22 +11,9 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
<<<<<<< 08099714bab27d1ed48a8bee431a35a38098ecec
|
|
||||||
class IdentityManagerImpl implements IdentityManager {
|
|
||||||
=======
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
class IdentityManagerImpl implements IdentityManager {
|
||||||
import static org.briarproject.api.db.StorageStatus.ACTIVE;
|
|
||||||
import static org.briarproject.api.db.StorageStatus.ADDING;
|
|
||||||
import static org.briarproject.api.db.StorageStatus.REMOVING;
|
|
||||||
|
|
||||||
class IdentityManagerImpl implements IdentityManager, Service {
|
|
||||||
|
|
||||||
private static final Logger LOG =
|
|
||||||
Logger.getLogger(IdentityManagerImpl.class.getName());
|
|
||||||
>>>>>>> Switched Roboguice/Guice out for Dagger 2
|
|
||||||
|
|
||||||
private final DatabaseComponent db;
|
private final DatabaseComponent db;
|
||||||
private final List<AddIdentityHook> addHooks;
|
private final List<AddIdentityHook> addHooks;
|
||||||
private final List<RemoveIdentityHook> removeHooks;
|
private final List<RemoveIdentityHook> removeHooks;
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
package org.briarproject.identity;
|
package org.briarproject.identity;
|
||||||
|
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
|
import org.briarproject.api.data.BdfWriterFactory;
|
||||||
|
import org.briarproject.api.data.ObjectReader;
|
||||||
import org.briarproject.api.db.DatabaseComponent;
|
import org.briarproject.api.db.DatabaseComponent;
|
||||||
import org.briarproject.api.event.EventBus;
|
import org.briarproject.api.event.EventBus;
|
||||||
|
import org.briarproject.api.identity.Author;
|
||||||
|
import org.briarproject.api.identity.AuthorFactory;
|
||||||
import org.briarproject.api.identity.IdentityManager;
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
|
import org.briarproject.api.system.Clock;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
@@ -13,8 +19,18 @@ import dagger.Provides;
|
|||||||
public class IdentityModule {
|
public class IdentityModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
AuthorFactory provideAuthorFactory(CryptoComponent crypto,
|
||||||
IdentityManager provideIdendityModule(DatabaseComponent db, EventBus eventBus) {
|
BdfWriterFactory bdfWriterFactory, Clock clock) {
|
||||||
return new IdentityManagerImpl(db, eventBus);
|
return new AuthorFactoryImpl(crypto, bdfWriterFactory, clock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
IdentityManager provideIdendityModule(DatabaseComponent db) {
|
||||||
|
return new IdentityManagerImpl(db);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
ObjectReader<Author> provideAuthorReader(AuthorFactory authorFactory) {
|
||||||
|
return new AuthorReader(authorFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,12 @@ public class InvitationModule {
|
|||||||
BdfWriterFactory bdfWriterFactory,
|
BdfWriterFactory bdfWriterFactory,
|
||||||
StreamReaderFactory streamReaderFactory,
|
StreamReaderFactory streamReaderFactory,
|
||||||
StreamWriterFactory streamWriterFactory,
|
StreamWriterFactory streamWriterFactory,
|
||||||
AuthorFactory authorFactory, GroupFactory groupFactory,
|
AuthorFactory authorFactory, ConnectionManager connectionManager,
|
||||||
KeyManager keyManager, ConnectionManager connectionManager,
|
|
||||||
IdentityManager identityManager, ContactManager contactManager,
|
IdentityManager identityManager, ContactManager contactManager,
|
||||||
Clock clock, PluginManager pluginManager) {
|
Clock clock, PluginManager pluginManager) {
|
||||||
return new InvitationTaskFactoryImpl(crypto, bdfReaderFactory,
|
return new InvitationTaskFactoryImpl(crypto, bdfReaderFactory,
|
||||||
bdfWriterFactory, streamReaderFactory, streamWriterFactory,
|
bdfWriterFactory, streamReaderFactory, streamWriterFactory,
|
||||||
authorFactory, groupFactory, keyManager, connectionManager,
|
authorFactory, connectionManager, identityManager,
|
||||||
identityManager, contactManager, clock, pluginManager);
|
contactManager, clock, pluginManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import javax.inject.Singleton;
|
|||||||
import org.briarproject.api.event.EventBus;
|
import org.briarproject.api.event.EventBus;
|
||||||
import org.briarproject.api.lifecycle.IoExecutor;
|
import org.briarproject.api.lifecycle.IoExecutor;
|
||||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.plugins.BackoffFactory;
|
||||||
import org.briarproject.api.plugins.ConnectionManager;
|
import org.briarproject.api.plugins.ConnectionManager;
|
||||||
import org.briarproject.api.plugins.ConnectionRegistry;
|
import org.briarproject.api.plugins.ConnectionRegistry;
|
||||||
import org.briarproject.api.plugins.PluginManager;
|
import org.briarproject.api.plugins.PluginManager;
|
||||||
@@ -14,6 +15,7 @@ import org.briarproject.api.transport.KeyManager;
|
|||||||
import org.briarproject.api.transport.StreamReaderFactory;
|
import org.briarproject.api.transport.StreamReaderFactory;
|
||||||
import org.briarproject.api.transport.StreamWriterFactory;
|
import org.briarproject.api.transport.StreamWriterFactory;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
@@ -23,10 +25,16 @@ import dagger.Provides;
|
|||||||
@Module
|
@Module
|
||||||
public class PluginsModule {
|
public class PluginsModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
BackoffFactory provideBackoffFactory() {
|
||||||
|
return new BackoffFactoryImpl();
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
Poller providePoller(@IoExecutor Executor ioExecutor,
|
Poller providePoller(@IoExecutor Executor ioExecutor,
|
||||||
ConnectionRegistry connectionRegistry, Timer timer) {
|
ConnectionRegistry connectionRegistry, SecureRandom random,
|
||||||
return new PollerImpl(ioExecutor, connectionRegistry, timer);
|
Timer timer) {
|
||||||
|
return new PollerImpl(ioExecutor, connectionRegistry, random, timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|||||||
@@ -9,12 +9,10 @@ import org.briarproject.api.event.EventBus;
|
|||||||
import org.briarproject.api.identity.Author;
|
import org.briarproject.api.identity.Author;
|
||||||
import org.briarproject.api.identity.AuthorFactory;
|
import org.briarproject.api.identity.AuthorFactory;
|
||||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
import org.briarproject.api.sync.Group;
|
|
||||||
import org.briarproject.api.sync.GroupFactory;
|
import org.briarproject.api.sync.GroupFactory;
|
||||||
import org.briarproject.api.sync.MessageFactory;
|
import org.briarproject.api.sync.MessageFactory;
|
||||||
import org.briarproject.api.sync.PacketReaderFactory;
|
import org.briarproject.api.sync.PacketReaderFactory;
|
||||||
import org.briarproject.api.sync.PacketWriterFactory;
|
import org.briarproject.api.sync.PacketWriterFactory;
|
||||||
import org.briarproject.api.sync.PrivateGroupFactory;
|
|
||||||
import org.briarproject.api.sync.SyncSessionFactory;
|
import org.briarproject.api.sync.SyncSessionFactory;
|
||||||
import org.briarproject.api.sync.ValidationManager;
|
import org.briarproject.api.sync.ValidationManager;
|
||||||
import org.briarproject.api.system.Clock;
|
import org.briarproject.api.system.Clock;
|
||||||
@@ -29,12 +27,6 @@ import dagger.Provides;
|
|||||||
@Module
|
@Module
|
||||||
public class SyncModule {
|
public class SyncModule {
|
||||||
|
|
||||||
@Provides
|
|
||||||
AuthorFactory provideAuthFactory(CryptoComponent crypto,
|
|
||||||
BdfWriterFactory bdfWriterFactory, Clock clock) {
|
|
||||||
return new AuthorFactoryImpl(crypto, bdfWriterFactory, clock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
GroupFactory provideGroupFactory(CryptoComponent crypto) {
|
GroupFactory provideGroupFactory(CryptoComponent crypto) {
|
||||||
return new GroupFactoryImpl(crypto);
|
return new GroupFactoryImpl(crypto);
|
||||||
@@ -55,12 +47,6 @@ public class SyncModule {
|
|||||||
return new PacketWriterFactoryImpl();
|
return new PacketWriterFactoryImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
PrivateGroupFactory providePrivateGroupFactory(GroupFactory groupFactory,
|
|
||||||
BdfWriterFactory bdfWriterFactory) {
|
|
||||||
return new PrivateGroupFactoryImpl(groupFactory, bdfWriterFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
SyncSessionFactory provideSyncSessionFactory(DatabaseComponent db,
|
SyncSessionFactory provideSyncSessionFactory(DatabaseComponent db,
|
||||||
@@ -71,12 +57,6 @@ public class SyncModule {
|
|||||||
packetReaderFactory, packetWriterFactory);
|
packetReaderFactory, packetWriterFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
ObjectReader<Author> getAuthorReader(AuthorFactory authorFactory) {
|
|
||||||
return new AuthorReader(authorFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ValidationManager getValidationManager(LifecycleManager lifecycleManager,
|
ValidationManager getValidationManager(LifecycleManager lifecycleManager,
|
||||||
|
|||||||
Reference in New Issue
Block a user