Implement BQP transport descriptors

This commit is contained in:
str4d
2016-01-28 23:23:43 +00:00
parent 65316414ea
commit d2d8d9d46e
11 changed files with 347 additions and 14 deletions

View File

@@ -0,0 +1,23 @@
package org.briarproject.api.keyagreement;
import org.briarproject.api.TransportId;
import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
public class KeyAgreementConnection {
private final DuplexTransportConnection conn;
private final TransportId id;
public KeyAgreementConnection(DuplexTransportConnection conn,
TransportId id) {
this.conn = conn;
this.id = id;
}
public DuplexTransportConnection getConnection() {
return conn;
}
public TransportId getTransportId() {
return id;
}
}

View File

@@ -0,0 +1,35 @@
package org.briarproject.api.keyagreement;
import java.util.concurrent.Callable;
/**
* An class for managing a particular key agreement listener.
*/
public abstract class KeyAgreementListener {
private final TransportDescriptor descriptor;
public KeyAgreementListener(TransportDescriptor descriptor) {
this.descriptor = descriptor;
}
/**
* Returns the descriptor that a remote peer can use to connect to this
* listener.
*/
public TransportDescriptor getDescriptor() {
return descriptor;
}
/**
* Starts listening for incoming connections, and returns a Callable that
* will return a KeyAgreementConnection when an incoming connection is
* received.
*/
public abstract Callable<KeyAgreementConnection> listen();
/**
* Closes the underlying server socket.
*/
public abstract void close();
}

View File

@@ -0,0 +1,28 @@
package org.briarproject.api.keyagreement;
import org.briarproject.api.TransportId;
import org.briarproject.api.properties.TransportProperties;
/**
* Describes how to connect to a device over a short-range transport.
*/
public class TransportDescriptor {
private final TransportId id;
private final TransportProperties properties;
public TransportDescriptor(TransportId id, TransportProperties properties) {
this.id = id;
this.properties = properties;
}
/** Returns the transport identifier. */
public TransportId getIdentifier() {
return id;
}
/** Returns the transport properties. */
public TransportProperties getProperties() {
return properties;
}
}