TrueZIP 6.8.1

de.schlichtherle.key.passwd.console
Class PromptingKeyProviderUI

java.lang.Object
  extended by de.schlichtherle.key.passwd.console.PromptingKeyProviderUI
All Implemented Interfaces:
PromptingKeyProviderUI
Direct Known Subclasses:
PromptingAesKeyProviderUI

public class PromptingKeyProviderUI
extends Object
implements PromptingKeyProviderUI

A out I/O based user interface to prompt for passwords. This class is thread safe.

Since:
TrueZIP 6.4
Version:
$Id: PromptingKeyProviderUI.java,v 1.4 2010/08/20 13:09:43 christian_schlichtherle Exp $
Author:
Christian Schlichtherle

Field Summary
protected static Console con
          The console to use for I/O.
protected static ResourceBundle resources
           
 
Constructor Summary
PromptingKeyProviderUI()
           
 
Method Summary
protected  Console printf(String format)
           
protected  Console printf(String format, Object arg)
           
 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 promptExtraData(PromptingKeyProvider provider)
           
 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.
 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.
protected  String readLine(String format)
           
protected  String readLine(String format, Object arg)
           
protected  char[] readPassword(String format)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resources

protected static final ResourceBundle resources

con

protected static final Console con
The console to use for I/O. If null, the prompt methods are never called, so it's safe to assume that it's not null in these methods.

Constructor Detail

PromptingKeyProviderUI

public PromptingKeyProviderUI()
Method Detail

promptCreateKey

public final void promptCreateKey(PromptingKeyProvider provider)
Description copied from interface: PromptingKeyProviderUI
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.

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.

Specified by:
promptCreateKey in interface PromptingKeyProviderUI
Parameters:
provider - The default key provider to store the result in.

promptExtraData

protected void promptExtraData(PromptingKeyProvider provider)

promptUnknownOpenKey

public final boolean promptUnknownOpenKey(PromptingKeyProvider provider)
Description copied from interface: PromptingKeyProviderUI
Prompts the user for the key which may be used to open an existing protected resource in order to access its contents.

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.

Specified by:
promptUnknownOpenKey in interface PromptingKeyProviderUI
Parameters:
provider - The key provider to store the result in.
Returns:
true if the user has requested to change the provided key.

promptInvalidOpenKey

public final boolean promptInvalidOpenKey(PromptingKeyProvider provider)
Description copied from interface: PromptingKeyProviderUI
Prompts the user for the key which may be used to open an existing protected resource in order to access its contents. This is called if the key returned by a previous call to PromptingKeyProviderUI.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.

Specified by:
promptInvalidOpenKey in interface PromptingKeyProviderUI
Parameters:
provider - The key provider to store the result in.
Returns:
true if the user has requested to change the provided key.

printf

protected final Console printf(String format)

printf

protected final Console printf(String format,
                               Object arg)

readLine

protected final String readLine(String format)

readLine

protected final String readLine(String format,
                                Object arg)

readPassword

protected final char[] readPassword(String format)

TrueZIP 6.8.1

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