|
TrueZIP 6.8.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.key.passwd.swing.PromptingKeyProviderUI
public class PromptingKeyProviderUI
A Swing based user interface to prompt for passwords or key files. This class is thread safe.
| Nested Class Summary | |
|---|---|
private static class |
PromptingKeyProviderUI.BooleanRunnable
|
| Field Summary | |
|---|---|
private static String |
CLASS_NAME
|
private CreateKeyPanel |
createKeyPanel
Deprecated. This field is not used anymore and will be removed for the next major release number. |
private Feedback |
invalidCreateKeyFeedback
|
private Feedback |
invalidOpenKeyFeedback
|
static int |
KEY_FILE_LEN
This is the number of bytes to load from the beginning of a key file. |
(package private) static String |
lastResourceID
The last resource ID used when prompting. |
private static Logger |
logger
|
private OpenKeyPanel |
openKeyPanel
Deprecated. This field is not used anymore and will be removed for the next major release number. |
private static Map |
openKeyPanels
|
private static String |
PACKAGE_NAME
|
private static ResourceBundle |
resources
|
private static long |
START_PROMPTING_TIMEOUT
The timeout for the EDT to start prompting for a key in milliseconds. |
private Feedback |
unknownCreateKeyFeedback
|
private Feedback |
unknownOpenKeyFeedback
|
| Constructor Summary | |
|---|---|
PromptingKeyProviderUI()
|
|
| Method Summary | |
|---|---|
protected CreateKeyPanel |
createCreateKeyPanel()
A factory method to create the Create Protected Resource Key Panel. |
private static Feedback |
createFeedback(String type)
|
protected OpenKeyPanel |
createOpenKeyPanel()
A factory method to create the Open Protected Resource Key Panel. |
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. |
protected CreateKeyPanel |
getCreateKeyPanel()
Deprecated. This method is not used anymore and will be removed for the next major release number. It's use may dead lock the GUI. Use createCreateKeyPanel() instead. |
protected Feedback |
getInvalidCreateKeyFeedback()
|
protected Feedback |
getInvalidOpenKeyFeedback()
|
protected OpenKeyPanel |
getOpenKeyPanel()
Deprecated. This method is not used anymore and will be removed for the next major release number. It's use may dead lock the GUI. Use createOpenKeyPanel() instead. |
protected Feedback |
getUnknownCreateKeyFeedback()
|
protected Feedback |
getUnknownOpenKeyFeedback()
|
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 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. |
protected void |
promptCreateKey(PromptingKeyProvider provider,
JComponent extraDataUI)
This method is only called by the AWT Event Dispatch Thread, so it doesn't need to be thread safe. |
boolean |
promptInvalidOpenKey(PromptingKeyProvider provider)
Prompts the user for the key which may be used to open an existing protected resource in order to access its contents. |
protected boolean |
promptOpenKey(PromptingKeyProvider provider,
boolean invalid,
JComponent extraDataUI)
This method is only called by the AWT Event Dispatch Thread, so it doesn't need to be thread safe. |
boolean |
promptUnknownOpenKey(PromptingKeyProvider provider)
Prompts the user for the key which may be used to open an existing protected resource in order to access its contents. |
(package private) static byte[] |
readKeyFile(String pathname)
Reads the encryption key as a byte sequence from the given pathname into a buffer of exactly KEY_FILE_LEN bytes and returns it. |
protected void |
setInvalidCreateKeyFeedback(Feedback ickf)
|
protected void |
setInvalidOpenKeyFeedback(Feedback iokf)
|
protected void |
setUnknownOpenKeyFeedback(Feedback uokf)
|
protected void |
setUnkownCreateKeyFeedback(Feedback 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 PACKAGE_NAME
private static final String CLASS_NAME
private static final ResourceBundle resources
private static final Logger logger
private static final long START_PROMPTING_TIMEOUT
public static final int KEY_FILE_LEN
private static final Map openKeyPanels
static String lastResourceID
private CreateKeyPanel createKeyPanel
private OpenKeyPanel openKeyPanel
private Feedback unknownCreateKeyFeedback
private Feedback invalidCreateKeyFeedback
private Feedback unknownOpenKeyFeedback
private Feedback invalidOpenKeyFeedback
| Constructor Detail |
|---|
public PromptingKeyProviderUI()
| Method Detail |
|---|
static byte[] readKeyFile(String pathname)
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.protected CreateKeyPanel getCreateKeyPanel()
createCreateKeyPanel() instead.
protected CreateKeyPanel createCreateKeyPanel()
protected OpenKeyPanel getOpenKeyPanel()
createOpenKeyPanel() instead.
protected OpenKeyPanel createOpenKeyPanel()
protected Feedback getUnknownCreateKeyFeedback()
protected void setUnkownCreateKeyFeedback(Feedback uckf)
protected Feedback getInvalidCreateKeyFeedback()
protected void setInvalidCreateKeyFeedback(Feedback ickf)
protected Feedback getUnknownOpenKeyFeedback()
protected void setUnknownOpenKeyFeedback(Feedback uokf)
protected Feedback getInvalidOpenKeyFeedback()
protected void setInvalidOpenKeyFeedback(Feedback iokf)
private static Feedback createFeedback(String type)
public final void promptCreateKey(PromptingKeyProvider provider)
PromptingKeyProviderUI
Upon return, the implementation is expected to update the common key
in provider.
Upon return, if provider.getKey() returns null,
prompting for the key is assumed to have been cancelled by the user.
In this case, the current and each subsequent call to
KeyProvider.getOpenKey() or KeyProvider.getCreateKey()
by the client results in an UnknownKeyException and the user
is not prompted anymore until the provider is reset by the
KeyManager.
Otherwise, the key is used as the common key, a clone of which is
provided to the client upon request.
Hint: If the user cancels the dialog, it is recommended to
leave the provider's key property simply unmodified.
This causes the old key to be reused and allows the client to
continue its operation as if the user would not have requested to
change the key.
Since TrueZIP 6.4, an implementation may also throw a
RuntimeException with any kind of UnknownKeyException
as its cause.
This will trigger the calling method in the
PromptingKeyProvider class to unwrap and pass on the
cause without changing its state.
This may be useful if prompting was interrupted by a call to
Thread.interrupt() while waiting on the Event Dispatch Thread.
In this case, another try to prompt the user should have the chance to
succeed instead of being cancelled without actually prompting the user
again.
To trigger this behaviour, the implementation should simply throw any
kind of RuntimeException with a
KeyPromptingInterruptedException as its cause.
promptCreateKey in interface PromptingKeyProviderUIprovider - The default key provider to store the result in.public final boolean promptUnknownOpenKey(PromptingKeyProvider provider)
PromptingKeyProviderUI
Upon return, the implementation is expected to update the common key
in provider.
Upon return, if provider.getKey() returns null,
prompting for the key is assumed to have been cancelled by the user.
In this case, the current and each subsequent call to
KeyProvider.getOpenKey() or KeyProvider.getCreateKey()
by the client results in an UnknownKeyException and the user
is not prompted anymore until the provider is reset by the
KeyManager.
Otherwise, the key is used as the common key, a clone of which is
provided to the client upon request.
Since TrueZIP 6.4, an implementation may also throw a
RuntimeException with any kind of UnknownKeyException
as its cause.
This will trigger the calling method in the
PromptingKeyProvider class to unwrap and pass on the
cause without changing its state.
This may be useful if prompting was interrupted by a call to
Thread.interrupt() while waiting on the Event Dispatch Thread.
In this case, another try to prompt the user should have the chance to
succeed instead of being cancelled without actually prompting the user
again.
To trigger this behaviour, the implementation should simply throw any
kind of RuntimeException with a
KeyPromptingInterruptedException as its cause.
promptUnknownOpenKey in interface PromptingKeyProviderUIprovider - The key provider to store the result in.
true if the user has requested to change the
provided key.public final boolean promptInvalidOpenKey(PromptingKeyProvider provider)
PromptingKeyProviderUIPromptingKeyProviderUI.promptUnknownOpenKey(de.schlichtherle.key.PromptingKeyProvider) is invalid.
Upon return, the implementation is expected to update the common key
in provider.
Upon return, if provider.getKey() returns null,
prompting for the key is assumed to have been cancelled by the user.
In this case, the current and each subsequent call to
KeyProvider.getOpenKey() or KeyProvider.getCreateKey()
by the client results in an UnknownKeyException and the user
is not prompted anymore until the provider is reset by the
KeyManager.
Otherwise, the key is used as the common key, a clone of which is
provided to the client upon request.
Since TrueZIP 6.4, an implementation may also throw a
RuntimeException with any kind of UnknownKeyException
as its cause.
This will trigger the calling method in the
PromptingKeyProvider class to unwrap and pass on the
cause without changing its state.
This may be useful if prompting was interrupted by a call to
Thread.interrupt() while waiting on the Event Dispatch Thread.
In this case, another try to prompt the user should have the chance to
succeed instead of being cancelled without actually prompting the user
again.
To trigger this behaviour, the implementation should simply throw any
kind of RuntimeException with a
KeyPromptingInterruptedException as its cause.
promptInvalidOpenKey in interface PromptingKeyProviderUIprovider - The key provider to store the result in.
true if the user has requested to change the
provided key.
protected void promptCreateKey(PromptingKeyProvider provider,
JComponent extraDataUI)
protected boolean promptOpenKey(PromptingKeyProvider provider,
boolean invalid,
JComponent extraDataUI)
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)
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.
|
TrueZIP 6.8.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||