Renamed an inner class.

This commit is contained in:
akwizgran
2012-11-01 18:48:08 +00:00
parent 38ed9d69bf
commit c0c6af7a86

View File

@@ -26,7 +26,7 @@ class TransportConnectionRecogniser {
private final CryptoComponent crypto; private final CryptoComponent crypto;
private final DatabaseComponent db; private final DatabaseComponent db;
private final TransportId transportId; private final TransportId transportId;
private final Map<Bytes, WindowContext> tagMap; // Locking: this private final Map<Bytes, TagContext> tagMap; // Locking: this
private final Map<RemovalKey, RemovalContext> removalMap; // Locking: this private final Map<RemovalKey, RemovalContext> removalMap; // Locking: this
TransportConnectionRecogniser(CryptoComponent crypto, DatabaseComponent db, TransportConnectionRecogniser(CryptoComponent crypto, DatabaseComponent db,
@@ -34,17 +34,17 @@ class TransportConnectionRecogniser {
this.crypto = crypto; this.crypto = crypto;
this.db = db; this.db = db;
this.transportId = transportId; this.transportId = transportId;
tagMap = new HashMap<Bytes, WindowContext>(); tagMap = new HashMap<Bytes, TagContext>();
removalMap = new HashMap<RemovalKey, RemovalContext>(); removalMap = new HashMap<RemovalKey, RemovalContext>();
} }
synchronized ConnectionContext acceptConnection(byte[] tag) synchronized ConnectionContext acceptConnection(byte[] tag)
throws DbException { throws DbException {
WindowContext wctx = tagMap.remove(new Bytes(tag)); TagContext tctx = tagMap.remove(new Bytes(tag));
if(wctx == null) return null; // The tag was not expected if(tctx == null) return null; // The tag was not expected
ConnectionWindow window = wctx.window; ConnectionWindow window = tctx.window;
ConnectionContext ctx = wctx.context; ConnectionContext ctx = tctx.context;
long period = wctx.period; long period = tctx.period;
ContactId contactId = ctx.getContactId(); ContactId contactId = ctx.getContactId();
byte[] secret = ctx.getSecret(); byte[] secret = ctx.getSecret();
long connection = ctx.getConnectionNumber(); long connection = ctx.getConnectionNumber();
@@ -56,14 +56,14 @@ class TransportConnectionRecogniser {
byte[] tag1 = new byte[TAG_LENGTH]; byte[] tag1 = new byte[TAG_LENGTH];
crypto.encodeTag(tag1, cipher, key, connection1); crypto.encodeTag(tag1, cipher, key, connection1);
if(connection1 <= connection) { if(connection1 <= connection) {
WindowContext old = tagMap.remove(new Bytes(tag1)); TagContext old = tagMap.remove(new Bytes(tag1));
assert old != null; assert old != null;
ByteUtils.erase(old.context.getSecret()); ByteUtils.erase(old.context.getSecret());
} else { } else {
ConnectionContext ctx1 = new ConnectionContext(contactId, ConnectionContext ctx1 = new ConnectionContext(contactId,
transportId, secret.clone(), connection1, alice); transportId, secret.clone(), connection1, alice);
WindowContext wctx1 = new WindowContext(window, ctx1, period); TagContext tctx1 = new TagContext(window, ctx1, period);
WindowContext old = tagMap.put(new Bytes(tag1), wctx1); TagContext old = tagMap.put(new Bytes(tag1), tctx1);
assert old == null; assert old == null;
} }
} }
@@ -91,8 +91,8 @@ class TransportConnectionRecogniser {
crypto.encodeTag(tag, cipher, key, connection); crypto.encodeTag(tag, cipher, key, connection);
ConnectionContext ctx = new ConnectionContext(contactId, ConnectionContext ctx = new ConnectionContext(contactId,
transportId, secret.clone(), connection, alice); transportId, secret.clone(), connection, alice);
WindowContext wctx = new WindowContext(window, ctx, period); TagContext tctx = new TagContext(window, ctx, period);
WindowContext old = tagMap.put(new Bytes(tag), wctx); TagContext old = tagMap.put(new Bytes(tag), tctx);
assert old == null; assert old == null;
} }
// Create a removal context to remove the window later // Create a removal context to remove the window later
@@ -115,7 +115,7 @@ class TransportConnectionRecogniser {
byte[] tag = new byte[TAG_LENGTH]; byte[] tag = new byte[TAG_LENGTH];
for(long connection : rctx.window.getUnseen()) { for(long connection : rctx.window.getUnseen()) {
crypto.encodeTag(tag, cipher, key, connection); crypto.encodeTag(tag, cipher, key, connection);
WindowContext old = tagMap.remove(new Bytes(tag)); TagContext old = tagMap.remove(new Bytes(tag));
assert old != null; assert old != null;
ByteUtils.erase(old.context.getSecret()); ByteUtils.erase(old.context.getSecret());
} }
@@ -137,14 +137,14 @@ class TransportConnectionRecogniser {
removalMap.clear(); removalMap.clear();
} }
private static class WindowContext { private static class TagContext {
private final ConnectionWindow window; private final ConnectionWindow window;
private final ConnectionContext context; private final ConnectionContext context;
private final long period; private final long period;
private WindowContext(ConnectionWindow window, private TagContext(ConnectionWindow window, ConnectionContext context,
ConnectionContext context, long period) { long period) {
this.window = window; this.window = window;
this.context = context; this.context = context;
this.period = period; this.period = period;