|
TrueZIP Driver TZP (ZIP.RAES) 7.0-rc1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.truezip.crypto.raes.param.swing.AesCipherParametersUI
public final class AesCipherParametersUI
A Swing based user interface to prompt for passwords or key files.
| 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<PromptingKeyProvider<?>,OpenKeyPanel> |
openKeyPanels
|
private static ResourceBundle |
resources
|
private static ServiceLocator |
serviceLocator
|
private static long |
START_PROMPTING_TIMEOUT
The timeout for the EDT to start prompting for a key in milliseconds. |
private UnknownKeyFeedback |
unknownKeyFeedback
|
| Constructor Summary | |
|---|---|
AesCipherParametersUI()
|
|
| Method Summary | |
|---|---|
private static void |
eventuallyDispose(Window window)
The following is a double work around for Sun's J2SE 1.4.2 which has been tested with 1.4.2-b28 and 1.4.2_12-b03 on the Windows platform. |
(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 |
promptCreateKey(PromptingKeyProvider<? super AesCipherParameters> provider)
Prompts the user for the key which may be used to create a new protected resource or entirely replace the contents of an already existing protected resource. |
private void |
promptCreateKeyEDT(PromptingKeyProvider<? super AesCipherParameters> provider)
This method is only called by the AWT Event Dispatch Thread, so it doesn't need to be thread safe. |
void |
promptOpenKey(PromptingKeyProvider<? super AesCipherParameters> provider,
boolean invalid)
Prompts the user for the key which may be used to open an existing protected resource in order to access its contents. |
private void |
promptOpenKeyEDT(PromptingKeyProvider<? super AesCipherParameters> provider,
boolean invalid)
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 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 |
|---|
private static final String CLASS_NAME
private static final ResourceBundle resources
static final URI INITIAL_RESOURCE
private static final long START_PROMPTING_TIMEOUT
public static final int KEY_FILE_LEN
private static final Map<PromptingKeyProvider<?>,OpenKeyPanel> openKeyPanels
private static final ServiceLocator serviceLocator
static volatile URI lastResource
private volatile UnknownKeyFeedback unknownKeyFeedback
private volatile InvalidKeyFeedback invalidKeyFeedback
| Constructor Detail |
|---|
public AesCipherParametersUI()
| Method Detail |
|---|
static byte[] readKeyFile(File file)
throws IOException
KEY_FILE_LEN bytes and returns it.
EOFException - If the file is not at least KEY_FILE_LEN
bytes long.
IOException - on any other I/O related issue.UnknownKeyFeedback getUnknownKeyFeedback()
void setUnkownKeyFeedback(UnknownKeyFeedback uckf)
InvalidKeyFeedback getInvalidKeyFeedback()
void setInvalidKeyFeedback(InvalidKeyFeedback ickf)
public void promptCreateKey(PromptingKeyProvider<? super AesCipherParameters> provider)
throws UnknownKeyException
PromptingKeyProvider.UIkey property of the given provider.
If the implementation has called PromptingKeyProvider.setKey(K) with a
non-null parameter, then a clone of this object will be
used as the key of the given provider.
Otherwise, prompting for a key is permanently disabled and each
subsequent call to SafeKeyProvider.getCreateKey() or SafeKeyProvider.getOpenKey(boolean)
results in a KeyPromptingCancelledException until
PromptingKeyProvider.resetCancelledKey() or PromptingKeyProvider.resetUnconditionally() gets
called.
promptCreateKey in interface PromptingKeyProvider.UI<AesCipherParameters>provider - The key provider to store the result in.
UnknownKeyException - if key prompting fails for any reason.
public void promptOpenKey(PromptingKeyProvider<? super AesCipherParameters> provider,
boolean invalid)
throws UnknownKeyException
PromptingKeyProvider.UIkey property of the given provider.
If the implementation has called PromptingKeyProvider.setKey(K) with a
non-null parameter, then a clone of this object will be
used as the key of the given provider.
Otherwise, if the implementation has called PromptingKeyProvider.setKey(K) with a
null parameter or throws a
KeyPromptingCancelledException, then prompting for the key
is permanently disabled and each subsequent call to
SafeKeyProvider.getCreateKey() or SafeKeyProvider.getOpenKey(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.
promptOpenKey in interface PromptingKeyProvider.UI<AesCipherParameters>provider - The key provider to store the result in.invalid - true iff a previous call to this method
resulted in an invalid key.
KeyPromptingCancelledException - if key prompting has been
cancelled by the user.
UnknownKeyException - if key prompting fails for any other
reason.private void promptCreateKeyEDT(PromptingKeyProvider<? super AesCipherParameters> provider)
private void promptOpenKeyEDT(PromptingKeyProvider<? super AesCipherParameters> provider,
boolean invalid)
private static void eventuallyDispose(Window window)
The issue is that an application will not terminate until all Window's have been dispose()d or System.exit() has been called - it is not sufficient just to hide() all Window's.
The JOptionPane properly dispose()s its Dialog which displays
our password panels.
However, by default JOptionPane uses an internal Frame
as its parent window if the application does not specify a parent
window explicitly.
JOptionPane never dispose()s the parent window, so the
client application may eventually not terminate.
The workaround is to dispose the parent window if it's not showing.
private static void multiplexOnEDT(Runnable task)
throws UnknownKeyException
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.
UnknownKeyException
|
TrueZIP Driver TZP (ZIP.RAES) 7.0-rc1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||