JDK-6502004 : ZipFile constructor throws ZipException when encrypted entries are present
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 6
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-12-07
  • Updated: 2010-05-15
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b104)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b104, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

(Service Pack 2)

A DESCRIPTION OF THE PROBLEM :
A unit test for our software tests opening a password-protected Zip file, confirming that the entries are as expected and that the entries throw a certain exception.

However in 1.6.0, this does not work as expected, a ZipException is thrown.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Obtain a password-protected zip file (we made ours using WinZip but any tool should work.)

Run the program provided, with the password-protected zip file in the current directory and renamed to "encrypted.zip".


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The program should complete without printing out anything.
ACTUAL -
A ZipException is thrown and reported on stderr (see stack trace below.)


ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.util.zip.ZipException: invalid CEN header (encrypted entry)
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:114)
	at java.util.zip.ZipFile.<init>(ZipFile.java:131)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class ZipTest {
    public static void main(String[] args) throws Exception {
        ZipFile zipFile = new ZipFile("encrypted.zip");
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
There is no workaround for this issue as far as I know.  Using a ZipInputStream may work, or may not work.

Comments
EVALUATION Sun's implementation does not support encrypted / password-protected zip files, in no small part because the underlying library does not provide this support: http://www.zlib.net/zlib_faq.html#faq38
07-12-2006