TrueZIP 6.8.1

de.schlichtherle.key.passwd.swing
Class PromptingKeyManager

java.lang.Object
  extended by de.schlichtherle.key.KeyManager
      extended by de.schlichtherle.key.PromptingKeyManager
          extended by de.schlichtherle.key.passwd.swing.PromptingKeyManager

public class PromptingKeyManager
extends PromptingKeyManager

A key manager which enables users to enter passwords or select key files as keys using a Swing GUI. This key manager is used by default unless the JVM is running in headless mode!

If a password is entered, then the run time type of the key is a char array, holding each password character. If a key file is selected, the file size must be 512 bytes or more, of which only the first 512 bytes are used as a byte array.

If this JVM is run in headless mode, all prompting is disabled.

Note that class loading and instantiation may happen in a JVM shutdown hook, so class initializers and constructors must behave accordingly. In particular, it's not permitted to construct or use a Swing GUI there.

This class is thread safe.

Since:
TrueZIP 6.0
Version:
$Id: PromptingKeyManager.java,v 1.6 2010/09/20 21:59:49 christian_schlichtherle Exp $
Author:
Christian Schlichtherle

Nested Class Summary
 
Nested classes/interfaces inherited from class de.schlichtherle.key.KeyManager
KeyManager.KeyProviderCommand
 
Constructor Summary
PromptingKeyManager()
          Constructs a new PromptingKeyManager.
 
Method Summary
protected  void ensurePromptingImpl()
          If this JVM is running in headless mode, then this method throws a KeyPromptingDisabledException with a HeadlessException as its cause.
static Window getParentWindow()
          Returns the parent window of the last focused window.
protected  boolean isPromptingImpl()
          Called by PromptingKeyManager.isPrompting() on the default key manager instance in order to implement its behaviour and allow subclasses to override it.
static void setParentWindow(Window w)
          Deprecated. You shouldn't use this method any more, but rely on the implementation in getParentWindow().
 
Methods inherited from class de.schlichtherle.key.PromptingKeyManager
getKeyProvider, isPrompting, mapPromptingKeyProviderUIType, register, resetCancelledPrompts, setPrompting, setPromptingImpl
 
Methods inherited from class de.schlichtherle.key.KeyManager
forEachKeyProvider, getInstance, getKeyProvider, mapKeyProviderType, moveKeyProvider, resetAndClearKeyProviders, resetAndRemoveKeyProvider, resetAndRemoveKeyProviders, resetKeyProvider, resetKeyProviders, setInstance, setKeyProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PromptingKeyManager

public PromptingKeyManager()
Constructs a new PromptingKeyManager. This instance maps the following key provider UI types using PromptingKeyManager.mapPromptingKeyProviderUIType(java.lang.String, java.lang.Class):
uiClassID uiClass
"PromptingKeyProvider" PromptingKeyProviderUI.class
"PromptingAesKeyProvider" PromptingAesKeyProviderUI.class

Method Detail

getParentWindow

public static Window getParentWindow()
Returns the parent window of the last focused window. If no window received the focus yet or is already made eligible for finalization, then any showing window is used.

In all cases, the first showing parent window which is found by searching the containment hierarchy upwards is preferrably returned.

As a last resort, if no window is showing, then JOptionPane's root frame is used.


setParentWindow

public static void setParentWindow(Window w)
Deprecated. You shouldn't use this method any more, but rely on the implementation in getParentWindow().

Sets the parent window of the dialog used for prompting the user for a key. The window is stored in a weak reference in order to allow it to get garbage collected if no thread is holding a strong reference to it from a root object.

Parameters:
w - The parent window to use for key prompting or null if a default window shall be used.
See Also:
getParentWindow()

isPromptingImpl

protected boolean isPromptingImpl()
Description copied from class: PromptingKeyManager
Called by PromptingKeyManager.isPrompting() on the default key manager instance in order to implement its behaviour and allow subclasses to override it. Subclasses should call the implementation in this class when overriding this method.

Overrides:
isPromptingImpl in class PromptingKeyManager
See Also:
PromptingKeyManager.setPromptingImpl(boolean), KeyManager.getInstance()

ensurePromptingImpl

protected void ensurePromptingImpl()
                            throws KeyPromptingDisabledException
If this JVM is running in headless mode, then this method throws a KeyPromptingDisabledException with a HeadlessException as its cause.

Overrides:
ensurePromptingImpl in class PromptingKeyManager
Throws:
KeyPromptingDisabledException

TrueZIP 6.8.1

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