TrueZIP Driver ZIP.RAES (TZP) 7.1

de.schlichtherle.truezip.crypto.raes.param.swing
Class AesCipherParametersView

java.lang.Object
  extended by de.schlichtherle.truezip.crypto.raes.param.swing.AesCipherParametersView
All Implemented Interfaces:
PromptingKeyProvider.View<AesCipherParameters>

public final class AesCipherParametersView
extends Object
implements PromptingKeyProvider.View<AesCipherParameters>

A Swing based user interface to prompt for passwords or key files.

Author:
Christian Schlichtherle

Field Summary
private static String CLASS_NAME
           
(package private) static URI INITIAL_RESOURCE
           
private  InvalidKeyFeedback invalidKeyFeedback
           
static int KEY_FILE_LEN
          This is the number of bytes to load from the beginning of a key file.
(package private) static URI lastResource
          The last resource ID used when prompting.
private static Map<URI,ReadKeyPanel> readKeyPanels
           
private static ResourceBundle resources
           
private static ServiceLocator serviceLocator
           
private  UnknownKeyFeedback unknownKeyFeedback
           
 
Constructor Summary
AesCipherParametersView()
           
 
Method Summary
(package private)  InvalidKeyFeedback getInvalidKeyFeedback()
           
(package private)  UnknownKeyFeedback getUnknownKeyFeedback()
           
private static void multiplexOnEDT(Runnable task)
          Invokes the given task on the AWT Event Dispatching Thread (EDT) and waits until it's finished.
 void promptReadKey(PromptingKeyProvider.Controller<AesCipherParameters> controller, boolean invalid)
          Prompts the user for the key for reading the contents of an existing protected resource.
private  void promptReadKeyEDT(PromptingKeyProvider.Controller<AesCipherParameters> controller, boolean invalid)
          This method is only called by the AWT Event Dispatch Thread, so it doesn't need to be thread safe.
 void promptWriteKey(PromptingKeyProvider.Controller<AesCipherParameters> controller)
          Prompts the user for the key for (over)writing the contents of a new or existing protected resource.
private  void promptWriteKeyEDT(PromptingKeyProvider.Controller<AesCipherParameters> controller)
          This method is only called by the AWT Event Dispatch Thread, so it doesn't need to be thread safe.
(package private) static byte[] readKeyFile(File file)
          Reads the encryption key as a byte sequence from the given pathname into a new buffer of exactly KEY_FILE_LEN bytes and returns it.
(package private)  void setInvalidKeyFeedback(InvalidKeyFeedback ickf)
           
(package private)  void setUnkownKeyFeedback(UnknownKeyFeedback uckf)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_NAME

private static final String CLASS_NAME

resources

private static final ResourceBundle resources

INITIAL_RESOURCE

static final URI INITIAL_RESOURCE

KEY_FILE_LEN

public static final int KEY_FILE_LEN
This is the number of bytes to load from the beginning of a key file. A valid key file for encryption must contain at least this number of bytes!

See Also:
Constant Field Values

readKeyPanels

private static final Map<URI,ReadKeyPanel> readKeyPanels

serviceLocator

private static final ServiceLocator serviceLocator

lastResource

static volatile URI lastResource
The last resource ID used when prompting. Initialized to the empty string.


unknownKeyFeedback

private volatile UnknownKeyFeedback unknownKeyFeedback

invalidKeyFeedback

private volatile InvalidKeyFeedback invalidKeyFeedback
Constructor Detail

AesCipherParametersView

public AesCipherParametersView()
Method Detail

readKeyFile

static byte[] readKeyFile(File file)
                   throws IOException
Reads the encryption key as a byte sequence from the given pathname into a new buffer of exactly KEY_FILE_LEN bytes and returns it.

Throws:
EOFException - If the file is not at least KEY_FILE_LEN bytes long.
IOException - on any other I/O related issue.

getUnknownKeyFeedback

