Files
briar/test/net/sf/briar/transport/NullConnectionEncrypter.java
akwizgran a1b664b639 More refactoring to connect ConnectionRecogniser to ConnectionReader.
Added TestDatabaseModule so tests can specify their own DB
configuration. The modules are currently too tightly coupled - see
whether any dependencies can be removed.
2011-09-28 14:21:38 +01:00

52 lines
1019 B
Java

package net.sf.briar.transport;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/** A ConnectionEncrypter that performs no encryption. */
class NullConnectionEncrypter extends FilterOutputStream
implements ConnectionEncrypter {
private long capacity;
NullConnectionEncrypter(OutputStream out) {
this(out, Long.MAX_VALUE);
}
NullConnectionEncrypter(OutputStream out, long capacity) {
super(out);
this.capacity = capacity;
}
public OutputStream getOutputStream() {
return this;
}
public void writeMac(byte[] mac) throws IOException {
out.write(mac);
capacity -= mac.length;
}
public long getRemainingCapacity() {
return capacity;
}
@Override
public void write(int b) throws IOException {
out.write(b);
capacity--;
}
@Override
public void write(byte[] b) throws IOException {
write(b, 0, b.length);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
out.write(b, off, len);
capacity -= len;
}
}