--- old/src/java.base/share/classes/java/util/zip/InflaterInputStream.java 2015-12-17 22:40:11.450805998 +0900 +++ new/src/java.base/share/classes/java/util/zip/InflaterInputStream.java 2015-12-17 22:40:11.236482851 +0900 @@ -51,6 +51,11 @@ protected byte[] buf; /** + * Original input buffer. + */ + protected byte[] originBuf; + + /** * Length of input buffer. */ protected int len; @@ -59,6 +64,8 @@ // 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 */ @@ -86,6 +93,7 @@ } this.inf = inf; buf = new byte[size]; + originBuf = new byte[size]; } /** @@ -239,6 +247,12 @@ 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); } @@ -285,4 +299,15 @@ 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. zip decryption will not + * work if this value set to null. + * @since 1.9 + */ + public void setZipCryption(ZipCryption zipCryption) { + this.zipCryption = zipCryption; + } }