public final class AesCipherParametersView extends Object implements PromptingKeyProvider.View<AesCipherParameters>
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
AesCipherParametersView() |
| Modifier and Type | Method and Description |
|---|---|
(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) |
private static final String CLASS_NAME
private static final ResourceBundle resources
static final URI INITIAL_RESOURCE
public static final int KEY_FILE_LEN
private static final Map<URI,ReadKeyPanel> readKeyPanels
private static final ServiceLocator serviceLocator
static volatile URI lastResource
private volatile UnknownKeyFeedback unknownKeyFeedback
private volatile InvalidKeyFeedback invalidKeyFeedback
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 promptWriteKey(PromptingKeyProvider.Controller<AesCipherParameters> controller) throws UnknownKeyException
PromptingKeyProvider.Viewkey 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.
promptWriteKey in interface PromptingKeyProvider.View<AesCipherParameters>controller - The key controller for storing the result.UnknownKeyException - if key prompting fails for any reason.private void promptWriteKeyEDT(PromptingKeyProvider.Controller<AesCipherParameters> controller)
public void promptReadKey(PromptingKeyProvider.Controller<AesCipherParameters> controller, boolean invalid) throws UnknownKeyException
PromptingKeyProvider.Viewkey 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.
promptReadKey in interface PromptingKeyProvider.View<AesCipherParameters>controller - The key controller for storing the result.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 promptReadKeyEDT(PromptingKeyProvider.Controller<AesCipherParameters> controller, boolean invalid)
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.
UnknownKeyExceptionCopyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.