mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Remove local author from contacts.
This commit is contained in:
@@ -18,11 +18,10 @@ public interface ContactGroupFactory {
|
||||
* Creates a group for the given client to share with the given contact.
|
||||
*/
|
||||
Group createContactGroup(ClientId clientId, int majorVersion,
|
||||
Contact contact);
|
||||
Contact contact, AuthorId local);
|
||||
|
||||
/**
|
||||
* Creates a group for the given client to share between the given authors
|
||||
* identified by their AuthorIds.
|
||||
* Creates a group for the given client to share between the given authors.
|
||||
*/
|
||||
Group createContactGroup(ClientId clientId, int majorVersion,
|
||||
AuthorId authorId1, AuthorId authorId2);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.briarproject.bramble.api.contact;
|
||||
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.AuthorId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -17,16 +16,14 @@ public class Contact {
|
||||
|
||||
private final ContactId id;
|
||||
private final Author author;
|
||||
private final AuthorId localAuthorId;
|
||||
@Nullable
|
||||
private final String alias;
|
||||
@Nullable
|
||||
private final byte[] handshakePublicKey;
|
||||
private final boolean verified;
|
||||
|
||||
public Contact(ContactId id, Author author, AuthorId localAuthorId,
|
||||
@Nullable String alias, @Nullable byte[] handshakePublicKey,
|
||||
boolean verified) {
|
||||
public Contact(ContactId id, Author author, @Nullable String alias,
|
||||
@Nullable byte[] handshakePublicKey, boolean verified) {
|
||||
if (alias != null) {
|
||||
int aliasLength = toUtf8(alias).length;
|
||||
if (aliasLength == 0 || aliasLength > MAX_AUTHOR_NAME_LENGTH)
|
||||
@@ -38,7 +35,6 @@ public class Contact {
|
||||
}
|
||||
this.id = id;
|
||||
this.author = author;
|
||||
this.localAuthorId = localAuthorId;
|
||||
this.alias = alias;
|
||||
this.handshakePublicKey = handshakePublicKey;
|
||||
this.verified = verified;
|
||||
@@ -52,10 +48,6 @@ public class Contact {
|
||||
return author;
|
||||
}
|
||||
|
||||
public AuthorId getLocalAuthorId() {
|
||||
return localAuthorId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
|
||||
@@ -24,34 +24,31 @@ public interface ContactManager {
|
||||
void registerContactHook(ContactHook hook);
|
||||
|
||||
/**
|
||||
* Stores a contact associated with the given local and remote pseudonyms,
|
||||
* derives and stores transport keys for each transport, and returns an ID
|
||||
* for the contact.
|
||||
* Stores a contact with the given pseudonym, derives and stores transport
|
||||
* keys for each transport, and returns an ID for the contact.
|
||||
*
|
||||
* @param alice true if the local party is Alice
|
||||
*/
|
||||
ContactId addContact(Transaction txn, Author remote, AuthorId local,
|
||||
SecretKey rootKey, long timestamp, boolean alice, boolean verified,
|
||||
boolean active) throws DbException;
|
||||
|
||||
/**
|
||||
* Stores a contact associated with the given local and remote pseudonyms
|
||||
* and returns an ID for the contact.
|
||||
*/
|
||||
ContactId addContact(Transaction txn, Author remote, AuthorId local,
|
||||
boolean verified) throws DbException;
|
||||
|
||||
/**
|
||||
* Stores a contact associated with the given local and remote pseudonyms,
|
||||
* derives and stores transport keys for each transport, and returns an ID
|
||||
* for the contact.
|
||||
*
|
||||
* @param alice true if the local party is Alice
|
||||
*/
|
||||
ContactId addContact(Author remote, AuthorId local, SecretKey rootKey,
|
||||
ContactId addContact(Transaction txn, Author a, SecretKey rootKey,
|
||||
long timestamp, boolean alice, boolean verified, boolean active)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Stores a contact with the given pseudonym and returns an ID for the
|
||||
* contact.
|
||||
*/
|
||||
ContactId addContact(Transaction txn, Author a, boolean verified)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Stores a contact with the given pseudonym, derives and stores transport
|
||||
* keys for each transport, and returns an ID for the contact.
|
||||
*
|
||||
* @param alice true if the local party is Alice
|
||||
*/
|
||||
ContactId addContact(Author a, SecretKey rootKey, long timestamp,
|
||||
boolean alice, boolean verified, boolean active) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the static link that needs to be sent to the contact to be added.
|
||||
*/
|
||||
@@ -88,22 +85,14 @@ public interface ContactManager {
|
||||
Contact getContact(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the contact with the given remoteAuthorId
|
||||
* that was added by the LocalAuthor with the given localAuthorId
|
||||
*
|
||||
* @throws org.briarproject.bramble.api.db.NoSuchContactException
|
||||
* Returns the contact with the given ID.
|
||||
*/
|
||||
Contact getContact(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
||||
throws DbException;
|
||||
Contact getContact(AuthorId a) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the contact with the given remoteAuthorId
|
||||
* that was added by the LocalAuthor with the given localAuthorId
|
||||
*
|
||||
* @throws org.briarproject.bramble.api.db.NoSuchContactException
|
||||
* Returns the contact with the given ID.
|
||||
*/
|
||||
Contact getContact(Transaction txn, AuthorId remoteAuthorId,
|
||||
AuthorId localAuthorId) throws DbException;
|
||||
Contact getContact(Transaction txn, AuthorId a) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all active contacts.
|
||||
@@ -133,16 +122,14 @@ public interface ContactManager {
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Return true if a contact with this name and public key already exists
|
||||
* Returns true if a contact with this pseudonym already exists.
|
||||
*/
|
||||
boolean contactExists(Transaction txn, AuthorId remoteAuthorId,
|
||||
AuthorId localAuthorId) throws DbException;
|
||||
boolean contactExists(Transaction txn, AuthorId a) throws DbException;
|
||||
|
||||
/**
|
||||
* Return true if a contact with this name and public key already exists
|
||||
* Returns true if a contact with this pseudonym already exists.
|
||||
*/
|
||||
boolean contactExists(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
||||
throws DbException;
|
||||
boolean contactExists(AuthorId a) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the {@link AuthorInfo} for the given author.
|
||||
|
||||
@@ -102,11 +102,11 @@ public interface DatabaseComponent {
|
||||
NullableDbCallable<R, E> task) throws DbException, E;
|
||||
|
||||
/**
|
||||
* Stores a contact associated with the given local and remote pseudonyms,
|
||||
* and returns an ID for the contact.
|
||||
* Stores a contact with the given pseudonym and returns an ID for the
|
||||
* contact.
|
||||
*/
|
||||
ContactId addContact(Transaction txn, Author remote, AuthorId local,
|
||||
boolean verified) throws DbException;
|
||||
ContactId addContact(Transaction txn, Author a, boolean verified)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Stores a group.
|
||||
@@ -158,13 +158,11 @@ public interface DatabaseComponent {
|
||||
TransportKeys k) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns true if the database contains the given contact for the given
|
||||
* local pseudonym.
|
||||
* Returns true if the database contains the given contact.
|
||||
* <p/>
|
||||
* Read-only.
|
||||
*/
|
||||
boolean containsContact(Transaction txn, AuthorId remote, AuthorId local)
|
||||
throws DbException;
|
||||
boolean containsContact(Transaction txn, AuthorId a) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns true if the database contains the given group.
|
||||
@@ -254,6 +252,13 @@ public interface DatabaseComponent {
|
||||
*/
|
||||
Contact getContact(Transaction txn, ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the contact with the given author ID.
|
||||
* <p/>
|
||||
* Read-only.
|
||||
*/
|
||||
Contact getContact(Transaction txn, AuthorId a) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all contacts.
|
||||
* <p/>
|
||||
@@ -261,22 +266,6 @@ public interface DatabaseComponent {
|
||||
*/
|
||||
Collection<Contact> getContacts(Transaction txn) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns a possibly empty collection of contacts with the given author ID.
|
||||
* <p/>
|
||||
* Read-only.
|
||||
*/
|
||||
Collection<Contact> getContactsByAuthorId(Transaction txn, AuthorId remote)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all contacts associated with the given local pseudonym.
|
||||
* <p/>
|
||||
* Read-only.
|
||||
*/
|
||||
Collection<ContactId> getContacts(Transaction txn, AuthorId a)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the group with the given ID.
|
||||
* <p/>
|
||||
|
||||
@@ -163,19 +163,15 @@ public class TestUtils {
|
||||
}
|
||||
|
||||
public static Contact getContact() {
|
||||
return getContact(getAuthor(), new AuthorId(getRandomId()),
|
||||
random.nextBoolean());
|
||||
return getContact(getAuthor(), random.nextBoolean());
|
||||
}
|
||||
|
||||
public static Contact getContact(Author remote, AuthorId local,
|
||||
boolean verified) {
|
||||
return getContact(getContactId(), remote, local, verified);
|
||||
public static Contact getContact(Author a, boolean verified) {
|
||||
return getContact(getContactId(), a, verified);
|
||||
}
|
||||
|
||||
public static Contact getContact(ContactId c, Author remote, AuthorId local,
|
||||
boolean verified) {
|
||||
return new Contact(c, remote, local,
|
||||
getRandomString(MAX_AUTHOR_NAME_LENGTH),
|
||||
public static Contact getContact(ContactId c, Author a, boolean verified) {
|
||||
return new Contact(c, a, getRandomString(MAX_AUTHOR_NAME_LENGTH),
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH), verified);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user