Renamed a couple of classes.

This commit is contained in:
akwizgran
2012-01-20 23:28:17 +00:00
parent 3a77ba9aaf
commit 48ceaaea2a
10 changed files with 29 additions and 24 deletions

View File

@@ -55,7 +55,8 @@ class ConnectionReaderFactoryImpl implements ConnectionReaderFactory {
new IncomingAuthenticationLayerImpl(correction, mac, macKey); new IncomingAuthenticationLayerImpl(correction, mac, macKey);
// No reordering or retransmission // No reordering or retransmission
IncomingReliabilityLayer reliability = IncomingReliabilityLayer reliability =
new NullIncomingReliabilityLayer(authentication); new IncomingReliabilityLayerImpl(authentication,
new NullFrameWindow());
// Create the reader - don't tolerate errors // Create the reader - don't tolerate errors
return new ConnectionReaderImpl(reliability, false); return new ConnectionReaderImpl(reliability, false);
} }
@@ -81,7 +82,7 @@ class ConnectionReaderFactoryImpl implements ConnectionReaderFactory {
Cipher tagCipher = crypto.getTagCipher(); Cipher tagCipher = crypto.getTagCipher();
Cipher segCipher = crypto.getSegmentCipher(); Cipher segCipher = crypto.getSegmentCipher();
IncomingEncryptionLayer encryption = IncomingEncryptionLayer encryption =
new IncomingSegmentedEncryptionLayer(in, tagCipher, segCipher, new SegmentedIncomingEncryptionLayer(in, tagCipher, segCipher,
tagKey, segKey, false, bufferedSegment); tagKey, segKey, false, bufferedSegment);
// No error correction // No error correction
IncomingErrorCorrectionLayer correction = IncomingErrorCorrectionLayer correction =
@@ -92,7 +93,8 @@ class ConnectionReaderFactoryImpl implements ConnectionReaderFactory {
new IncomingAuthenticationLayerImpl(correction, mac, macKey); new IncomingAuthenticationLayerImpl(correction, mac, macKey);
// No reordering or retransmission // No reordering or retransmission
IncomingReliabilityLayer reliability = IncomingReliabilityLayer reliability =
new NullIncomingReliabilityLayer(authentication); new IncomingReliabilityLayerImpl(authentication,
new NullFrameWindow());
// Create the reader - don't tolerate errors // Create the reader - don't tolerate errors
return new ConnectionReaderImpl(reliability, false); return new ConnectionReaderImpl(reliability, false);
} }

View File

