Renamed ContactTransport -> Endpoint, added more database exceptions.

This commit is contained in:
akwizgran
2013-01-29 15:24:34 +00:00
parent 54067763a6
commit 61a6931643
15 changed files with 199 additions and 161 deletions

View File

@@ -3,7 +3,7 @@ package net.sf.briar.api.crypto;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.protocol.TransportId;
import net.sf.briar.api.transport.ConnectionContext;
import net.sf.briar.api.transport.ContactTransport;
import net.sf.briar.api.transport.Endpoint;
public interface KeyManager {
@@ -24,8 +24,8 @@ public interface KeyManager {
ConnectionContext getConnectionContext(ContactId c, TransportId t);
/**
* Called whenever a contact transport has been added. The initial secret
* Called whenever an endpoint has been added. The initial secret
* is erased before returning.
*/
void contactTransportAdded(ContactTransport ct, byte[] initialSecret);
void endpointAdded(Endpoint ep, byte[] initialSecret);
}

View File

@@ -24,7 +24,7 @@ import net.sf.briar.api.protocol.SubscriptionUpdate;
import net.sf.briar.api.protocol.TransportAck;
import net.sf.briar.api.protocol.TransportId;
import net.sf.briar.api.protocol.TransportUpdate;
import net.sf.briar.api.transport.ContactTransport;
import net.sf.briar.api.transport.Endpoint;
import net.sf.briar.api.transport.TemporarySecret;
/**
@@ -54,8 +54,8 @@ public interface DatabaseComponent {
*/
ContactId addContact() throws DbException;
/** Adds a contact transport to the database. */
void addContactTransport(ContactTransport ct) throws DbException;
/** Adds an endpoitn to the database. */
void addEndpoint(Endpoint ep) throws DbException;
/** Adds a locally generated group message to the database. */
void addLocalGroupMessage(Message m) throws DbException;
@@ -239,8 +239,8 @@ public interface DatabaseComponent {
void removeContact(ContactId c) throws DbException;
/**
* Sets the connection reordering window for the given contact transport
* in the given rotation period.
* Sets the connection reordering window for the given endoint in the given
* rotation period.
*/
void setConnectionWindow(ContactId c, TransportId t, long period,
long centre, byte[] bitmap) throws DbException;

View File

@@ -2,7 +2,8 @@ package net.sf.briar.api.db;
/**
* Thrown when a database operation is attempted for a contact that is not in
* the database.
* the database. This exception may occur due to concurrent updates and does
* not indicate a database error.
*/
public class NoSuchContactException extends DbException {

View File

@@ -1,10 +0,0 @@
package net.sf.briar.api.db;
/**
* Thrown when a database operation is attempted for a contact transport that
* is not in the database.
*/
public class NoSuchContactTransportException extends DbException {
private static final long serialVersionUID = -6274982612759573100L;
}

View File

@@ -0,0 +1,12 @@
package net.sf.briar.api.db;
/**
* Thrown when a database operation is attempted for a group to which the user
* does not subscribe. This exception may occur due to concurrent updates and
* does not indicate a database error.
*/
public class NoSuchSubscriptionException extends DbException {
private static final long serialVersionUID = -5494178507342571697L;
}

View File

@@ -0,0 +1,11 @@
package net.sf.briar.api.db;
/**
* Thrown when a database operation is attempted for a transport that is not in
* the database. This exception may occur due to concurrent updates and does
* not indicate a database error.
*/
public class NoSuchTransportException extends DbException {
private static final long serialVersionUID = -6274982612759573100L;
}

View File

@@ -3,14 +3,14 @@ package net.sf.briar.api.transport;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.protocol.TransportId;
public class ContactTransport {
public class Endpoint {
private final ContactId contactId;
private final TransportId transportId;
private final long epoch, clockDiff, latency;
private final boolean alice;
public ContactTransport(ContactId contactId, TransportId transportId,
public Endpoint(ContactId contactId, TransportId transportId,
long epoch, long clockDiff, long latency, boolean alice) {
this.contactId = contactId;
this.transportId = transportId;

View File

@@ -4,7 +4,7 @@ import static net.sf.briar.api.transport.TransportConstants.CONNECTION_WINDOW_SI
import net.sf.briar.api.ContactId;
import net.sf.briar.api.protocol.TransportId;
public class TemporarySecret extends ContactTransport {
public class TemporarySecret extends Endpoint {
private final long period, outgoing, centre;
private final byte[] secret, bitmap;
@@ -30,10 +30,10 @@ public class TemporarySecret extends ContactTransport {
secret, 0L, 0L, new byte[CONNECTION_WINDOW_SIZE / 8]);
}
/** Creates a temporary secret derived from the given contact transport. */
public TemporarySecret(ContactTransport ct, long period, byte[] secret) {
this(ct.getContactId(), ct.getTransportId(), ct.getEpoch(),
ct.getClockDifference(), ct.getLatency(), ct.getAlice(),
/** Creates a temporary secret derived from the given endpoint. */
public TemporarySecret(Endpoint ep, long period, byte[] secret) {
this(ep.getContactId(), ep.getTransportId(), ep.getEpoch(),
ep.getClockDifference(), ep.getLatency(), ep.getAlice(),
period, secret);
}