TrueZIP Samples 7.1

de.schlichtherle.truezip.sample.zip.raes
Class KeyManagement

java.lang.Object
  extended by de.schlichtherle.truezip.sample.zip.raes.KeyManagement

@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public final class KeyManagement
extends Object

Provides static utility methods to set passwords for RAES encrypted ZIP files 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.

Author:
Christian Schlichtherle

Nested Class Summary
private static class KeyManagement.SimpleKeyManagerService
           
private static class KeyManagement.SimpleKeyProvider
           
private static class KeyManagement.SimpleKeyProviderFactory
           
private static class KeyManagement.SimpleView
           
 
Constructor Summary
private KeyManagement()
          You cannot instantiate this class.
 
Method Summary
static void setAllPasswords1(char[] password)
          Sets the password for all RAES encrypted ZIP files.
static void setAllPasswords2(char[] password)
          Sets the password for all RAES encrypted ZIP files.
static void setPassword(TFile file, char[] password)
          Sets the password for an individual RAES encrypted ZIP file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyManagement

private KeyManagement()
You cannot instantiate this class.

Method Detail

setPassword

public static void setPassword(TFile file,
                               char[] password)
Sets the password for an individual RAES encrypted ZIP file. This method uses the default KeyManager for AesCipherParameters and the default KeyProvider for the given file in order to set the given password.

As another side effect, the key strength of the AesCipherParameters is set to the maximum 256 bits.

This method makes a protective copy of the given password char array. It's highly recommended to overwrite this array with any non-password data after calling this method.

Parameters:
file - the TZP archive file to set the password for.
password - the password char array to be copied for subsequent use.

setAllPasswords1

public static void setAllPasswords1(char[] password)
Sets the password for all RAES encrypted ZIP files. Important: This method installs a new default archive detector using TFile.setDefaultArchiveDetector(de.schlichtherle.truezip.file.TArchiveDetector). This will affect only subsequently created TFile objects!

This method decorates TArchiveDetector.ALL with a custom archive driver for the canonical archive file suffixes "tzp|zip.rae|zip.raes" and installs the result as the default archive detector using TFile.setDefaultArchiveDetector(de.schlichtherle.truezip.file.TArchiveDetector). The custom archive driver uses a custom KeyManagement.SimpleView implementation for its PromptingKeyManagerService.

The key strength for all archive files AesCipherParameters is set to the maximum 256 bits.

This method makes a protective copy of the given password char array. It's highly recommended to overwrite this array with any non-password data after calling this method.

Parameters:
password - the password char array to be copied for subsequent use.

setAllPasswords2

public static void setAllPasswords2(char[] password)
Sets the password for all RAES encrypted ZIP files. Important: This method installs a new default archive detector using TFile.setDefaultArchiveDetector(de.schlichtherle.truezip.file.TArchiveDetector). This will affect only subsequently created TFile objects!

This method decorates TArchiveDetector.ALL with a custom archive driver for the canonical archive file suffixes "tzp|zip.rae|zip.raes" and installs the result as the default archive detector using TFile.setDefaultArchiveDetector(de.schlichtherle.truezip.file.TArchiveDetector). The custom archive driver uses a custom implementation of a KeyManager which requires considerably more code than the approach used in setAllPasswords1(char[]).

As another side effect, the key strength of the AesCipherParameters is set to the maximum 256 bits.

This method makes a protective copy of the given password char array. It's highly recommended to overwrite this array with any non-password data after calling this method.

Parameters:
password - the password char array to be copied for subsequent use.

TrueZIP Samples 7.1

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.