mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Replace old introduction client with new one
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_ABORT;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_ACK;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_REQUEST;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_RESPONSE;
|
||||
|
||||
@NotNullByDefault
|
||||
public enum IntroduceeAction {
|
||||
|
||||
LOCAL_ACCEPT,
|
||||
LOCAL_DECLINE,
|
||||
LOCAL_ABORT,
|
||||
REMOTE_REQUEST,
|
||||
REMOTE_ACCEPT,
|
||||
REMOTE_DECLINE,
|
||||
REMOTE_ABORT,
|
||||
ACK;
|
||||
|
||||
@Nullable
|
||||
public static IntroduceeAction getRemote(int type, boolean accept) {
|
||||
if (type == TYPE_REQUEST) return REMOTE_REQUEST;
|
||||
if (type == TYPE_RESPONSE && accept) return REMOTE_ACCEPT;
|
||||
if (type == TYPE_RESPONSE) return REMOTE_DECLINE;
|
||||
if (type == TYPE_ACK) return ACK;
|
||||
if (type == TYPE_ABORT) return REMOTE_ABORT;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IntroduceeAction getRemote(int type) {
|
||||
return getRemote(type, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IntroduceeAction getLocal(int type, boolean accept) {
|
||||
if (type == TYPE_RESPONSE && accept) return LOCAL_ACCEPT;
|
||||
if (type == TYPE_RESPONSE) return LOCAL_DECLINE;
|
||||
if (type == TYPE_ACK) return ACK;
|
||||
if (type == TYPE_ABORT) return LOCAL_ABORT;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IntroduceeAction getLocal(int type) {
|
||||
return getLocal(type, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import static org.briarproject.briar.api.introduction.IntroduceeAction.ACK;
|
||||
import static org.briarproject.briar.api.introduction.IntroduceeAction.LOCAL_ACCEPT;
|
||||
import static org.briarproject.briar.api.introduction.IntroduceeAction.LOCAL_DECLINE;
|
||||
import static org.briarproject.briar.api.introduction.IntroduceeAction.REMOTE_ACCEPT;
|
||||
import static org.briarproject.briar.api.introduction.IntroduceeAction.REMOTE_DECLINE;
|
||||
import static org.briarproject.briar.api.introduction.IntroduceeAction.REMOTE_REQUEST;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public enum IntroduceeProtocolState {
|
||||
|
||||
ERROR(0),
|
||||
AWAIT_REQUEST(1) {
|
||||
@Override
|
||||
public IntroduceeProtocolState next(IntroduceeAction a) {
|
||||
if (a == REMOTE_REQUEST) return AWAIT_RESPONSES;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
AWAIT_RESPONSES(2) {
|
||||
@Override
|
||||
public IntroduceeProtocolState next(IntroduceeAction a) {
|
||||
if (a == REMOTE_ACCEPT) return AWAIT_LOCAL_RESPONSE;
|
||||
if (a == REMOTE_DECLINE) return FINISHED;
|
||||
if (a == LOCAL_ACCEPT) return AWAIT_REMOTE_RESPONSE;
|
||||
if (a == LOCAL_DECLINE) return FINISHED;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
AWAIT_REMOTE_RESPONSE(3) {
|
||||
@Override
|
||||
public IntroduceeProtocolState next(IntroduceeAction a) {
|
||||
if (a == REMOTE_ACCEPT) return AWAIT_ACK;
|
||||
if (a == REMOTE_DECLINE) return FINISHED;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
AWAIT_LOCAL_RESPONSE(4) {
|
||||
@Override
|
||||
public IntroduceeProtocolState next(IntroduceeAction a) {
|
||||
if (a == LOCAL_ACCEPT) return AWAIT_ACK;
|
||||
if (a == LOCAL_DECLINE) return FINISHED;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
AWAIT_ACK(5) {
|
||||
@Override
|
||||
public IntroduceeProtocolState next(IntroduceeAction a) {
|
||||
if (a == ACK) return FINISHED;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
FINISHED(6);
|
||||
|
||||
private final int value;
|
||||
|
||||
IntroduceeProtocolState(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static IntroduceeProtocolState fromValue(int value) {
|
||||
for (IntroduceeProtocolState s : values()) {
|
||||
if (s.value == value) return s;
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public IntroduceeProtocolState next(IntroduceeAction a) {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_ABORT;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_ACK;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_REQUEST;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.TYPE_RESPONSE;
|
||||
|
||||
@NotNullByDefault
|
||||
public enum IntroducerAction {
|
||||
|
||||
LOCAL_REQUEST,
|
||||
LOCAL_ABORT,
|
||||
REMOTE_ACCEPT_1,
|
||||
REMOTE_ACCEPT_2,
|
||||
REMOTE_DECLINE_1,
|
||||
REMOTE_DECLINE_2,
|
||||
REMOTE_ABORT,
|
||||
ACK_1,
|
||||
ACK_2;
|
||||
|
||||
@Nullable
|
||||
public static IntroducerAction getLocal(int type) {
|
||||
if (type == TYPE_REQUEST) return LOCAL_REQUEST;
|
||||
if (type == TYPE_ABORT) return LOCAL_ABORT;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IntroducerAction getRemote(int type, boolean one,
|
||||
boolean accept) {
|
||||
|
||||
if (one) {
|
||||
if (type == TYPE_RESPONSE && accept) return REMOTE_ACCEPT_1;
|
||||
if (type == TYPE_RESPONSE) return REMOTE_DECLINE_1;
|
||||
if (type == TYPE_ACK) return ACK_1;
|
||||
} else {
|
||||
if (type == TYPE_RESPONSE && accept) return REMOTE_ACCEPT_2;
|
||||
if (type == TYPE_RESPONSE) return REMOTE_DECLINE_2;
|
||||
if (type == TYPE_ACK) return ACK_2;
|
||||
}
|
||||
if (type == TYPE_ABORT) return REMOTE_ABORT;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IntroducerAction getRemote(int type, boolean one) {
|
||||
return getRemote(type, one, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import static org.briarproject.briar.api.introduction.IntroducerAction.ACK_1;
|
||||
import static org.briarproject.briar.api.introduction.IntroducerAction.ACK_2;
|
||||
import static org.briarproject.briar.api.introduction.IntroducerAction.LOCAL_REQUEST;
|
||||
import static org.briarproject.briar.api.introduction.IntroducerAction.REMOTE_ABORT;
|
||||
import static org.briarproject.briar.api.introduction.IntroducerAction.REMOTE_ACCEPT_1;
|
||||
import static org.briarproject.briar.api.introduction.IntroducerAction.REMOTE_ACCEPT_2;
|
||||
import static org.briarproject.briar.api.introduction.IntroducerAction.REMOTE_DECLINE_1;
|
||||
import static org.briarproject.briar.api.introduction.IntroducerAction.REMOTE_DECLINE_2;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public enum IntroducerProtocolState {
|
||||
|
||||
ERROR(0),
|
||||
PREPARE_REQUESTS(1) {
|
||||
@Override
|
||||
public IntroducerProtocolState next(IntroducerAction a) {
|
||||
if (a == LOCAL_REQUEST) return AWAIT_RESPONSES;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
AWAIT_RESPONSES(2) {
|
||||
@Override
|
||||
public IntroducerProtocolState next(IntroducerAction a) {
|
||||
if (a == REMOTE_ACCEPT_1) return AWAIT_RESPONSE_2;
|
||||
if (a == REMOTE_ACCEPT_2) return AWAIT_RESPONSE_1;
|
||||
if (a == REMOTE_DECLINE_1) return FINISHED;
|
||||
if (a == REMOTE_DECLINE_2) return FINISHED;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
AWAIT_RESPONSE_1(3) {
|
||||
@Override
|
||||
public IntroducerProtocolState next(IntroducerAction a) {
|
||||
if (a == REMOTE_ACCEPT_1) return AWAIT_ACKS;
|
||||
if (a == REMOTE_DECLINE_1) return FINISHED;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
AWAIT_RESPONSE_2(4) {
|
||||
@Override
|
||||
public IntroducerProtocolState next(IntroducerAction a) {
|
||||
if (a == REMOTE_ACCEPT_2) return AWAIT_ACKS;
|
||||
if (a == REMOTE_DECLINE_2) return FINISHED;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
AWAIT_ACKS(5) {
|
||||
@Override
|
||||
public IntroducerProtocolState next(IntroducerAction a) {
|
||||
if (a == ACK_1) return AWAIT_ACK_2;
|
||||
if (a == ACK_2) return AWAIT_ACK_1;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
AWAIT_ACK_1(6) {
|
||||
@Override
|
||||
public IntroducerProtocolState next(IntroducerAction a) {
|
||||
if (a == ACK_1) return FINISHED;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
AWAIT_ACK_2(7) {
|
||||
@Override
|
||||
public IntroducerProtocolState next(IntroducerAction a) {
|
||||
if (a == ACK_2) return FINISHED;
|
||||
return ERROR;
|
||||
}
|
||||
},
|
||||
FINISHED(8) {
|
||||
@Override
|
||||
public IntroducerProtocolState next(IntroducerAction a) {
|
||||
if (a == REMOTE_ABORT) return ERROR;
|
||||
return FINISHED;
|
||||
}
|
||||
};
|
||||
|
||||
private final int value;
|
||||
|
||||
IntroducerProtocolState(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static IntroducerProtocolState fromValue(int value) {
|
||||
for (IntroducerProtocolState s : values()) {
|
||||
if (s.value == value) return s;
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public static boolean isOngoing(IntroducerProtocolState state) {
|
||||
return state != FINISHED && state != ERROR;
|
||||
}
|
||||
|
||||
public IntroducerProtocolState next(IntroducerAction a) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -4,126 +4,26 @@ import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_BODY_L
|
||||
|
||||
public interface IntroductionConstants {
|
||||
|
||||
/* Protocol roles */
|
||||
int ROLE_INTRODUCER = 0;
|
||||
int ROLE_INTRODUCEE = 1;
|
||||
|
||||
/* Message types */
|
||||
int TYPE_REQUEST = 1;
|
||||
int TYPE_RESPONSE = 2;
|
||||
int TYPE_ACK = 3;
|
||||
int TYPE_ABORT = 4;
|
||||
|
||||
/* Message Constants */
|
||||
String TYPE = "type";
|
||||
String GROUP_ID = "groupId";
|
||||
String SESSION_ID = "sessionId";
|
||||
String CONTACT = "contactId";
|
||||
String NAME = "name";
|
||||
String PUBLIC_KEY = "publicKey";
|
||||
String E_PUBLIC_KEY = "ephemeralPublicKey";
|
||||
String MSG = "msg";
|
||||
String ACCEPT = "accept";
|
||||
String TIME = "time";
|
||||
String TRANSPORT = "transport";
|
||||
String MESSAGE_ID = "messageId";
|
||||
String MESSAGE_TIME = "timestamp";
|
||||
String MAC = "mac";
|
||||
String SIGNATURE = "signature";
|
||||
|
||||
/* Validation Constants */
|
||||
|
||||
/**
|
||||
* The length of the message authentication code in bytes.
|
||||
*/
|
||||
int MAC_LENGTH = 32;
|
||||
|
||||
/**
|
||||
* The maximum length of the introducer's optional message to the
|
||||
* introducees in UTF-8 bytes.
|
||||
*/
|
||||
int MAX_INTRODUCTION_MESSAGE_LENGTH = MAX_MESSAGE_BODY_LENGTH - 1024;
|
||||
int MAX_REQUEST_MESSAGE_LENGTH = MAX_MESSAGE_BODY_LENGTH - 1024;
|
||||
|
||||
/* Introducer Local State Metadata */
|
||||
String STATE = "state";
|
||||
String ROLE = "role";
|
||||
String GROUP_ID_1 = "groupId1";
|
||||
String GROUP_ID_2 = "groupId2";
|
||||
String CONTACT_1 = "contact1";
|
||||
String CONTACT_2 = "contact2";
|
||||
String AUTHOR_ID_1 = "authorId1";
|
||||
String AUTHOR_ID_2 = "authorId2";
|
||||
String CONTACT_ID_1 = "contactId1";
|
||||
String CONTACT_ID_2 = "contactId2";
|
||||
String RESPONSE_1 = "response1";
|
||||
String RESPONSE_2 = "response2";
|
||||
String LABEL_SESSION_ID = "org.briarproject.briar.introduction/SESSION_ID";
|
||||
|
||||
/* Introduction Request Action */
|
||||
String PUBLIC_KEY1 = "publicKey1";
|
||||
String PUBLIC_KEY2 = "publicKey2";
|
||||
String LABEL_MASTER_KEY = "org.briarproject.briar.introduction/MASTER_KEY";
|
||||
|
||||
/* Introducee Local State Metadata (without those already defined) */
|
||||
String STORAGE_ID = "storageId";
|
||||
String INTRODUCER = "introducer";
|
||||
String LOCAL_AUTHOR_ID = "localAuthorId";
|
||||
String REMOTE_AUTHOR_ID = "remoteAuthorId";
|
||||
String OUR_PUBLIC_KEY = "ourEphemeralPublicKey";
|
||||
String OUR_PRIVATE_KEY = "ourEphemeralPrivateKey";
|
||||
String OUR_TIME = "ourTime";
|
||||
String ADDED_CONTACT_ID = "addedContactId";
|
||||
String NOT_OUR_RESPONSE = "notOurResponse";
|
||||
String EXISTS = "contactExists";
|
||||
String REMOTE_AUTHOR_IS_US = "remoteAuthorIsUs";
|
||||
String ANSWERED = "answered";
|
||||
String NONCE = "nonce";
|
||||
String MAC_KEY = "macKey";
|
||||
String OUR_TRANSPORT = "ourTransport";
|
||||
String OUR_MAC = "ourMac";
|
||||
String OUR_SIGNATURE = "ourSignature";
|
||||
|
||||
String TASK = "task";
|
||||
int TASK_ADD_CONTACT = 0;
|
||||
int TASK_ACTIVATE_CONTACT = 1;
|
||||
int TASK_ABORT = 2;
|
||||
|
||||
/**
|
||||
* Label for deriving the shared secret.
|
||||
*/
|
||||
String SHARED_SECRET_LABEL =
|
||||
"org.briarproject.briar.introduction/SHARED_SECRET";
|
||||
|
||||
/**
|
||||
* Label for deriving Alice's key binding nonce from the shared secret.
|
||||
*/
|
||||
String ALICE_NONCE_LABEL =
|
||||
"org.briarproject.briar.introduction/ALICE_NONCE";
|
||||
|
||||
/**
|
||||
* Label for deriving Bob's key binding nonce from the shared secret.
|
||||
*/
|
||||
String BOB_NONCE_LABEL =
|
||||
"org.briarproject.briar.introduction/BOB_NONCE";
|
||||
|
||||
/**
|
||||
* Label for deriving Alice's MAC key from the shared secret.
|
||||
*/
|
||||
String ALICE_MAC_KEY_LABEL =
|
||||
String LABEL_ALICE_MAC_KEY =
|
||||
"org.briarproject.briar.introduction/ALICE_MAC_KEY";
|
||||
|
||||
/**
|
||||
* Label for deriving Bob's MAC key from the shared secret.
|
||||
*/
|
||||
String BOB_MAC_KEY_LABEL =
|
||||
String LABEL_BOB_MAC_KEY =
|
||||
"org.briarproject.briar.introduction/BOB_MAC_KEY";
|
||||
|
||||
/**
|
||||
* Label for signing the introduction response.
|
||||
*/
|
||||
String SIGNING_LABEL =
|
||||
"org.briarproject.briar.introduction/RESPONSE_SIGNATURE";
|
||||
String LABEL_AUTH_MAC = "org.briarproject.briar.introduction/AUTH_MAC";
|
||||
|
||||
String LABEL_AUTH_SIGN = "org.briarproject.briar.introduction/AUTH_SIGN";
|
||||
|
||||
String LABEL_AUTH_NONCE = "org.briarproject.briar.introduction/AUTH_NONCE";
|
||||
|
||||
/**
|
||||
* Label for MACing the introduction response.
|
||||
*/
|
||||
String MAC_LABEL = "org.briarproject.briar.introduction/RESPONSE_MAC";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.briar.api.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
@@ -24,25 +23,25 @@ public interface IntroductionManager extends ConversationClient {
|
||||
/**
|
||||
* The current version of the introduction client.
|
||||
*/
|
||||
int CLIENT_VERSION = 0;
|
||||
int CLIENT_VERSION = 1;
|
||||
|
||||
/**
|
||||
* Sends two initial introduction messages.
|
||||
*/
|
||||
void makeIntroduction(Contact c1, Contact c2, @Nullable String msg,
|
||||
long timestamp) throws DbException, FormatException;
|
||||
long timestamp) throws DbException;
|
||||
|
||||
/**
|
||||
* Accepts an introduction.
|
||||
*/
|
||||
void acceptIntroduction(ContactId contactId, SessionId sessionId,
|
||||
long timestamp) throws DbException, FormatException;
|
||||
long timestamp) throws DbException;
|
||||
|
||||
/**
|
||||
* Declines an introduction.
|
||||
*/
|
||||
void declineIntroduction(ContactId contactId, SessionId sessionId,
|
||||
long timestamp) throws DbException, FormatException;
|
||||
long timestamp) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all introduction messages for the given contact.
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.briarproject.briar.api.client.SessionId;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.ROLE_INTRODUCER;
|
||||
import static org.briarproject.briar.api.introduction.Role.INTRODUCER;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
@@ -16,10 +16,10 @@ public class IntroductionMessage extends BaseMessageHeader {
|
||||
|
||||
private final SessionId sessionId;
|
||||
private final MessageId messageId;
|
||||
private final int role;
|
||||
private final Role role;
|
||||
|
||||
IntroductionMessage(SessionId sessionId, MessageId messageId,
|
||||
GroupId groupId, int role, long time, boolean local, boolean sent,
|
||||
GroupId groupId, Role role, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read) {
|
||||
|
||||
super(messageId, groupId, time, local, sent, seen, read);
|
||||
@@ -37,7 +37,7 @@ public class IntroductionMessage extends BaseMessageHeader {
|
||||
}
|
||||
|
||||
public boolean isIntroducer() {
|
||||
return role == ROLE_INTRODUCER;
|
||||
return role == INTRODUCER;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.briar.api.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.identity.AuthorId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
@@ -15,21 +14,19 @@ public class IntroductionRequest extends IntroductionResponse {
|
||||
|
||||
@Nullable
|
||||
private final String message;
|
||||
private final boolean answered, exists, introducesOtherIdentity;
|
||||
private final boolean answered, exists;
|
||||
|
||||
public IntroductionRequest(SessionId sessionId, MessageId messageId,
|
||||
GroupId groupId, int role, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, AuthorId authorId, String name,
|
||||
boolean accepted, @Nullable String message, boolean answered,
|
||||
boolean exists, boolean introducesOtherIdentity) {
|
||||
GroupId groupId, Role role, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, String name, boolean accepted,
|
||||
@Nullable String message, boolean answered, boolean exists) {
|
||||
|
||||
super(sessionId, messageId, groupId, role, time, local, sent, seen,
|
||||
read, authorId, name, accepted);
|
||||
read, name, accepted);
|
||||
|
||||
this.message = message;
|
||||
this.answered = answered;
|
||||
this.exists = exists;
|
||||
this.introducesOtherIdentity = introducesOtherIdentity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -44,8 +41,4 @@ public class IntroductionRequest extends IntroductionResponse {
|
||||
public boolean contactExists() {
|
||||
return exists;
|
||||
}
|
||||
|
||||
public boolean doesIntroduceOtherIdentity() {
|
||||
return introducesOtherIdentity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.briar.api.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.identity.AuthorId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
@@ -12,19 +11,15 @@ import javax.annotation.concurrent.Immutable;
|
||||
@NotNullByDefault
|
||||
public class IntroductionResponse extends IntroductionMessage {
|
||||
|
||||
private final AuthorId remoteAuthorId;
|
||||
private final String name;
|
||||
private final boolean accepted;
|
||||
|
||||
public IntroductionResponse(SessionId sessionId, MessageId messageId,
|
||||
GroupId groupId, int role, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, AuthorId remoteAuthorId, String name,
|
||||
boolean accepted) {
|
||||
|
||||
GroupId groupId, Role role, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, String name, boolean accepted) {
|
||||
super(sessionId, messageId, groupId, role, time, local, sent, seen,
|
||||
read);
|
||||
|
||||
this.remoteAuthorId = remoteAuthorId;
|
||||
this.name = name;
|
||||
this.accepted = accepted;
|
||||
}
|
||||
@@ -37,7 +32,4 @@ public class IntroductionResponse extends IntroductionMessage {
|
||||
return accepted;
|
||||
}
|
||||
|
||||
public AuthorId getRemoteAuthorId() {
|
||||
return remoteAuthorId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.briar.api.introduction2;
|
||||
package org.briarproject.briar.api.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.briar.api.introduction.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
@@ -11,19 +10,14 @@ import javax.annotation.concurrent.Immutable;
|
||||
@NotNullByDefault
|
||||
public class IntroductionAbortedEvent extends Event {
|
||||
|
||||
private final ContactId contactId;
|
||||
private final SessionId sessionId;
|
||||
|
||||
public IntroductionAbortedEvent(ContactId contactId, SessionId sessionId) {
|
||||
this.contactId = contactId;
|
||||
public IntroductionAbortedEvent(SessionId sessionId) {
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
public ContactId getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
|
||||
public SessionId getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
// TODO still needed?
|
||||
public class IntroductionSucceededEvent extends Event {
|
||||
|
||||
private final Contact contact;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction2;
|
||||
|
||||
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||
|
||||
public interface IntroductionConstants {
|
||||
|
||||
/**
|
||||
* The maximum length of the introducer's optional message to the
|
||||
* introducees in UTF-8 bytes.
|
||||
*/
|
||||
int MAX_REQUEST_MESSAGE_LENGTH = MAX_MESSAGE_BODY_LENGTH - 1024;
|
||||
|
||||
String LABEL_SESSION_ID = "org.briarproject.briar.introduction/SESSION_ID";
|
||||
|
||||
String LABEL_MASTER_KEY = "org.briarproject.briar.introduction/MASTER_KEY";
|
||||
|
||||
String LABEL_ALICE_MAC_KEY =
|
||||
"org.briarproject.briar.introduction/ALICE_MAC_KEY";
|
||||
|
||||
String LABEL_BOB_MAC_KEY =
|
||||
"org.briarproject.briar.introduction/BOB_MAC_KEY";
|
||||
|
||||
String LABEL_AUTH_MAC = "org.briarproject.briar.introduction/AUTH_MAC";
|
||||
|
||||
String LABEL_AUTH_SIGN = "org.briarproject.briar.introduction/AUTH_SIGN";
|
||||
|
||||
String LABEL_AUTH_NONCE = "org.briarproject.briar.introduction/AUTH_NONCE";
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction2;
|
||||
|
||||
import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.ClientId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.api.messaging.ConversationManager.ConversationClient;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface IntroductionManager extends ConversationClient {
|
||||
|
||||
/**
|
||||
* The unique ID of the introduction client.
|
||||
*/
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.introduction");
|
||||
|
||||
/**
|
||||
* The current version of the introduction client.
|
||||
*/
|
||||
int CLIENT_VERSION = 1;
|
||||
|
||||
/**
|
||||
* Sends two initial introduction messages.
|
||||
*/
|
||||
void makeIntroduction(Contact c1, Contact c2, @Nullable String msg,
|
||||
long timestamp) throws DbException;
|
||||
|
||||
/**
|
||||
* Accepts an introduction.
|
||||
*/
|
||||
void acceptIntroduction(ContactId contactId, SessionId sessionId,
|
||||
long timestamp) throws DbException;
|
||||
|
||||
/**
|
||||
* Declines an introduction.
|
||||
*/
|
||||
void declineIntroduction(ContactId contactId, SessionId sessionId,
|
||||
long timestamp) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all introduction messages for the given contact.
|
||||
*/
|
||||
Collection<IntroductionMessage> getIntroductionMessages(ContactId contactId)
|
||||
throws DbException;
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction2;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.BaseMessageHeader;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import static org.briarproject.briar.api.introduction2.Role.INTRODUCER;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class IntroductionMessage extends BaseMessageHeader {
|
||||
|
||||
private final SessionId sessionId;
|
||||
private final MessageId messageId;
|
||||
private final Role role;
|
||||
|
||||
IntroductionMessage(SessionId sessionId, MessageId messageId,
|
||||
GroupId groupId, Role role, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read) {
|
||||
|
||||
super(messageId, groupId, time, local, sent, seen, read);
|
||||
this.sessionId = sessionId;
|
||||
this.messageId = messageId;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public SessionId getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public MessageId getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public boolean isIntroducer() {
|
||||
return role == INTRODUCER;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction2;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class IntroductionRequest extends IntroductionResponse {
|
||||
|
||||
@Nullable
|
||||
private final String message;
|
||||
private final boolean answered, exists;
|
||||
|
||||
public IntroductionRequest(SessionId sessionId, MessageId messageId,
|
||||
GroupId groupId, Role role, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, String name, boolean accepted,
|
||||
@Nullable String message, boolean answered, boolean exists) {
|
||||
|
||||
super(sessionId, messageId, groupId, role, time, local, sent, seen,
|
||||
read, name, accepted);
|
||||
|
||||
this.message = message;
|
||||
this.answered = answered;
|
||||
this.exists = exists;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public boolean wasAnswered() {
|
||||
return answered;
|
||||
}
|
||||
|
||||
public boolean contactExists() {
|
||||
return exists;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction2;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class IntroductionResponse extends IntroductionMessage {
|
||||
|
||||
private final String name;
|
||||
private final boolean accepted;
|
||||
|
||||
public IntroductionResponse(SessionId sessionId, MessageId messageId,
|
||||
GroupId groupId, Role role, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, String name, boolean accepted) {
|
||||
super(sessionId, messageId, groupId, role, time, local, sent, seen,
|
||||
read);
|
||||
|
||||
this.name = name;
|
||||
this.accepted = accepted;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean wasAccepted() {
|
||||
return accepted;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction2.event;
|
||||
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.identity.AuthorId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
// TODO still needed?
|
||||
public class IntroductionAbortedEvent extends Event {
|
||||
|
||||
private final AuthorId remoteAuthorId;
|
||||
private final SessionId sessionId;
|
||||
|
||||
public IntroductionAbortedEvent(AuthorId remoteAuthorId,
|
||||
SessionId sessionId) {
|
||||
this.remoteAuthorId = remoteAuthorId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
public AuthorId getRemoteAuthorId() {
|
||||
return remoteAuthorId;
|
||||
}
|
||||
|
||||
public SessionId getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction2.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.introduction2.IntroductionRequest;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class IntroductionRequestReceivedEvent extends Event {
|
||||
|
||||
private final ContactId contactId;
|
||||
private final IntroductionRequest introductionRequest;
|
||||
|
||||
public IntroductionRequestReceivedEvent(ContactId contactId,
|
||||
IntroductionRequest introductionRequest) {
|
||||
|
||||
this.contactId = contactId;
|
||||
this.introductionRequest = introductionRequest;
|
||||
}
|
||||
|
||||
public ContactId getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
|
||||
public IntroductionRequest getIntroductionRequest() {
|
||||
return introductionRequest;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction2.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.introduction2.IntroductionResponse;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class IntroductionResponseReceivedEvent extends Event {
|
||||
|
||||
private final ContactId contactId;
|
||||
private final IntroductionResponse introductionResponse;
|
||||
|
||||
public IntroductionResponseReceivedEvent(ContactId contactId,
|
||||
IntroductionResponse introductionResponse) {
|
||||
|
||||
this.contactId = contactId;
|
||||
this.introductionResponse = introductionResponse;
|
||||
}
|
||||
|
||||
public ContactId getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
|
||||
public IntroductionResponse getIntroductionResponse() {
|
||||
return introductionResponse;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.briarproject.briar.api.introduction2.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
// TODO still needed?
|
||||
public class IntroductionSucceededEvent extends Event {
|
||||
|
||||
private final Contact contact;
|
||||
|
||||
public IntroductionSucceededEvent(Contact contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
public Contact getContact() {
|
||||
return contact;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user