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