UnknownKeyFeedback getUnknownKeyFeedback()

setUnkownKeyFeedback

void setUnkownKeyFeedback(UnknownKeyFeedback uckf)

getInvalidKeyFeedback

InvalidKeyFeedback getInvalidKeyFeedback()

setInvalidKeyFeedback

void setInvalidKeyFeedback(InvalidKeyFeedback ickf)

promptWriteKey

public void promptWriteKey(PromptingKeyProvider.Controller<AesCipherParameters> controller)
                    throws UnknownKeyException
Description copied from interface: PromptingKeyProvider.View
Prompts the user for the key for (over)writing the contents of a new or existing protected resource. Upon return, the implementation should have updated the key property of the given controller.

If the implementation has called PromptingKeyProvider.Controller.setKey(K) with a non-null parameter, then a clone of this object will be used as the key.

Otherwise, prompting for a key is permanently disabled and each subsequent call to SafeKeyProvider.getWriteKey() or SafeKeyProvider.getReadKey(boolean) results in a KeyPromptingCancelledException until PromptingKeyProvider.resetCancelledKey() or PromptingKeyProvider.resetUnconditionally() gets called.

Specified by:
promptWriteKey in interface PromptingKeyProvider.View<AesCipherParameters>
Parameters:
controller - The key controller for storing the result.
Throws:
UnknownKeyException - if key prompting fails for any reason.

promptWriteKeyEDT

private void promptWriteKeyEDT(PromptingKeyProvider.Controller<AesCipherParameters> controller)
This method is only called by the AWT Event Dispatch Thread, so it doesn't need to be thread safe.


promptReadKey

public void promptReadKey(PromptingKeyProvider.Controller<AesCipherParameters> controller,
                          boolean invalid)
                   throws UnknownKeyException
Description copied from interface: PromptingKeyProvider.View
Prompts the user for the key for reading the contents of an existing protected resource. Upon return, the implementation should have updated the key property of the given controller.

If the implementation has called PromptingKeyProvider.Controller.setKey(K) with a non-null parameter, then a clone of this object will be used as the key.

Otherwise, if the implementation has called PromptingKeyProvider.Controller.setKey(K) with a null parameter or throws a KeyPromptingCancelledException, then prompting for the key is permanently disabled and each subsequent call to SafeKeyProvider.getWriteKey() or SafeKeyProvider.getReadKey(boolean) results in a KeyPromptingCancelledException until PromptingKeyProvider.resetCancelledKey() or PromptingKeyProvider.resetUnconditionally() gets called.

Otherwise, the state of the key provider is not changed and this method gets called again.

Specified by:
promptReadKey in interface PromptingKeyProvider.View<AesCipherParameters>
Parameters:
controller - The key controller for storing the result.
invalid - true iff a previous call to this method resulted in an invalid key.
Throws:
KeyPromptingCancelledException - if key prompting has been cancelled by the user.
UnknownKeyException - if key prompting fails for any other reason.

promptReadKeyEDT

private void promptReadKeyEDT(PromptingKeyProvider.Controller<AesCipherParameters> controller,
                              boolean invalid)
This method is only called by the AWT Event Dispatch Thread, so it doesn't need to be thread safe.


multiplexOnEDT

private static void multiplexOnEDT(Runnable task)
                            throws UnknownKeyException
Invokes the given task on the AWT Event Dispatching Thread (EDT) and waits until it's finished.

In multithreaded environments, although technically possible, do not allow multiple threads to prompt for a key concurrently, because this would only confuse users. By explicitly locking the class object rather than the instance, we enforce this even if multiple implementations and instances are used.

If the current thread is interrupted, an UndeclaredThrowableException is thrown with a KeyPromptingInterruptedException as its cause.

If a Throwable is thrown by the EDT, then it's wrapped in an UndeclaredThrowableException and re-thrown by this thread.

Throws:
UnknownKeyException

TrueZIP Driver ZIP.RAES (TZP) 7.1

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