Transport properties client. #229

This commit is contained in:
akwizgran
2016-01-22 11:32:39 +00:00
parent baa580c6f4
commit 88475bdd54
66 changed files with 748 additions and 436 deletions

View File

@@ -3,7 +3,7 @@ package org.briarproject.api;
import java.util.Hashtable;
import java.util.Map;
abstract class StringMap extends Hashtable<String, String> {
public abstract class StringMap extends Hashtable<String, String> {
private static final long serialVersionUID = 2497176435908100448L;

View File

@@ -1,12 +1,13 @@
package org.briarproject.api;
import static org.briarproject.api.TransportPropertyConstants.MAX_TRANSPORT_ID_LENGTH;
/**
* Type-safe wrapper for a string that uniquely identifies a transport plugin.
*/
public class TransportId {
/** The maximum length of transport identifier in UTF-8 bytes. */
public static int MAX_TRANSPORT_ID_LENGTH = 10;
private final String id;
public TransportId(String id) {
@@ -21,8 +22,7 @@ public class TransportId {
@Override
public boolean equals(Object o) {
if (o instanceof TransportId) return id.equals(((TransportId) o).id);
return false;
return o instanceof TransportId && id.equals(((TransportId) o).id);
}
@Override

View File

@@ -1,12 +1,12 @@
package org.briarproject.api.db;
import org.briarproject.api.Settings;
import org.briarproject.api.TransportId;
import org.briarproject.api.contact.Contact;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.identity.Author;
import org.briarproject.api.identity.AuthorId;
import org.briarproject.api.identity.LocalAuthor;
import org.briarproject.api.settings.Settings;
import org.briarproject.api.sync.Ack;
import org.briarproject.api.sync.ClientId;
import org.briarproject.api.sync.Group;

View File

@@ -1,9 +0,0 @@
package org.briarproject.api.event;
/**
* An event that is broadcast when the local transport properties are
* updated.
*/
public class LocalTransportsUpdatedEvent extends Event {
}

View File

@@ -1,28 +0,0 @@
package org.briarproject.api.event;
import org.briarproject.api.TransportId;
import org.briarproject.api.contact.ContactId;
/**
* An event that is broadcast when a contact's remote transport properties
* are updated.
*/
public class RemoteTransportsUpdatedEvent extends Event {
private final ContactId contactId;
private final TransportId transportId;
public RemoteTransportsUpdatedEvent(ContactId contactId,
TransportId transportId) {
this.contactId = contactId;
this.transportId = transportId;
}
public ContactId getContactId() {
return contactId;
}
public TransportId getTransportId() {
return transportId;
}
}

View File

@@ -7,5 +7,5 @@ public interface InvitationTaskFactory {
/** Creates a task using the given pseudonym and invitation codes. */
InvitationTask createTask(AuthorId localAuthorId, int localCode,
int remoteCode, boolean reuseConnection);
int remoteCode);
}

View File

@@ -1,8 +1,8 @@
package org.briarproject.api.plugins;
import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.Settings;
import org.briarproject.api.properties.TransportProperties;
import org.briarproject.api.settings.Settings;
import java.util.Map;

View File

@@ -1,4 +1,6 @@
package org.briarproject.api;
package org.briarproject.api.properties;
import org.briarproject.api.StringMap;
import java.util.Map;

View File

@@ -1,13 +1,7 @@
package org.briarproject.api;
package org.briarproject.api.properties;
public interface TransportPropertyConstants {
/**
* The maximum length of a string that uniquely identifies a transport
* plugin.
*/
int MAX_TRANSPORT_ID_LENGTH = 10;
/** The maximum number of properties per transport. */
int MAX_PROPERTIES_PER_TRANSPORT = 100;

View File

@@ -1,7 +1,6 @@
package org.briarproject.api.property;
package org.briarproject.api.properties;
import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.db.DbException;
@@ -26,11 +25,4 @@ public interface TransportPropertyManager {
*/
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

@@ -1,4 +1,6 @@
package org.briarproject.api;
package org.briarproject.api.settings;
import org.briarproject.api.StringMap;
public class Settings extends StringMap {

View File

@@ -1,6 +1,5 @@
package org.briarproject.api.settings;
import org.briarproject.api.Settings;
import org.briarproject.api.db.DbException;
public interface SettingsManager {

View File

@@ -4,8 +4,6 @@ import org.briarproject.api.TransportId;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.crypto.SecretKey;
import java.util.Collection;
/**
* Responsible for managing transport keys and recognising the pseudo-random
* tags of incoming streams.
@@ -18,8 +16,8 @@ public interface KeyManager {
* {@link StreamContext StreamContexts} for the contact can be created
* after this method has returned.
*/
void addContact(ContactId c, Collection<TransportId> transports,
SecretKey master, long timestamp, boolean alice);
void addContact(ContactId c, SecretKey master, long timestamp,
boolean alice);
/**
* Returns a {@link StreamContext} for sending a stream to the given