[TRUEZIP-360] "Enter key for writing" popup shouldn't be shown Created: 13/Mar/15  Updated: 13/Mar/15

Status: Open
Project: TrueZIP
Component/s: TrueZIP Kernel
Affects Version/s: TrueZIP 7.7.8
Fix Version/s: None

Type: Bug Priority: Major
Reporter: lbinkiewicz Assignee: Christian Schlichtherle
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


I've noticed that "Enter key for writing" popup appears while it shoudn't.
Attached file should explain the issue.

Comment by lbinkiewicz [ 13/Mar/15 ]

package issue;

import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;

import de.schlichtherle.truezip.crypto.param.AesKeyStrength;
import de.schlichtherle.truezip.file.TArchiveDetector;
import de.schlichtherle.truezip.file.TConfig;
import de.schlichtherle.truezip.file.TFile;
import de.schlichtherle.truezip.file.TFileWriter;
import de.schlichtherle.truezip.fs.FsController;
import de.schlichtherle.truezip.fs.FsDriverProvider;
import de.schlichtherle.truezip.fs.FsModel;
import de.schlichtherle.truezip.fs.FsOutputOption;
import de.schlichtherle.truezip.fs.archive.zip.ZipDriver;
import de.schlichtherle.truezip.fs.archive.zip.ZipDriverEntry;
import de.schlichtherle.truezip.socket.sl.IOPoolLocator;
import de.schlichtherle.truezip.util.BitField;
import de.schlichtherle.truezip.zip.WinZipAesParameters;
import de.schlichtherle.truezip.zip.ZipCryptoParameters;
import de.schlichtherle.truezip.zip.ZipKeyException;

public class TrueZipTest {

final class CustomWinZipAesParameters implements WinZipAesParameters {
final byte[] password;

CustomWinZipAesParameters(final byte[] password)

{ this.password = password.clone(); }

public byte[] getWritePassword(String name) throws ZipKeyException

{ return password.clone(); }

public byte[] getReadPassword(String name, boolean invalid)
throws ZipKeyException

{ if (invalid) throw new ZipKeyException(name + " (invalid password)"); return password.clone(); }

public AesKeyStrength getKeyStrength(String arg0)
throws ZipKeyException

{ return AesKeyStrength.BITS_256; }

public void setKeyStrength(String name, AesKeyStrength keyStrength)
throws ZipKeyException

{ // We have been using only 128 bits to create archive entries. assert AesKeyStrength.BITS_256 == keyStrength; }


final class CustomZipDriver extends ZipDriver {
final ZipCryptoParameters param;

public CustomZipDriver(byte[] password)

{ super(IOPoolLocator.SINGLETON); param = new CustomWinZipAesParameters(password); }

protected ZipCryptoParameters zipCryptoParameters(FsModel model,
Charset charset)

{ return param; }

public <M extends FsModel> FsController<M> decorate(
FsController<M> controller)

{ return controller; }

protected boolean process(ZipDriverEntry input, ZipDriverEntry output)

{ return false; }


private void setConfig1()

{ final TConfig config = TConfig.get(); FsDriverProvider provider = new TArchiveDetector( TArchiveDetector.ALL.toString()); config.setOutputPreferences(config.getOutputPreferences().clear( FsOutputOption.ENCRYPT)); config.setArchiveDetector(new TArchiveDetector(provider, ".zip")); }

private void setConfig2(String password)

{ final TConfig config = TConfig.get(); FsDriverProvider provider = new TArchiveDetector( TArchiveDetector.ALL.toString()); config.setOutputPreferences(config.getOutputPreferences().or( BitField.of(FsOutputOption.ENCRYPT))); config.setArchiveDetector(new TArchiveDetector(provider, ".zip", new CustomZipDriver(password.getBytes()))); }

private File createSampleFile(String dir, String zipFile, String innerFile)
throws IOException {
File f = new TFile(dir, zipFile);
File file = new TFile(f.getPath() + File.separator + innerFile);
Writer writer = new TFileWriter(file, true, Charset.forName("UTF-8"));

{ writer.write("TEST"); }


{ writer.close(); }

return f;


public static void main(String[] args) throws IOException,
InterruptedException {
String workingDir = "/home/lukasz/ar1";
String zipName = "a.zip";
String innerFile = "a.txt";

TrueZipTest tzt = new TrueZipTest();

File finit = new File(workingDir, zipName);
if (finit.exists())

{ finit.delete(); System.out.println(finit.exists()); }

File f0 = tzt.createSampleFile(workingDir, zipName, innerFile);

// create archive without pass
File f1 = tzt.createSampleFile(workingDir, zipName, innerFile);

// create archive with pass
File f2 = tzt.createSampleFile(workingDir, zipName, innerFile);

// create archive with pass
File f3 = tzt.createSampleFile(workingDir, zipName, innerFile);

File f4 = tzt.createSampleFile(workingDir, zipName, innerFile);



Comment by lbinkiewicz [ 13/Mar/15 ]

This issue occurs only while first file is created as not encrypted, If You uncomment this section:
File f0 = tzt.createSampleFile(workingDir, zipName, innerFile);
There is no popup displayed.

Generated at Tue Jul 07 10:08:49 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.