mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Use namespaced strings for client IDs
This commit is contained in:
@@ -27,13 +27,11 @@ import org.briarproject.api.identity.Author.Status;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.identity.IdentityManager;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.clients.BdfIncomingMessageHook;
|
||||
import org.briarproject.util.StringUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
@@ -74,10 +72,6 @@ import static org.briarproject.blogs.BlogPostValidator.authorToBdfDictionary;
|
||||
class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
AddContactHook, RemoveContactHook, Client {
|
||||
|
||||
static final ClientId CLIENT_ID = new ClientId(StringUtils.fromHexString(
|
||||
"dafbe56f0c8971365cea4bb5f08ec9a6" +
|
||||
"1d686e058b943997b6ff259ba423f613"));
|
||||
|
||||
private final IdentityManager identityManager;
|
||||
private final ContactManager contactManager;
|
||||
private final BlogFactory blogFactory;
|
||||
@@ -98,11 +92,6 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
removeHooks = new CopyOnWriteArrayList<RemoveBlogHook>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientId getClientId() {
|
||||
return CLIENT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLocalState(Transaction txn) throws DbException {
|
||||
// Ensure that the local identity has its own personal blog
|
||||
|
||||
@@ -67,8 +67,8 @@ import static org.briarproject.db.ExponentialBackoff.calculateExpiry;
|
||||
*/
|
||||
abstract class JdbcDatabase implements Database<Connection> {
|
||||
|
||||
private static final int SCHEMA_VERSION = 27;
|
||||
private static final int MIN_SCHEMA_VERSION = 27;
|
||||
private static final int SCHEMA_VERSION = 28;
|
||||
private static final int MIN_SCHEMA_VERSION = 28;
|
||||
|
||||
private static final String CREATE_SETTINGS =
|
||||
"CREATE TABLE settings"
|
||||
@@ -103,7 +103,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
private static final String CREATE_GROUPS =
|
||||
"CREATE TABLE groups"
|
||||
+ " (groupId HASH NOT NULL,"
|
||||
+ " clientId HASH NOT NULL,"
|
||||
+ " clientId VARCHAR NOT NULL,"
|
||||
+ " descriptor BINARY NOT NULL,"
|
||||
+ " PRIMARY KEY (groupId))";
|
||||
|
||||
@@ -504,7 +504,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
+ " VALUES (?, ?, ?)";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setBytes(1, g.getId().getBytes());
|
||||
ps.setBytes(2, g.getClientId().getBytes());
|
||||
ps.setString(2, g.getClientId().getString());
|
||||
ps.setBytes(3, g.getDescriptor());
|
||||
int affected = ps.executeUpdate();
|
||||
if (affected != 1) throw new DbStateException();
|
||||
@@ -1091,7 +1091,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
ps.setBytes(1, g.getBytes());
|
||||
rs = ps.executeQuery();
|
||||
if (!rs.next()) throw new DbStateException();
|
||||
ClientId clientId = new ClientId(rs.getBytes(1));
|
||||
ClientId clientId = new ClientId(rs.getString(1));
|
||||
byte[] descriptor = rs.getBytes(2);
|
||||
rs.close();
|
||||
ps.close();
|
||||
@@ -1111,7 +1111,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
String sql = "SELECT groupId, descriptor FROM groups"
|
||||
+ " WHERE clientId = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setBytes(1, c.getBytes());
|
||||
ps.setString(1, c.getString());
|
||||
rs = ps.executeQuery();
|
||||
List<Group> groups = new ArrayList<Group>();
|
||||
while (rs.next()) {
|
||||
@@ -1678,7 +1678,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
+ " WHERE state = ? AND clientId = ? AND raw IS NOT NULL";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setInt(1, state.getValue());
|
||||
ps.setBytes(2, c.getBytes());
|
||||
ps.setString(2, c.getString());
|
||||
rs = ps.executeQuery();
|
||||
List<MessageId> ids = new ArrayList<MessageId>();
|
||||
while (rs.next()) ids.add(new MessageId(rs.getBytes(1)));
|
||||
@@ -1707,7 +1707,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
+ " WHERE m.shared = FALSE AND m1.shared = TRUE"
|
||||
+ " AND g.clientId = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setBytes(1, c.getBytes());
|
||||
ps.setString(1, c.getString());
|
||||
rs = ps.executeQuery();
|
||||
List<MessageId> ids = new ArrayList<MessageId>();
|
||||
while (rs.next()) ids.add(new MessageId(rs.getBytes(1)));
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.briarproject.api.identity.IdentityManager;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
import org.briarproject.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.api.plugins.TorConstants;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.system.Clock;
|
||||
@@ -73,11 +72,6 @@ class FeedManagerImpl implements FeedManager, Client, EventListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(FeedManagerImpl.class.getName());
|
||||
|
||||
private static final ClientId CLIENT_ID =
|
||||
new ClientId(StringUtils.fromHexString(
|
||||
"466565644d616e6167657202fb797097"
|
||||
+ "255af837abbf8c16e250b3c2ccc286eb"));
|
||||
|
||||
private static final int CONNECT_TIMEOUT = 60 * 1000; // Milliseconds
|
||||
|
||||
private final ScheduledExecutorService feedExecutor;
|
||||
@@ -114,11 +108,6 @@ class FeedManagerImpl implements FeedManager, Client, EventListener {
|
||||
this.torSocketFactory = torSocketFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientId getClientId() {
|
||||
return CLIENT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventOccurred(Event e) {
|
||||
if (e instanceof TransportEnabledEvent) {
|
||||
@@ -510,7 +499,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener {
|
||||
}
|
||||
|
||||
private Group getLocalGroup() {
|
||||
return contactGroupFactory.createLocalGroup(getClientId());
|
||||
return contactGroupFactory.createLocalGroup(CLIENT_ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,13 +20,11 @@ import org.briarproject.api.identity.Author.Status;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.identity.IdentityManager;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.clients.BdfIncomingMessageHook;
|
||||
import org.briarproject.util.StringUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
@@ -56,10 +54,6 @@ import static org.briarproject.clients.BdfConstants.MSG_KEY_READ;
|
||||
|
||||
class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
||||
|
||||
static final ClientId CLIENT_ID = new ClientId(StringUtils.fromHexString(
|
||||
"859a7be50dca035b64bd6902fb797097"
|
||||
+ "795af837abbf8c16d750b3c2ccc186ea"));
|
||||
|
||||
private final IdentityManager identityManager;
|
||||
private final ForumFactory forumFactory;
|
||||
private final ForumPostFactory forumPostFactory;
|
||||
@@ -92,11 +86,6 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientId getClientId() {
|
||||
return CLIENT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Forum addForum(String name) throws DbException {
|
||||
Forum f = forumFactory.createForum(name);
|
||||
|
||||
@@ -32,9 +32,8 @@ public class ForumModule {
|
||||
ForumManager provideForumManager(ForumManagerImpl forumManager,
|
||||
ValidationManager validationManager) {
|
||||
|
||||
validationManager
|
||||
.registerIncomingMessageHook(forumManager.getClientId(),
|
||||
forumManager);
|
||||
validationManager.registerIncomingMessageHook(ForumManager.CLIENT_ID,
|
||||
forumManager);
|
||||
|
||||
return forumManager;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,12 @@ import org.briarproject.api.introduction.IntroductionManager;
|
||||
import org.briarproject.api.introduction.IntroductionMessage;
|
||||
import org.briarproject.api.introduction.IntroductionRequest;
|
||||
import org.briarproject.api.introduction.IntroductionResponse;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.api.sync.MessageStatus;
|
||||
import org.briarproject.clients.ConversationClientImpl;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -79,10 +77,6 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
||||
implements IntroductionManager, Client, AddContactHook,
|
||||
RemoveContactHook {
|
||||
|
||||
static final ClientId CLIENT_ID = new ClientId(StringUtils.fromHexString(
|
||||
"23b1897c198a90ae75b976ac023d0f32"
|
||||
+ "80ca67b12f2346b2c23a34f34e2434c3"));
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(IntroductionManagerImpl.class.getName());
|
||||
|
||||
@@ -102,11 +96,6 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
||||
this.introductionGroupFactory = introductionGroupFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientId getClientId() {
|
||||
return CLIENT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLocalState(Transaction txn) throws DbException {
|
||||
db.addGroup(txn, introductionGroupFactory.createLocalGroup());
|
||||
|
||||
@@ -15,6 +15,7 @@ import javax.inject.Singleton;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import static org.briarproject.api.introduction.IntroductionManager.CLIENT_ID;
|
||||
import static org.briarproject.api.sync.ValidationManager.MessageValidator;
|
||||
|
||||
@Module
|
||||
@@ -28,16 +29,14 @@ public class IntroductionModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
MessageValidator provideValidator(MessageQueueManager messageQueueManager,
|
||||
IntroductionManager introductionManager,
|
||||
MetadataEncoder metadataEncoder, ClientHelper clientHelper,
|
||||
Clock clock) {
|
||||
|
||||
IntroductionValidator introductionValidator = new IntroductionValidator(
|
||||
clientHelper, metadataEncoder, clock);
|
||||
|
||||
messageQueueManager.registerMessageValidator(
|
||||
introductionManager.getClientId(),
|
||||
introductionValidator);
|
||||
messageQueueManager
|
||||
.registerMessageValidator(CLIENT_ID, introductionValidator);
|
||||
|
||||
return introductionValidator;
|
||||
}
|
||||
@@ -54,9 +53,8 @@ public class IntroductionModule {
|
||||
lifecycleManager.registerClient(introductionManager);
|
||||
contactManager.registerAddContactHook(introductionManager);
|
||||
contactManager.registerRemoveContactHook(introductionManager);
|
||||
messageQueueManager.registerIncomingMessageHook(
|
||||
introductionManager.getClientId(),
|
||||
introductionManager);
|
||||
messageQueueManager
|
||||
.registerIncomingMessageHook(CLIENT_ID, introductionManager);
|
||||
conversationManager.registerConversationClient(introductionManager);
|
||||
|
||||
return introductionManager;
|
||||
|
||||
@@ -18,14 +18,12 @@ import org.briarproject.api.event.PrivateMessageReceivedEvent;
|
||||
import org.briarproject.api.messaging.MessagingManager;
|
||||
import org.briarproject.api.messaging.PrivateMessage;
|
||||
import org.briarproject.api.messaging.PrivateMessageHeader;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.api.sync.MessageStatus;
|
||||
import org.briarproject.clients.ConversationClientImpl;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -38,10 +36,6 @@ import static org.briarproject.clients.BdfConstants.MSG_KEY_READ;
|
||||
class MessagingManagerImpl extends ConversationClientImpl
|
||||
implements MessagingManager, Client, AddContactHook, RemoveContactHook {
|
||||
|
||||
static final ClientId CLIENT_ID = new ClientId(StringUtils.fromHexString(
|
||||
"6bcdc006c0910b0f44e40644c3b31f1a"
|
||||
+ "8bf9a6d6021d40d219c86b731b903070"));
|
||||
|
||||
private final ContactGroupFactory contactGroupFactory;
|
||||
|
||||
@Inject
|
||||
@@ -87,11 +81,6 @@ class MessagingManagerImpl extends ConversationClientImpl
|
||||
db.removeGroup(txn, getContactGroup(c));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientId getClientId() {
|
||||
return CLIENT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean incomingMessage(Transaction txn, Message m, BdfList body,
|
||||
BdfDictionary meta) throws DbException, FormatException {
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.briarproject.api.identity.AuthorFactory;
|
||||
import org.briarproject.api.privategroup.MessageType;
|
||||
import org.briarproject.api.privategroup.PrivateGroup;
|
||||
import org.briarproject.api.privategroup.PrivateGroupFactory;
|
||||
import org.briarproject.api.privategroup.invitation.GroupInvitationManager;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.InvalidMessageException;
|
||||
import org.briarproject.api.sync.Message;
|
||||
@@ -30,6 +29,7 @@ import static org.briarproject.api.identity.AuthorConstants.MAX_SIGNATURE_LENGTH
|
||||
import static org.briarproject.api.privategroup.MessageType.JOIN;
|
||||
import static org.briarproject.api.privategroup.MessageType.POST;
|
||||
import static org.briarproject.api.privategroup.PrivateGroupConstants.MAX_GROUP_POST_BODY_LENGTH;
|
||||
import static org.briarproject.api.privategroup.invitation.GroupInvitationManager.CLIENT_ID;
|
||||
import static org.briarproject.privategroup.Constants.KEY_MEMBER_ID;
|
||||
import static org.briarproject.privategroup.Constants.KEY_MEMBER_NAME;
|
||||
import static org.briarproject.privategroup.Constants.KEY_MEMBER_PUBLIC_KEY;
|
||||
@@ -44,18 +44,15 @@ class GroupMessageValidator extends BdfMessageValidator {
|
||||
private final ContactGroupFactory contactGroupFactory;
|
||||
private final PrivateGroupFactory groupFactory;
|
||||
private final AuthorFactory authorFactory;
|
||||
private final GroupInvitationManager groupInvitationManager; // TODO remove
|
||||
|
||||
GroupMessageValidator(ContactGroupFactory contactGroupFactory,
|
||||
PrivateGroupFactory groupFactory,
|
||||
ClientHelper clientHelper, MetadataEncoder metadataEncoder,
|
||||
Clock clock, AuthorFactory authorFactory,
|
||||
GroupInvitationManager groupInvitationManager) {
|
||||
Clock clock, AuthorFactory authorFactory) {
|
||||
super(clientHelper, metadataEncoder, clock);
|
||||
this.contactGroupFactory = contactGroupFactory;
|
||||
this.groupFactory = groupFactory;
|
||||
this.authorFactory = authorFactory;
|
||||
this.groupInvitationManager = groupInvitationManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,8 +122,8 @@ class GroupMessageValidator extends BdfMessageValidator {
|
||||
|
||||
// derive invitation group
|
||||
Group invitationGroup = contactGroupFactory
|
||||
.createContactGroup(groupInvitationManager.getClientId(),
|
||||
pg.getAuthor().getId(), member.getId());
|
||||
.createContactGroup(CLIENT_ID, pg.getAuthor().getId(),
|
||||
member.getId());
|
||||
|
||||
// signature with the creator's private key
|
||||
// over a list with four elements:
|
||||
|
||||
@@ -23,13 +23,11 @@ import org.briarproject.api.privategroup.MessageType;
|
||||
import org.briarproject.api.privategroup.PrivateGroup;
|
||||
import org.briarproject.api.privategroup.PrivateGroupFactory;
|
||||
import org.briarproject.api.privategroup.PrivateGroupManager;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.clients.BdfIncomingMessageHook;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -64,10 +62,6 @@ import static org.briarproject.privategroup.Constants.KEY_TYPE;
|
||||
public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
||||
PrivateGroupManager {
|
||||
|
||||
static final ClientId CLIENT_ID = new ClientId(
|
||||
StringUtils.fromHexString("5072697661746547726f75704d616e61"
|
||||
+ "67657220627920546f727374656e2047"));
|
||||
|
||||
private final PrivateGroupFactory privateGroupFactory;
|
||||
private final IdentityManager identityManager;
|
||||
private final List<PrivateGroupHook> hooks;
|
||||
@@ -84,11 +78,6 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
||||
hooks = new CopyOnWriteArrayList<PrivateGroupHook>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientId getClientId() {
|
||||
return CLIENT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPrivateGroup(PrivateGroup group, GroupMessage joinMsg)
|
||||
throws DbException {
|
||||
@@ -251,7 +240,7 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
||||
Collection<Group> groups;
|
||||
Transaction txn = db.startTransaction(true);
|
||||
try {
|
||||
groups = db.getGroups(txn, getClientId());
|
||||
groups = db.getGroups(txn, CLIENT_ID);
|
||||
db.commitTransaction(txn);
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PrivateGroupModule {
|
||||
ValidationManager validationManager) {
|
||||
|
||||
validationManager
|
||||
.registerIncomingMessageHook(groupManager.getClientId(),
|
||||
.registerIncomingMessageHook(PrivateGroupManager.CLIENT_ID,
|
||||
groupManager);
|
||||
|
||||
return groupManager;
|
||||
@@ -68,9 +68,9 @@ public class PrivateGroupModule {
|
||||
|
||||
GroupMessageValidator validator = new GroupMessageValidator(
|
||||
contactGroupFactory, groupFactory, clientHelper,
|
||||
metadataEncoder, clock, authorFactory, groupInvitationManager);
|
||||
metadataEncoder, clock, authorFactory);
|
||||
validationManager.registerMessageValidator(
|
||||
PrivateGroupManagerImpl.CLIENT_ID, validator);
|
||||
PrivateGroupManager.CLIENT_ID, validator);
|
||||
|
||||
return validator;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class PrivateGroupModule {
|
||||
ValidationManager validationManager) {
|
||||
|
||||
validationManager.registerIncomingMessageHook(
|
||||
groupInvitationManager.getClientId(), groupInvitationManager);
|
||||
GroupInvitationManager.CLIENT_ID, groupInvitationManager);
|
||||
lifecycleManager.registerClient(groupInvitationManager);
|
||||
contactManager.registerAddContactHook(groupInvitationManager);
|
||||
contactManager.registerRemoveContactHook(groupInvitationManager);
|
||||
|
||||
@@ -19,12 +19,10 @@ import org.briarproject.api.privategroup.PrivateGroup;
|
||||
import org.briarproject.api.privategroup.invitation.GroupInvitationItem;
|
||||
import org.briarproject.api.privategroup.invitation.GroupInvitationManager;
|
||||
import org.briarproject.api.sharing.InvitationMessage;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.clients.ConversationClientImpl;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -38,11 +36,6 @@ public class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
ContactManager.AddContactHook, ContactManager.RemoveContactHook,
|
||||
ConversationManager.ConversationClient {
|
||||
|
||||
private static final ClientId CLIENT_ID =
|
||||
new ClientId(StringUtils.fromHexString(
|
||||
"B55231ABFC4A10666CD93D649B1D7F4F"
|
||||
+ "016E65B87BB4C04F4E35613713DBCD13"));
|
||||
|
||||
private final ContactGroupFactory contactGroupFactory;
|
||||
private final Group localGroup;
|
||||
|
||||
@@ -52,12 +45,7 @@ public class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
ContactGroupFactory contactGroupFactory) {
|
||||
super(db, clientHelper, metadataParser);
|
||||
this.contactGroupFactory = contactGroupFactory;
|
||||
localGroup = contactGroupFactory.createLocalGroup(getClientId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientId getClientId() {
|
||||
return CLIENT_ID;
|
||||
localGroup = contactGroupFactory.createLocalGroup(CLIENT_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,7 +82,7 @@ public class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
|
||||
@Override
|
||||
protected Group getContactGroup(Contact c) {
|
||||
return contactGroupFactory.createContactGroup(getClientId(), c);
|
||||
return contactGroupFactory.createContactGroup(CLIENT_ID, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,13 +16,11 @@ import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.properties.TransportProperties;
|
||||
import org.briarproject.api.properties.TransportPropertyManager;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.api.system.Clock;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -34,10 +32,6 @@ import javax.inject.Inject;
|
||||
class TransportPropertyManagerImpl implements TransportPropertyManager,
|
||||
Client, AddContactHook, RemoveContactHook {
|
||||
|
||||
static final ClientId CLIENT_ID = new ClientId(StringUtils.fromHexString(
|
||||
"673ea091673561e28f70122f6a8ea8f4"
|
||||
+ "97c3624b86fa07f785bb15f09fb87b4b"));
|
||||
|
||||
private final DatabaseComponent db;
|
||||
private final ClientHelper clientHelper;
|
||||
private final ContactGroupFactory contactGroupFactory;
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.api.system.Clock;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
@@ -48,10 +47,6 @@ class BlogSharingManagerImpl extends
|
||||
SharingManagerImpl<Blog, BlogInvitation, BlogInviteeSessionState, BlogSharerSessionState, BlogInvitationReceivedEvent, BlogInvitationResponseReceivedEvent>
|
||||
implements BlogSharingManager, RemoveBlogHook {
|
||||
|
||||
static final ClientId CLIENT_ID = new ClientId(StringUtils.fromHexString(
|
||||
"bee438b5de0b3a685badc4e49d76e72d"
|
||||
+ "21e01c4b569a775112756bdae267a028"));
|
||||
|
||||
private final IdentityManager identityManager;
|
||||
private final BlogManager blogManager;
|
||||
|
||||
@@ -84,7 +79,7 @@ class BlogSharingManagerImpl extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientId getClientId() {
|
||||
protected ClientId getClientId() {
|
||||
return CLIENT_ID;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.api.system.Clock;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
@@ -42,10 +41,6 @@ class ForumSharingManagerImpl extends
|
||||
SharingManagerImpl<Forum, ForumInvitation, ForumInviteeSessionState, ForumSharerSessionState, ForumInvitationReceivedEvent, ForumInvitationResponseReceivedEvent>
|
||||
implements ForumSharingManager, ForumManager.RemoveForumHook {
|
||||
|
||||
static final ClientId CLIENT_ID = new ClientId(StringUtils.fromHexString(
|
||||
"cd11a5d04dccd9e2931d6fc3df456313"
|
||||
+ "63bb3e9d9d0e9405fccdb051f41f5449"));
|
||||
|
||||
private final SFactory sFactory;
|
||||
private final IFactory iFactory;
|
||||
private final ISFactory isFactory;
|
||||
@@ -75,7 +70,7 @@ class ForumSharingManagerImpl extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientId getClientId() {
|
||||
protected ClientId getClientId() {
|
||||
return CLIENT_ID;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,11 @@ import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.event.InvitationRequestReceivedEvent;
|
||||
import org.briarproject.api.event.InvitationResponseReceivedEvent;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
import org.briarproject.api.sharing.SharingInvitationItem;
|
||||
import org.briarproject.api.sharing.InvitationMessage;
|
||||
import org.briarproject.api.sharing.Shareable;
|
||||
import org.briarproject.api.sharing.SharingInvitationItem;
|
||||
import org.briarproject.api.sharing.SharingManager;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
@@ -115,6 +116,8 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
localGroup = contactGroupFactory.createLocalGroup(getClientId());
|
||||
}
|
||||
|
||||
protected abstract ClientId getClientId();
|
||||
|
||||
protected abstract InvitationMessage createInvitationRequest(MessageId id,
|
||||
I msg, ContactId contactId, boolean available, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read);
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupFactory;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -18,7 +19,9 @@ class GroupFactoryImpl implements GroupFactory {
|
||||
}
|
||||
|
||||
public Group createGroup(ClientId c, byte[] descriptor) {
|
||||
byte[] hash = crypto.hash(GroupId.LABEL, c.getBytes(), descriptor);
|
||||
byte[] hash =
|
||||
crypto.hash(GroupId.LABEL, StringUtils.toUtf8(c.getString()),
|
||||
descriptor);
|
||||
return new Group(new GroupId(hash), c, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user