Key Management

Abstract

This article shows how to set passwords for WinZip AES encrypted ZIP entries programmatically. Use whatever approach fits your needs best when you want to set the password programmatically instead of prompting the user for a key by means of the default Swing or Console based user interfaces.

Introduction

At runtime, all WinZip AES encrypted ZIP entries are managed by an instance of a sub-class of the abstract archive driver implementation class ZipDriver. For custom encrypted application file formats, this should be an instance of the class JarDriver

Whenever this archive driver class reads or writes a WinZip AES encrypted ZIP entry, it uses an instance of the interface KeyManagerContainer in order to obtain an instance of the interface KeyManager for the interface AesPbeParameters and finally obtain an instance of the interface KeyProvider for the prospective archive file.

Because dependency injection is used all over the place in order to resolve the implementation classes of the interfaces KeyManagerContainer, KeyManager and KeyProvider, this architecture provides several ways to set passwords programmatically. In order to set a common password for all WinZip AES encrypted ZIP entries you need a custom TArchiveDetector which you can either inject into any TFile constructor or install as the default archive detector by calling

Error during retrieving content skip as ignoreDownloadError activated.

Setting Passwords For All WinZip AES Entries By Implementing A Custom Driver

This option bypasses the key manager by subclassing JarDriver and overriding the relevant methods for dealing with WinZip AES parameters.

Error during retrieving content skip as ignoreDownloadError activated.

Setting Passwords For All WinZip AES Entries By Implementing A Custom View

Another option is to use a prompting key manager by instantiating the class PromptingKeyManagerContainer which applies the Model-View-Controller pattern to manage its key providers. Here I simply substitute the default view class with a custom implementation.

Error during retrieving content skip as ignoreDownloadError activated.