< prev index next >
src/java.base/share/classes/java/util/zip/InflaterInputStream.java
Print this page
*** 49,66 ****
--- 49,73 ----
* Input buffer for decompression.
*/
protected byte[] buf;
/**
+ * Original input buffer.
+ */
+ protected byte[] originBuf;
+
+ /**
* Length of input buffer.
*/
protected int len;
private boolean closed = false;
// this flag is set to true after EOF has reached
private boolean reachEOF = false;
+ private ZipCryption zipCryption;
+
/**
* Check to make sure that this stream has not been closed
*/
private void ensureOpen() throws IOException {
if (closed) {
*** 84,93 ****
--- 91,101 ----
} else if (size <= 0) {
throw new IllegalArgumentException("buffer size <= 0");
}
this.inf = inf;
buf = new byte[size];
+ originBuf = new byte[size];
}
/**
* Creates a new input stream with the specified decompressor and a
* default buffer size.
*** 237,246 ****
--- 245,260 ----
ensureOpen();
len = in.read(buf, 0, buf.length);
if (len == -1) {
throw new EOFException("Unexpected end of ZLIB input stream");
}
+
+ if (zipCryption != null) {
+ System.arraycopy(buf, 0, originBuf, 0, len);
+ zipCryption.decryptBytes(buf, 0, len);
+ }
+
inf.setInput(buf, 0, len);
}
/**
* Tests if this input stream supports the <code>mark</code> and
*** 283,288 ****
--- 297,310 ----
* @see java.io.IOException
*/
public synchronized void reset() throws IOException {
throw new IOException("mark/reset not supported");
}
+
+ /**
+ * Set ZIP encryption/decryption engine to this inflater.
+ * @param zipCryption ZIP encrypt/decrypt engine.
+ */
+ public void setZipCryption(ZipCryption zipCryption) {
+ this.zipCryption = zipCryption;
+ }
}
< prev index next >