@@ -60,7 +60,7 @@ class ConnectionWriterFactoryImpl implements ConnectionWriterFactory {
Cipher tagCipher = crypto.getTagCipher(); Cipher tagCipher = crypto.getTagCipher();
Cipher segCipher = crypto.getSegmentCipher(); Cipher segCipher = crypto.getSegmentCipher();
OutgoingEncryptionLayer encryption = OutgoingEncryptionLayer encryption =
new OutgoingSegmentedEncryptionLayer(out, capacity, tagCipher, new SegmentedOutgoingEncryptionLayer(out, capacity, tagCipher,
segCipher, tagKey, segKey, false); segCipher, tagKey, segKey, false);
// No error correction // No error correction
OutgoingErrorCorrectionLayer correction = OutgoingErrorCorrectionLayer correction =

View File

@@ -2,16 +2,17 @@ package net.sf.briar.transport;
import java.io.IOException; import java.io.IOException;
class NullIncomingReliabilityLayer implements IncomingReliabilityLayer { class IncomingReliabilityLayerImpl implements IncomingReliabilityLayer {
private final IncomingAuthenticationLayer in; private final IncomingAuthenticationLayer in;
private final int maxFrameLength;
private final FrameWindow window; private final FrameWindow window;
private final int maxFrameLength;
NullIncomingReliabilityLayer(IncomingAuthenticationLayer in) { IncomingReliabilityLayerImpl(IncomingAuthenticationLayer in,
FrameWindow window) {
this.in = in; this.in = in;
this.window = window;
maxFrameLength = in.getMaxFrameLength(); maxFrameLength = in.getMaxFrameLength();
window = new NullFrameWindow();
} }
public boolean readFrame(Frame f) throws IOException, InvalidDataException { public boolean readFrame(Frame f) throws IOException, InvalidDataException {

View File

@@ -15,7 +15,7 @@ import net.sf.briar.api.crypto.ErasableKey;
import net.sf.briar.api.plugins.SegmentSource; import net.sf.briar.api.plugins.SegmentSource;
import net.sf.briar.api.transport.Segment; import net.sf.briar.api.transport.Segment;
class IncomingSegmentedEncryptionLayer implements IncomingEncryptionLayer { class SegmentedIncomingEncryptionLayer implements IncomingEncryptionLayer {
private final SegmentSource in; private final SegmentSource in;
private final Cipher tagCipher, segCipher; private final Cipher tagCipher, segCipher;
@@ -29,7 +29,7 @@ class IncomingSegmentedEncryptionLayer implements IncomingEncryptionLayer {
private boolean firstSegment = true; private boolean firstSegment = true;
private long segmentNumber = 0L; private long segmentNumber = 0L;
IncomingSegmentedEncryptionLayer(SegmentSource in, Cipher tagCipher, SegmentedIncomingEncryptionLayer(SegmentSource in, Cipher tagCipher,
Cipher segCipher, ErasableKey tagKey, ErasableKey segKey, Cipher segCipher, ErasableKey tagKey, ErasableKey segKey,
boolean tagEverySegment, Segment bufferedSegment) { boolean tagEverySegment, Segment bufferedSegment) {
this.in = in; this.in = in;

View File

@@ -15,7 +15,7 @@ import net.sf.briar.api.crypto.ErasableKey;
import net.sf.briar.api.plugins.SegmentSink; import net.sf.briar.api.plugins.SegmentSink;
import net.sf.briar.api.transport.Segment; import net.sf.briar.api.transport.Segment;
class OutgoingSegmentedEncryptionLayer implements OutgoingEncryptionLayer { class SegmentedOutgoingEncryptionLayer implements OutgoingEncryptionLayer {
private final SegmentSink out; private final SegmentSink out;
private final Cipher tagCipher, segCipher; private final Cipher tagCipher, segCipher;
@@ -27,7 +27,7 @@ class OutgoingSegmentedEncryptionLayer implements OutgoingEncryptionLayer {
private long capacity; private long capacity;
OutgoingSegmentedEncryptionLayer(SegmentSink out, long capacity, SegmentedOutgoingEncryptionLayer(SegmentSink out, long capacity,
Cipher tagCipher, Cipher segCipher, ErasableKey tagKey, Cipher tagCipher, Cipher segCipher, ErasableKey tagKey,
ErasableKey segKey, boolean tagEverySegment) { ErasableKey segKey, boolean tagEverySegment) {
this.out = out; this.out = out;

View File

@@ -59,9 +59,9 @@
<test name='net.sf.briar.transport.FrameWindowImplTest'/> <test name='net.sf.briar.transport.FrameWindowImplTest'/>
<test name='net.sf.briar.transport.IncomingEncryptionLayerImplTest'/> <test name='net.sf.briar.transport.IncomingEncryptionLayerImplTest'/>
<test name='net.sf.briar.transport.IncomingErrorCorrectionLayerImplTest'/> <test name='net.sf.briar.transport.IncomingErrorCorrectionLayerImplTest'/>
<test name='net.sf.briar.transport.IncomingSegmentedEncryptionLayerTest'/>
<test name='net.sf.briar.transport.OutgoingEncryptionLayerImplTest'/> <test name='net.sf.briar.transport.OutgoingEncryptionLayerImplTest'/>
<test name='net.sf.briar.transport.OutgoingSegmentedEncryptionLayerTest'/> <test name='net.sf.briar.transport.SegmentedIncomingEncryptionLayerTest'/>
<test name='net.sf.briar.transport.SegmentedOutgoingEncryptionLayerTest'/>
<test name='net.sf.briar.transport.XorErasureCodeTest'/> <test name='net.sf.briar.transport.XorErasureCodeTest'/>
<test name='net.sf.briar.transport.XorErasureDecoderTest'/> <test name='net.sf.briar.transport.XorErasureDecoderTest'/>
<test name='net.sf.briar.transport.XorErasureEncoderTest'/> <test name='net.sf.briar.transport.XorErasureEncoderTest'/>

View File

@@ -224,7 +224,8 @@ public class ConnectionReaderImplTest extends TransportTest {
IncomingAuthenticationLayer authentication = IncomingAuthenticationLayer authentication =
new IncomingAuthenticationLayerImpl(correction, mac, macKey); new IncomingAuthenticationLayerImpl(correction, mac, macKey);
IncomingReliabilityLayer reliability = IncomingReliabilityLayer reliability =
new NullIncomingReliabilityLayer(authentication); new IncomingReliabilityLayerImpl(authentication,
new NullFrameWindow());
return new ConnectionReaderImpl(reliability, false); return new ConnectionReaderImpl(reliability, false);
} }
} }

View File

@@ -103,7 +103,8 @@ public class FrameReadWriteTest extends BriarTestCase {
IncomingAuthenticationLayer authenticationIn = IncomingAuthenticationLayer authenticationIn =
new IncomingAuthenticationLayerImpl(correctionIn, mac, macKey); new IncomingAuthenticationLayerImpl(correctionIn, mac, macKey);
IncomingReliabilityLayer reliabilityIn = IncomingReliabilityLayer reliabilityIn =
new NullIncomingReliabilityLayer(authenticationIn); new IncomingReliabilityLayerImpl(authenticationIn,
new NullFrameWindow());
ConnectionReader reader = new ConnectionReaderImpl(reliabilityIn, ConnectionReader reader = new ConnectionReaderImpl(reliabilityIn,
false); false);
InputStream in1 = reader.getInputStream(); InputStream in1 = reader.getInputStream();

View File

@@ -22,12 +22,12 @@ import org.junit.Test;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
public class IncomingSegmentedEncryptionLayerTest extends BriarTestCase { public class SegmentedIncomingEncryptionLayerTest extends BriarTestCase {
private final Cipher tagCipher, segCipher; private final Cipher tagCipher, segCipher;
private final ErasableKey tagKey, segKey; private final ErasableKey tagKey, segKey;
public IncomingSegmentedEncryptionLayerTest() { public SegmentedIncomingEncryptionLayerTest() {
super(); super();
Injector i = Guice.createInjector(new CryptoModule()); Injector i = Guice.createInjector(new CryptoModule());
CryptoComponent crypto = i.getInstance(CryptoComponent.class); CryptoComponent crypto = i.getInstance(CryptoComponent.class);
@@ -65,7 +65,7 @@ public class IncomingSegmentedEncryptionLayerTest extends BriarTestCase {
SegmentSource in = new ByteArraySegmentSource(ciphertext1); SegmentSource in = new ByteArraySegmentSource(ciphertext1);
// Use the encryption layer to decrypt the ciphertext // Use the encryption layer to decrypt the ciphertext
IncomingEncryptionLayer decrypter = IncomingEncryptionLayer decrypter =
new IncomingSegmentedEncryptionLayer(in, tagCipher, segCipher, new SegmentedIncomingEncryptionLayer(in, tagCipher, segCipher,
tagKey, segKey, false, buffered); tagKey, segKey, false, buffered);
// First segment // First segment
Segment s = new SegmentImpl(); Segment s = new SegmentImpl();
@@ -116,7 +116,7 @@ public class IncomingSegmentedEncryptionLayerTest extends BriarTestCase {
SegmentSource in = new ByteArraySegmentSource(ciphertext1); SegmentSource in = new ByteArraySegmentSource(ciphertext1);
// Use the encryption layer to decrypt the ciphertext // Use the encryption layer to decrypt the ciphertext
IncomingEncryptionLayer decrypter = IncomingEncryptionLayer decrypter =
new IncomingSegmentedEncryptionLayer(in, tagCipher, segCipher, new SegmentedIncomingEncryptionLayer(in, tagCipher, segCipher,
tagKey, segKey, true, buffered); tagKey, segKey, true, buffered);
// First segment // First segment
Segment s = new SegmentImpl(); Segment s = new SegmentImpl();

View File

@@ -22,14 +22,14 @@ import org.junit.Test;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
public class OutgoingSegmentedEncryptionLayerTest extends BriarTestCase { public class SegmentedOutgoingEncryptionLayerTest extends BriarTestCase {
private static final int MAC_LENGTH = 32; private static final int MAC_LENGTH = 32;
private final Cipher tagCipher, segCipher; private final Cipher tagCipher, segCipher;
private final ErasableKey tagKey, segKey; private final ErasableKey tagKey, segKey;
public OutgoingSegmentedEncryptionLayerTest() { public SegmentedOutgoingEncryptionLayerTest() {
super(); super();
Injector i = Guice.createInjector(new CryptoModule()); Injector i = Guice.createInjector(new CryptoModule());
CryptoComponent crypto = i.getInstance(CryptoComponent.class); CryptoComponent crypto = i.getInstance(CryptoComponent.class);
@@ -65,7 +65,7 @@ public class OutgoingSegmentedEncryptionLayerTest extends BriarTestCase {
// Use the encryption layer to encrypt the plaintext // Use the encryption layer to encrypt the plaintext
ByteArraySegmentSink sink = new ByteArraySegmentSink(); ByteArraySegmentSink sink = new ByteArraySegmentSink();
OutgoingEncryptionLayer encrypter = OutgoingEncryptionLayer encrypter =
new OutgoingSegmentedEncryptionLayer(sink, Long.MAX_VALUE, new SegmentedOutgoingEncryptionLayer(sink, Long.MAX_VALUE,
tagCipher, segCipher, tagKey, segKey, false); tagCipher, segCipher, tagKey, segKey, false);
Segment s = new SegmentImpl(); Segment s = new SegmentImpl();
System.arraycopy(plaintext, 0, s.getBuffer(), 0, plaintext.length); System.arraycopy(plaintext, 0, s.getBuffer(), 0, plaintext.length);
@@ -113,7 +113,7 @@ public class OutgoingSegmentedEncryptionLayerTest extends BriarTestCase {
// Use the encryption layer to encrypt the plaintext // Use the encryption layer to encrypt the plaintext
SegmentSink sink = new ByteArraySegmentSink(); SegmentSink sink = new ByteArraySegmentSink();
OutgoingEncryptionLayer encrypter = OutgoingEncryptionLayer encrypter =
new OutgoingSegmentedEncryptionLayer(sink, Long.MAX_VALUE, new SegmentedOutgoingEncryptionLayer(sink, Long.MAX_VALUE,
tagCipher, segCipher, tagKey, segKey, true); tagCipher, segCipher, tagKey, segKey, true);
Segment s = new SegmentImpl(); Segment s = new SegmentImpl();
System.arraycopy(plaintext, 0, s.getBuffer(), 0, plaintext.length); System.arraycopy(plaintext, 0, s.getBuffer(), 0, plaintext.length);