Add methods for adding unbound keys.

This commit is contained in:
akwizgran
2018-03-27 15:47:01 +01:00
parent 78f2d48bc4
commit bb2f94d5eb
7 changed files with 104 additions and 10 deletions

View File

@@ -50,7 +50,7 @@ class ContactManagerImpl implements ContactManager {
@Override
public ContactId addContact(Transaction txn, Author remote, AuthorId local,
SecretKey master,long timestamp, boolean alice, boolean verified,
SecretKey master, long timestamp, boolean alice, boolean verified,
boolean active) throws DbException {
ContactId c = db.addContact(txn, remote, local, verified, active);
keyManager.addContact(txn, c, master, timestamp, alice);

View File

@@ -104,6 +104,13 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
m.addContact(txn, c, master, timestamp, alice);
}
@Override
public void addUnboundKeys(Transaction txn, SecretKey master,
long timestamp, boolean alice) throws DbException {
for (TransportKeyManager m : managers.values())
m.addUnboundKeys(txn, master, timestamp, alice);
}
@Override
public StreamContext getStreamContext(ContactId c, TransportId t)
throws DbException {

View File

@@ -17,6 +17,9 @@ interface TransportKeyManager {
void addContact(Transaction txn, ContactId c, SecretKey master,
long timestamp, boolean alice) throws DbException;
void addUnboundKeys(Transaction txn, SecretKey master, long timestamp,
boolean alice) throws DbException;
void removeContact(ContactId c);
@Nullable

View File

@@ -172,6 +172,18 @@ class TransportKeyManagerImpl implements TransportKeyManager {
@Override
public void addContact(Transaction txn, ContactId c, SecretKey master,
long timestamp, boolean alice) throws DbException {
deriveAndAddKeys(txn, c, master, timestamp, alice);
}
@Override
public void addUnboundKeys(Transaction txn, SecretKey master,
long timestamp, boolean alice) throws DbException {
deriveAndAddKeys(txn, null, master, timestamp, alice);
}
private void deriveAndAddKeys(Transaction txn, @Nullable ContactId c,
SecretKey master, long timestamp, boolean alice)
throws DbException {
lock.lock();
try {
// Work out what rotation period the timestamp belongs to