mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Some variables were still referring to TagRecogniser by its old name.
This commit is contained in:
@@ -46,7 +46,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
private final CryptoComponent crypto;
|
||||
private final DatabaseComponent db;
|
||||
private final EventBus eventBus;
|
||||
private final TagRecogniser connectionRecogniser;
|
||||
private final TagRecogniser tagRecogniser;
|
||||
private final Clock clock;
|
||||
private final Timer timer;
|
||||
|
||||
@@ -58,12 +58,12 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
|
||||
@Inject
|
||||
KeyManagerImpl(CryptoComponent crypto, DatabaseComponent db,
|
||||
EventBus eventBus, TagRecogniser connectionRecogniser,
|
||||
Clock clock, Timer timer) {
|
||||
EventBus eventBus, TagRecogniser tagRecogniser, Clock clock,
|
||||
Timer timer) {
|
||||
this.crypto = crypto;
|
||||
this.db = db;
|
||||
this.eventBus = eventBus;
|
||||
this.connectionRecogniser = connectionRecogniser;
|
||||
this.tagRecogniser = tagRecogniser;
|
||||
this.clock = clock;
|
||||
this.timer = timer;
|
||||
maxLatencies = new HashMap<TransportId, Long>();
|
||||
@@ -99,11 +99,11 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
}
|
||||
// Pass the old, current and new secrets to the recogniser
|
||||
for(TemporarySecret s : oldSecrets.values())
|
||||
connectionRecogniser.addSecret(s);
|
||||
tagRecogniser.addSecret(s);
|
||||
for(TemporarySecret s : currentSecrets.values())
|
||||
connectionRecogniser.addSecret(s);
|
||||
tagRecogniser.addSecret(s);
|
||||
for(TemporarySecret s : newSecrets.values())
|
||||
connectionRecogniser.addSecret(s);
|
||||
tagRecogniser.addSecret(s);
|
||||
// Schedule periodic key rotation
|
||||
timer.scheduleAtFixedRate(this, MS_BETWEEN_CHECKS, MS_BETWEEN_CHECKS);
|
||||
return true;
|
||||
@@ -218,7 +218,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
public synchronized boolean stop() {
|
||||
eventBus.removeListener(this);
|
||||
timer.cancel();
|
||||
connectionRecogniser.removeSecrets();
|
||||
tagRecogniser.removeSecrets();
|
||||
maxLatencies.clear();
|
||||
removeAndEraseSecrets(oldSecrets);
|
||||
removeAndEraseSecrets(currentSecrets);
|
||||
@@ -288,9 +288,9 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
return;
|
||||
}
|
||||
// Pass the new secrets to the recogniser
|
||||
connectionRecogniser.addSecret(s1);
|
||||
connectionRecogniser.addSecret(s2);
|
||||
connectionRecogniser.addSecret(s3);
|
||||
tagRecogniser.addSecret(s1);
|
||||
tagRecogniser.addSecret(s2);
|
||||
tagRecogniser.addSecret(s3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -311,7 +311,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
ContactId c = s.getContactId();
|
||||
TransportId t = s.getTransportId();
|
||||
long period = s.getPeriod();
|
||||
connectionRecogniser.removeSecret(c, t, period);
|
||||
tagRecogniser.removeSecret(c, t, period);
|
||||
}
|
||||
// Replace any dead secrets
|
||||
Collection<TemporarySecret> created = replaceDeadSecrets(now, dead);
|
||||
@@ -323,7 +323,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
// Pass any secrets that have been created to the recogniser
|
||||
for(TemporarySecret s : created) connectionRecogniser.addSecret(s);
|
||||
for(TemporarySecret s : created) tagRecogniser.addSecret(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
@Override
|
||||
public void run() {
|
||||
ContactId c = event.getContactId();
|
||||
connectionRecogniser.removeSecrets(c);
|
||||
tagRecogniser.removeSecrets(c);
|
||||
synchronized(KeyManagerImpl.this) {
|
||||
removeAndEraseSecrets(c, oldSecrets);
|
||||
removeAndEraseSecrets(c, currentSecrets);
|
||||
@@ -442,7 +442,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
@Override
|
||||
public void run() {
|
||||
TransportId t = event.getTransportId();
|
||||
connectionRecogniser.removeSecrets(t);
|
||||
tagRecogniser.removeSecrets(t);
|
||||
synchronized(KeyManagerImpl.this) {
|
||||
maxLatencies.remove(t);
|
||||
removeAndEraseSecrets(t, oldSecrets);
|
||||
|
||||
@@ -58,13 +58,12 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
final EventBus eventBus = context.mock(EventBus.class);
|
||||
final TagRecogniser connectionRecogniser =
|
||||
context.mock(TagRecogniser.class);
|
||||
final TagRecogniser tagRecogniser = context.mock(TagRecogniser.class);
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
final Timer timer = context.mock(Timer.class);
|
||||
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
// start()
|
||||
@@ -80,7 +79,7 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
// stop()
|
||||
oneOf(eventBus).removeListener(with(any(EventListener.class)));
|
||||
oneOf(timer).cancel();
|
||||
oneOf(connectionRecogniser).removeSecrets();
|
||||
oneOf(tagRecogniser).removeSecrets();
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
@@ -95,13 +94,12 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
final EventBus eventBus = context.mock(EventBus.class);
|
||||
final TagRecogniser connectionRecogniser =
|
||||
context.mock(TagRecogniser.class);
|
||||
final TagRecogniser tagRecogniser = context.mock(TagRecogniser.class);
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
final Timer timer = context.mock(Timer.class);
|
||||
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The secrets for periods 0 - 2 should be derived
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -132,13 +130,13 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
will(returnValue(secret2.clone()));
|
||||
oneOf(db).addSecrets(Arrays.asList(s0, s1, s2));
|
||||
// The secrets for periods 0 - 2 should be added to the recogniser
|
||||
oneOf(connectionRecogniser).addSecret(s0);
|
||||
oneOf(connectionRecogniser).addSecret(s1);
|
||||
oneOf(connectionRecogniser).addSecret(s2);
|
||||
oneOf(tagRecogniser).addSecret(s0);
|
||||
oneOf(tagRecogniser).addSecret(s1);
|
||||
oneOf(tagRecogniser).addSecret(s2);
|
||||
// stop()
|
||||
oneOf(eventBus).removeListener(with(any(EventListener.class)));
|
||||
oneOf(timer).cancel();
|
||||
oneOf(connectionRecogniser).removeSecrets();
|
||||
oneOf(tagRecogniser).removeSecrets();
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
@@ -154,13 +152,12 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
final EventBus eventBus = context.mock(EventBus.class);
|
||||
final TagRecogniser connectionRecogniser =
|
||||
context.mock(TagRecogniser.class);
|
||||
final TagRecogniser tagRecogniser = context.mock(TagRecogniser.class);
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
final Timer timer = context.mock(Timer.class);
|
||||
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The secrets for periods 0 - 2 should be derived
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -191,16 +188,16 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
will(returnValue(secret2.clone()));
|
||||
oneOf(db).addSecrets(Arrays.asList(s0, s1, s2));
|
||||
// The secrets for periods 0 - 2 should be added to the recogniser
|
||||
oneOf(connectionRecogniser).addSecret(s0);
|
||||
oneOf(connectionRecogniser).addSecret(s1);
|
||||
oneOf(connectionRecogniser).addSecret(s2);
|
||||
oneOf(tagRecogniser).addSecret(s0);
|
||||
oneOf(tagRecogniser).addSecret(s1);
|
||||
oneOf(tagRecogniser).addSecret(s2);
|
||||
// getConnectionContext()
|
||||
oneOf(db).incrementStreamCounter(contactId, transportId, 1);
|
||||
will(returnValue(0L));
|
||||
// stop()
|
||||
oneOf(eventBus).removeListener(with(any(EventListener.class)));
|
||||
oneOf(timer).cancel();
|
||||
oneOf(connectionRecogniser).removeSecrets();
|
||||
oneOf(tagRecogniser).removeSecrets();
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
@@ -224,13 +221,12 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
final EventBus eventBus = context.mock(EventBus.class);
|
||||
final TagRecogniser connectionRecogniser =
|
||||
context.mock(TagRecogniser.class);
|
||||
final TagRecogniser tagRecogniser = context.mock(TagRecogniser.class);
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
final Timer timer = context.mock(Timer.class);
|
||||
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The DB contains the secrets for periods 0 - 2
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -250,15 +246,15 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
oneOf(clock).currentTimeMillis();
|
||||
will(returnValue(EPOCH));
|
||||
// The secrets for periods 0 - 2 should be added to the recogniser
|
||||
oneOf(connectionRecogniser).addSecret(s0);
|
||||
oneOf(connectionRecogniser).addSecret(s1);
|
||||
oneOf(connectionRecogniser).addSecret(s2);
|
||||
oneOf(tagRecogniser).addSecret(s0);
|
||||
oneOf(tagRecogniser).addSecret(s1);
|
||||
oneOf(tagRecogniser).addSecret(s2);
|
||||
oneOf(timer).scheduleAtFixedRate(with(keyManager),
|
||||
with(any(long.class)), with(any(long.class)));
|
||||
// stop()
|
||||
oneOf(eventBus).removeListener(with(any(EventListener.class)));
|
||||
oneOf(timer).cancel();
|
||||
oneOf(connectionRecogniser).removeSecrets();
|
||||
oneOf(tagRecogniser).removeSecrets();
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
@@ -273,13 +269,12 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
final EventBus eventBus = context.mock(EventBus.class);
|
||||
final TagRecogniser connectionRecogniser =
|
||||
context.mock(TagRecogniser.class);
|
||||
final TagRecogniser tagRecogniser = context.mock(TagRecogniser.class);
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
final Timer timer = context.mock(Timer.class);
|
||||
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The DB contains the secrets for periods 0 - 2
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -309,15 +304,15 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
will(returnValue(secret3.clone()));
|
||||
oneOf(db).addSecrets(Arrays.asList(s3));
|
||||
// The secrets for periods 1 - 3 should be added to the recogniser
|
||||
oneOf(connectionRecogniser).addSecret(s1);
|
||||
oneOf(connectionRecogniser).addSecret(s2);
|
||||
oneOf(connectionRecogniser).addSecret(s3);
|
||||
oneOf(tagRecogniser).addSecret(s1);
|
||||
oneOf(tagRecogniser).addSecret(s2);
|
||||
oneOf(tagRecogniser).addSecret(s3);
|
||||
oneOf(timer).scheduleAtFixedRate(with(keyManager),
|
||||
with(any(long.class)), with(any(long.class)));
|
||||
// stop()
|
||||
oneOf(eventBus).removeListener(with(any(EventListener.class)));
|
||||
oneOf(timer).cancel();
|
||||
oneOf(connectionRecogniser).removeSecrets();
|
||||
oneOf(tagRecogniser).removeSecrets();
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
@@ -332,13 +327,12 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
final EventBus eventBus = context.mock(EventBus.class);
|
||||
final TagRecogniser connectionRecogniser =
|
||||
context.mock(TagRecogniser.class);
|
||||
final TagRecogniser tagRecogniser = context.mock(TagRecogniser.class);
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
final Timer timer = context.mock(Timer.class);
|
||||
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The DB contains the secrets for periods 0 - 2
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -370,15 +364,15 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
// The new secrets should be stored
|
||||
oneOf(db).addSecrets(Arrays.asList(s3, s4));
|
||||
// The secrets for periods 2 - 4 should be added to the recogniser
|
||||
oneOf(connectionRecogniser).addSecret(s2);
|
||||
oneOf(connectionRecogniser).addSecret(s3);
|
||||
oneOf(connectionRecogniser).addSecret(s4);
|
||||
oneOf(tagRecogniser).addSecret(s2);
|
||||
oneOf(tagRecogniser).addSecret(s3);
|
||||
oneOf(tagRecogniser).addSecret(s4);
|
||||
oneOf(timer).scheduleAtFixedRate(with(keyManager),
|
||||
with(any(long.class)), with(any(long.class)));
|
||||
// stop()
|
||||
oneOf(eventBus).removeListener(with(any(EventListener.class)));
|
||||
oneOf(timer).cancel();
|
||||
oneOf(connectionRecogniser).removeSecrets();
|
||||
oneOf(tagRecogniser).removeSecrets();
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
@@ -393,13 +387,12 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
final EventBus eventBus = context.mock(EventBus.class);
|
||||
final TagRecogniser connectionRecogniser =
|
||||
context.mock(TagRecogniser.class);
|
||||
final TagRecogniser tagRecogniser = context.mock(TagRecogniser.class);
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
final Timer timer = context.mock(Timer.class);
|
||||
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The DB contains the secrets for periods 0 - 2
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -419,9 +412,9 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
oneOf(clock).currentTimeMillis();
|
||||
will(returnValue(EPOCH));
|
||||
// The secrets for periods 0 - 2 should be added to the recogniser
|
||||
oneOf(connectionRecogniser).addSecret(s0);
|
||||
oneOf(connectionRecogniser).addSecret(s1);
|
||||
oneOf(connectionRecogniser).addSecret(s2);
|
||||
oneOf(tagRecogniser).addSecret(s0);
|
||||
oneOf(tagRecogniser).addSecret(s1);
|
||||
oneOf(tagRecogniser).addSecret(s2);
|
||||
oneOf(timer).scheduleAtFixedRate(with(keyManager),
|
||||
with(any(long.class)), with(any(long.class)));
|
||||
// run() during period 1: the secrets should not be affected
|
||||
@@ -433,7 +426,7 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
// stop()
|
||||
oneOf(eventBus).removeListener(with(any(EventListener.class)));
|
||||
oneOf(timer).cancel();
|
||||
oneOf(connectionRecogniser).removeSecrets();
|
||||
oneOf(tagRecogniser).removeSecrets();
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
@@ -457,13 +450,12 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
final EventBus eventBus = context.mock(EventBus.class);
|
||||
final TagRecogniser connectionRecogniser =
|
||||
context.mock(TagRecogniser.class);
|
||||
final TagRecogniser tagRecogniser = context.mock(TagRecogniser.class);
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
final Timer timer = context.mock(Timer.class);
|
||||
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The DB contains the secrets for periods 0 - 2
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -485,9 +477,9 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
oneOf(clock).currentTimeMillis();
|
||||
will(returnValue(EPOCH));
|
||||
// The secrets for periods 0 - 2 should be added to the recogniser
|
||||
oneOf(connectionRecogniser).addSecret(s0);
|
||||
oneOf(connectionRecogniser).addSecret(s1);
|
||||
oneOf(connectionRecogniser).addSecret(s2);
|
||||
oneOf(tagRecogniser).addSecret(s0);
|
||||
oneOf(tagRecogniser).addSecret(s1);
|
||||
oneOf(tagRecogniser).addSecret(s2);
|
||||
oneOf(timer).scheduleAtFixedRate(with(keyManager),
|
||||
with(any(long.class)), with(any(long.class)));
|
||||
// run() during period 2: the secrets should be rotated
|
||||
@@ -499,16 +491,16 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
will(returnValue(secret2.clone()));
|
||||
oneOf(crypto).deriveNextSecret(secret2, 3);
|
||||
will(returnValue(secret3.clone()));
|
||||
oneOf(connectionRecogniser).removeSecret(contactId, transportId, 0);
|
||||
oneOf(tagRecogniser).removeSecret(contactId, transportId, 0);
|
||||
oneOf(db).addSecrets(Arrays.asList(s3));
|
||||
oneOf(connectionRecogniser).addSecret(s3);
|
||||
oneOf(tagRecogniser).addSecret(s3);
|
||||
// getConnectionContext()
|
||||
oneOf(db).incrementStreamCounter(contactId, transportId, 2);
|
||||
will(returnValue(0L));
|
||||
// stop()
|
||||
oneOf(eventBus).removeListener(with(any(EventListener.class)));
|
||||
oneOf(timer).cancel();
|
||||
oneOf(connectionRecogniser).removeSecrets();
|
||||
oneOf(tagRecogniser).removeSecrets();
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
@@ -532,13 +524,12 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
final EventBus eventBus = context.mock(EventBus.class);
|
||||
final TagRecogniser connectionRecogniser =
|
||||
context.mock(TagRecogniser.class);
|
||||
final TagRecogniser tagRecogniser = context.mock(TagRecogniser.class);
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
final Timer timer = context.mock(Timer.class);
|
||||
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The DB contains the secrets for periods 0 - 2
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -561,9 +552,9 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
oneOf(clock).currentTimeMillis();
|
||||
will(returnValue(EPOCH));
|
||||
// The secrets for periods 0 - 2 should be added to the recogniser
|
||||
oneOf(connectionRecogniser).addSecret(s0);
|
||||
oneOf(connectionRecogniser).addSecret(s1);
|
||||
oneOf(connectionRecogniser).addSecret(s2);
|
||||
oneOf(tagRecogniser).addSecret(s0);
|
||||
oneOf(tagRecogniser).addSecret(s1);
|
||||
oneOf(tagRecogniser).addSecret(s2);
|
||||
oneOf(timer).scheduleAtFixedRate(with(keyManager),
|
||||
with(any(long.class)), with(any(long.class)));
|
||||
// run() during period 3 (late): the secrets should be rotated
|
||||
@@ -575,18 +566,18 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
will(returnValue(secret3.clone()));
|
||||
oneOf(crypto).deriveNextSecret(secret3, 4);
|
||||
will(returnValue(secret4.clone()));
|
||||
oneOf(connectionRecogniser).removeSecret(contactId, transportId, 0);
|
||||
oneOf(connectionRecogniser).removeSecret(contactId, transportId, 1);
|
||||
oneOf(tagRecogniser).removeSecret(contactId, transportId, 0);
|
||||
oneOf(tagRecogniser).removeSecret(contactId, transportId, 1);
|
||||
oneOf(db).addSecrets(Arrays.asList(s3, s4));
|
||||
oneOf(connectionRecogniser).addSecret(s3);
|
||||
oneOf(connectionRecogniser).addSecret(s4);
|
||||
oneOf(tagRecogniser).addSecret(s3);
|
||||
oneOf(tagRecogniser).addSecret(s4);
|
||||
// getConnectionContext()
|
||||
oneOf(db).incrementStreamCounter(contactId, transportId, 3);
|
||||
will(returnValue(0L));
|
||||
// stop()
|
||||
oneOf(eventBus).removeListener(with(any(EventListener.class)));
|
||||
oneOf(timer).cancel();
|
||||
oneOf(connectionRecogniser).removeSecrets();
|
||||
oneOf(tagRecogniser).removeSecrets();
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
|
||||
@@ -78,10 +78,9 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
final Timer timer = context.mock(Timer.class);
|
||||
|
||||
final TagRecogniser connectionRecogniser =
|
||||
new TagRecogniserImpl(crypto, db);
|
||||
final TagRecogniser tagRecogniser = new TagRecogniserImpl(crypto, db);
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
// start()
|
||||
@@ -117,10 +116,9 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
final SecretKey k1 = context.mock(SecretKey.class, "k1");
|
||||
final SecretKey k2 = context.mock(SecretKey.class, "k2");
|
||||
|
||||
final TagRecogniser connectionRecogniser =
|
||||
new TagRecogniserImpl(crypto, db);
|
||||
final TagRecogniser tagRecogniser = new TagRecogniserImpl(crypto, db);
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The secrets for periods 0 - 2 should be derived
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -241,10 +239,9 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
final SecretKey k1 = context.mock(SecretKey.class, "k1");
|
||||
final SecretKey k2 = context.mock(SecretKey.class, "k2");
|
||||
|
||||
final TagRecogniser connectionRecogniser =
|
||||
new TagRecogniserImpl(crypto, db);
|
||||
final TagRecogniser tagRecogniser = new TagRecogniserImpl(crypto, db);
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The secrets for periods 0 - 2 should be derived
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -376,8 +373,7 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
final SecretKey k1 = context.mock(SecretKey.class, "k1");
|
||||
final SecretKey k2 = context.mock(SecretKey.class, "k2");
|
||||
|
||||
final TagRecogniser tagRecogniser =
|
||||
new TagRecogniserImpl(crypto, db);
|
||||
final TagRecogniser tagRecogniser = new TagRecogniserImpl(crypto, db);
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
@@ -521,10 +517,9 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
final SecretKey k1 = context.mock(SecretKey.class, "k1");
|
||||
final SecretKey k2 = context.mock(SecretKey.class, "k2");
|
||||
|
||||
final TagRecogniser connectionRecogniser =
|
||||
new TagRecogniserImpl(crypto, db);
|
||||
final TagRecogniser tagRecogniser = new TagRecogniserImpl(crypto, db);
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The DB contains the secrets for periods 0 - 2
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -636,10 +631,9 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
final SecretKey k2 = context.mock(SecretKey.class, "k2");
|
||||
final SecretKey k3 = context.mock(SecretKey.class, "k3");
|
||||
|
||||
final TagRecogniser connectionRecogniser =
|
||||
new TagRecogniserImpl(crypto, db);
|
||||
final TagRecogniser tagRecogniser = new TagRecogniserImpl(crypto, db);
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The DB contains the secrets for periods 0 - 2
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
@@ -761,10 +755,9 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
final SecretKey k3 = context.mock(SecretKey.class, "k3");
|
||||
final SecretKey k4 = context.mock(SecretKey.class, "k4");
|
||||
|
||||
final TagRecogniser connectionRecogniser =
|
||||
new TagRecogniserImpl(crypto, db);
|
||||
final TagRecogniser tagRecogniser = new TagRecogniserImpl(crypto, db);
|
||||
final KeyManagerImpl keyManager = new KeyManagerImpl(crypto, db,
|
||||
eventBus, connectionRecogniser, clock, timer);
|
||||
eventBus, tagRecogniser, clock, timer);
|
||||
|
||||
// The DB contains the secrets for periods 0 - 2
|
||||
Endpoint ep = new Endpoint(contactId, transportId, EPOCH, true);
|
||||
|
||||
Reference in New Issue
Block a user