Merge branch '112-transport-properties-manager' into 'master'

Transport properties manager facade, key manager refactoring. #112

Refactoring for #112: decouple the invitation and plugin code from the database with a TransportPropertiesManager facade (which will become a BSP client), and move some key management logic from the invitation code to the KeyManager. Update the integration tests to use the new FooManager facades.

See merge request !49
This commit is contained in:
akwizgran
2016-01-12 11:35:18 +00:00
22 changed files with 347 additions and 166 deletions

View File

@@ -1,6 +1,7 @@
package org.briarproject.api.messaging;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.crypto.SecretKey;
import org.briarproject.api.db.DbException;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.Message;
@@ -10,6 +11,12 @@ import java.util.Collection;
public interface MessagingManager {
/**
* Informs the messaging manager that a new contact has been added.
* Creates a private conversation with the contact.
*/
void addContact(ContactId c, SecretKey master) throws DbException;
/** Stores a local private message. */
void addLocalMessage(Message m) throws DbException;

View File

@@ -0,0 +1,36 @@
package org.briarproject.api.property;
import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.db.DbException;
import java.util.Map;
public interface TransportPropertyManager {
/** Returns the local transport properties for all transports. */
Map<TransportId, TransportProperties> getLocalProperties()
throws DbException;
/** Returns the local transport properties for the given transport. */
TransportProperties getLocalProperties(TransportId t) throws DbException;
/** Returns all remote transport properties for the given transport. */
Map<ContactId, TransportProperties> getRemoteProperties(TransportId t)
throws DbException;
/**
* Merges the given properties with the existing local properties for the
* given transport.
*/
void mergeLocalProperties(TransportId t, TransportProperties p)
throws DbException;
/**
* Sets the remote transport properties for the given contact, replacing
* any existing properties.
*/
void setRemoteProperties(ContactId c,
Map<TransportId, TransportProperties> p) throws DbException;
}

View File

@@ -2,7 +2,7 @@ package org.briarproject.api.sync;
import java.util.Collection;
/** A packet acknowledging receipt of one or more {@link Message}s. */
/** A packet acknowledging receipt of one or more {@link Message Messages}. */
public class Ack {
private final Collection<MessageId> acked;

View File

@@ -2,7 +2,7 @@ package org.briarproject.api.sync;
import java.util.Collection;
/** A packet offering the recipient one or more {@link Message}s. */
/** A packet offering the recipient one or more {@link Message Messages}. */
public class Offer {
private final Collection<MessageId> offered;

View File

@@ -2,7 +2,9 @@ package org.briarproject.api.sync;
import java.util.Collection;
/** A packet requesting one or more {@link Message}s from the recipient. */
/**
* A packet requesting one or more {@link Message Messages} from the recipient.
*/
public class Request {
private final Collection<org.briarproject.api.sync.MessageId> requested;

View File

@@ -2,7 +2,7 @@ package org.briarproject.api.transport;
import org.briarproject.api.TransportId;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.db.DbException;
import org.briarproject.api.crypto.SecretKey;
import org.briarproject.api.lifecycle.Service;
import java.util.Collection;
@@ -14,11 +14,13 @@ import java.util.Collection;
public interface KeyManager extends Service {
/**
* Informs the key manager that a new contact has been added.
* Informs the key manager that a new contact has been added. Derives and
* stores transport keys for communicating with the contact.
* {@link StreamContext StreamContexts} for the contact can be created
* after this method has returned.
*/
void contactAdded(ContactId c, Collection<TransportKeys> keys);
void addContact(ContactId c, Collection<TransportId> transports,
SecretKey master, long timestamp, boolean alice);
/**
* Returns a {@link StreamContext} for sending a stream to the given
@@ -29,8 +31,8 @@ public interface KeyManager extends Service {
/**
* Looks up the given tag and returns a {@link StreamContext} for reading
* from the corresponding stream if the tag was expected, or null if the
* tag was unexpected.
* from the corresponding stream, or null if an error occurs or the tag was
* unexpected.
*/
StreamContext recogniseTag(TransportId t, byte[] tag) throws DbException;
StreamContext getStreamContext(TransportId t, byte[] tag);
}