@Override public int read() throws IOException { if (this.bytesReceived == this.bytesToReceive) { return -1; } final int read = this.wrappedInputStream.read(); if (read < 0) { throwEOFException(); } ++this.bytesReceived; if (this.md != null) { this.md.update((byte) read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
@Override public int read() throws IOException { if (this.bytesReceived == this.bytesToReceive) { return -1; } final int read = this.wrappedInputStream.read(); if (read < 0) { throwEOFException(); } ++this.bytesReceived; if (this.md != null) { this.md.update((byte) read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
@Override public int read(byte[] b, int off, int len) throws IOException { final int bytesMissing = this.bytesToReceive - this.bytesReceived; if (bytesMissing == 0) { return -1; } final int maxRecv = Math.min(len, bytesMissing); final int read = this.wrappedInputStream.read(b, off, maxRecv); if (read < 0) { throwEOFException(); } this.bytesReceived += read; if (this.md != null) { this.md.update(b, off, read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
@Override public int read() throws IOException { if (this.bytesReceived == this.bytesToReceive) { return -1; } final int read = this.wrappedInputStream.read(); if (read < 0) { throwEOFException(); } ++this.bytesReceived; if (this.md != null) { this.md.update((byte) read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
@Override public int read(byte[] b, int off, int len) throws IOException { final int bytesMissing = this.bytesToReceive - this.bytesReceived; if (bytesMissing == 0) { return -1; } final int maxRecv = Math.min(len, bytesMissing); final int read = this.wrappedInputStream.read(b, off, maxRecv); if (read < 0) { throwEOFException(); } this.bytesReceived += read; if (this.md != null) { this.md.update(b, off, read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
@Override public int read(byte[] b, int off, int len) throws IOException { final int bytesMissing = this.bytesToReceive - this.bytesReceived; if (bytesMissing == 0) { return -1; } final int maxRecv = Math.min(len, bytesMissing); final int read = this.wrappedInputStream.read(b, off, maxRecv); if (read < 0) { throwEOFException(); } this.bytesReceived += read; if (this.md != null) { this.md.update(b, off, read); if (this.bytesReceived == this.bytesToReceive) { final byte[] computedKey = this.md.digest(); if (!Arrays.equals(computedKey, this.blobKey.getHash())) { this.wrappedOutputStream.write(RETURN_ERROR); throw new IOException("Detected data corruption during transfer"); } this.wrappedOutputStream.write(RETURN_OKAY); } } return read; }
throw new IOException("Detected data corruption during transfer"); if (!Arrays.equals(localHash, remoteKey.getHash())) { throw new IOException("Detected data corruption during transfer");
throw new IOException("Detected data corruption during transfer"); if (!Arrays.equals(localHash, remoteKey.getHash())) { throw new IOException("Detected data corruption during transfer");
throw new IOException("Detected data corruption during transfer"); if (!Arrays.equals(localHash, remoteKey.getHash())) { throw new IOException("Detected data corruption during transfer");
if (!Arrays.equals(computedKey, blobKey.getHash())) { throw new IOException("Detected data corruption during transfer");
if (!Arrays.equals(computedKey, blobKey.getHash())) { throw new IOException("Detected data corruption during transfer");
if (!Arrays.equals(computedKey, blobKey.getHash())) { throw new IOException("Detected data corruption during transfer");