Skip to content
Snippets Groups Projects
Commit 33dfd4dc authored by bontric's avatar bontric
Browse files

Use readTag function in PrivateMailboxSession

parent 179bec39
Branches
No related tags found
No related merge requests found
Pipeline #
...@@ -23,6 +23,7 @@ import java.io.InputStream; ...@@ -23,6 +23,7 @@ import java.io.InputStream;
import java.net.ProtocolException; import java.net.ProtocolException;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Stream;
import static java.util.logging.Level.INFO; import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
...@@ -113,25 +114,10 @@ public class PrivateMailboxSession extends AbstractMailboxSession { ...@@ -113,25 +114,10 @@ public class PrivateMailboxSession extends AbstractMailboxSession {
MailboxRequestTake takeRequest = (MailboxRequestTake) request; MailboxRequestTake takeRequest = (MailboxRequestTake) request;
InputStream in = new ByteArrayInputStream( InputStream in = new ByteArrayInputStream(
takeRequest.getEncryptedSyncStream()); takeRequest.getEncryptedSyncStream());
byte[] tag = new byte[TAG_LENGTH];
StreamContext ctx;
try { try {
// read tag from input stream
int offset = 0;
while (offset < tag.length) {
int read = in.read(tag, offset, tag.length - offset);
if (read == -1) throw new EOFException();
offset += read;
}
ctx =
keyManager.getStreamContext(MailboxConstants.ID, tag);
if (ctx == null) { StreamContext ctx = readTag(in);
throw new ProtocolException(
"Received stream with unrecognisable tag");
}
InputStream reader = InputStream reader =
streamReaderFactory.createStreamReader(in, ctx); streamReaderFactory.createStreamReader(in, ctx);
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment