@@ -48,6 +48,12 @@ public void testZipOutputStreamDeflateWithStandardEncryption() throws IOExceptio
48
48
testZipOutputStream (CompressionMethod .DEFLATE , true , EncryptionMethod .ZIP_STANDARD , null );
49
49
}
50
50
51
+ @ Test
52
+ public void testZipOutputStreamDeflateWithStandardEncryptionWhenModifiedFileTimeNotSet ()
53
+ throws IOException , ZipException {
54
+ testZipOutputStream (CompressionMethod .DEFLATE , true , EncryptionMethod .ZIP_STANDARD , null , false );
55
+ }
56
+
51
57
@ Test
52
58
public void testZipOutputStreamDeflateWithAES128 () throws IOException , ZipException {
53
59
testZipOutputStream (CompressionMethod .DEFLATE , true , EncryptionMethod .AES , AesKeyStrength .KEY_STRENGTH_128 );
@@ -61,6 +67,13 @@ public void testZipOutputStreamDeflateWithAES256() throws IOException, ZipExcept
61
67
private void testZipOutputStream (CompressionMethod compressionMethod , boolean encrypt ,
62
68
EncryptionMethod encryptionMethod , AesKeyStrength aesKeyStrength )
63
69
throws IOException , ZipException {
70
+ testZipOutputStream (compressionMethod , encrypt , encryptionMethod , aesKeyStrength , true );
71
+ }
72
+
73
+ private void testZipOutputStream (CompressionMethod compressionMethod , boolean encrypt ,
74
+ EncryptionMethod encryptionMethod , AesKeyStrength aesKeyStrength ,
75
+ boolean setLastModifiedTime )
76
+ throws IOException , ZipException {
64
77
65
78
ZipParameters zipParameters = buildZipParameters (compressionMethod , encrypt , encryptionMethod , aesKeyStrength );
66
79
byte [] buff = new byte [4096 ];
@@ -73,7 +86,9 @@ private void testZipOutputStream(CompressionMethod compressionMethod, boolean en
73
86
zipParameters .setEntrySize (fileToAdd .length ());
74
87
}
75
88
76
- zipParameters .setLastModifiedFileTime (fileToAdd .lastModified ());
89
+ if (setLastModifiedTime ) {
90
+ zipParameters .setLastModifiedFileTime (fileToAdd .lastModified ());
91
+ }
77
92
zipParameters .setFileNameInZip (fileToAdd .getName ());
78
93
zos .putNextEntry (zipParameters );
79
94
0 commit comments