ds.ov2.gui
Class Gui_actions

java.lang.Object
  extended by ds.ov2.gui.Gui_actions

public class Gui_actions
extends Object

Actions for the main window of the graphical demonstrator.

CPP Preprocessing
no cpp preprocessing needed
Execution Environment:
host
Author:
Hendrik Tews
Version:
$Revision: 1.29 $
Last Commit:
$Date: 2010-03-12 15:40:21 $ by $Author: tews $

Nested Class Summary
 class Gui_actions.Bases_selection_abort_exception
          Exception for when the base selection dialog is aborted.
 
Field Summary
private  Applet_list_actions applet_list_actions
          Actions for the applet list dialog.
private  Bases_actions bases_actions
          Actions for the base selection dialog.
private  Card_protocols card_protocols
          Card protocol instance.
private  Config_actions config_actions
          Actions for the config dialog.
private  boolean initialization_finished
          GUI initialization order seems to depend in some parts on the order in which the GUI elements have been created in the netbeans GUI.
 Progress_messages progress_window
          The progress window.
 Terminal_thread terminal_thread
          Terminal thread instance.
 
Constructor Summary
Gui_actions(Card_protocols card_protocols)
          Constructor.
 
Method Summary
 void applet_selection_changed(ItemEvent e, Ov_demo_gui gui)
          Called when the applet type is changed in the applet type combobox.
(package private)  void apply_config(Config_window cw)
          Change our state to match to the new configuration.
 BigInteger bigint_of_number_spinner(JSpinner spinner)
          Read the value of a spinner holding a BigInteger.
 int check_key_size(Ov_demo_gui gui, int user_key_size)
          Check whether the user selected user_key_size makes sense for the current applet type.
 void clear_message_pane(JTextPane pane)
          Clear a message pane.
(package private)  void default_initialization(Ov_demo_gui gui)
          Default initialization of the internal state.
 void disable_card_maintenance(Ov_demo_gui gui)
          Method to be called when a card is removed and the PTLS office tab is selected.
 void enable_card_maintenance(Ov_demo_gui gui)
          Method to be called when a card is inserted and the PTLS office tab is selected.
 void entry_automatic_changed(Ov_demo_gui gui)
          Method to be called when the run-automatically check box changes state in the entry gate tab.
 void entry_run_button(Ov_demo_gui gui)
          Method to be called when the run-entry-protocol button is pressed in the entry gate tab.
 Applet_list_window get_applet_list_window()
          Return the applet list window or throw an assertion if no such window is registered.
 void gui_error(Component parent_window, String message, String title)
          Show an error message to the user and wait until he acknoledges.
 void gui_warning(Component parent_window, String message, String title)
          Show a warning message to the user and wait until he acknowledges.
 int int_of_number_spinner(JSpinner spinner)
          Read the value of a spinner holding an integer.
 void lenstra_exponent_box_changed(ItemEvent e, Ov_demo_gui gui)
          Method to be called when the automatic exponent size check box in the PTLS office tab is selected.
 Number number_of_number_spinner(JSpinner spinner)
          Read out the value of a spinner.
 void progress_dismiss_button()
          Action for the dismiss button of the progress window.
 void ptls_automaton_resign_button(Ov_demo_gui gui)
          Method to be called when the obtain-new-signature button is pressed in the PTLS automaton tab.
 void ptls_office_card_status(Ov_demo_gui gui)
          Method to be called when the status-&-delete button in the PTLS office tab is pressed.
 void ptls_office_install_all(Ov_demo_gui gui)
          Method to be called when the reinstall-and-personalize button is pressed.
 void ptls_office_install_applet(Ov_demo_gui gui)
          Method to be called when the install button is pressed.
 void ptls_office_personalize(Ov_demo_gui gui)
          Action method for the PTLS office "Personalize" button.
 void ptls_office_reset_applet(Ov_demo_gui gui)
          Method to be called when the applet reset button is pressed.
(package private)  void ptls_parameters_missing(Ov_demo_gui gui)
          Method to be called when the user tries to select a different tab without having configured a set of PTLS parameters.
 void ptls_params_invalidate_action(Ov_demo_gui gui)
          Method to be called when we lost our PTLS parameters.
 void ptls_params_load_from_file(Ov_demo_gui gui, String file_name)
          Read PTLS parameters from file file.
 void ptls_params_load(Ov_demo_gui gui)
          Method to be called when the Load-from-file button for loading PTLS parameters is pressed.
 void ptls_params_new_ex(Ov_demo_gui gui)
          Method to be called when the create-new button to generate new PTLS parameters is pressed.
 void ptls_params_new(Ov_demo_gui gui)
          Method to be called when the create-new button to generate new PTLS parameters is pressed.
 void ptls_params_ready_action(Ov_demo_gui gui)
          Method to be called when we obtained some PTLS parameters.
 void ptls_params_save(Ov_demo_gui gui)
          Method to be called when Save-to-file button for saving the current PTLS parameters is pressed.
 void report_exception_maybe(Component parent_window, String title, Exception ex, String ex_name)
          Possibly report an escaping exception as error message.
 void rsa_key_size_change(Ov_demo_gui gui)
          Method to be called when the exponent length must be adjusted to the base langth.
(package private)  void select_automaton(Ov_demo_gui gui)
          Method to be called when the PTLS automaton tab is selected.
(package private)  void select_entry_gate(Ov_demo_gui gui)
          Method to be called when the entry gate tab is selected.
(package private)  void select_office(Ov_demo_gui gui)
          Method to be executed when the PTLS office tab is selected.
 void set_bases(Ov_demo_gui gui)
          Method to be called at the end of PTLS parameter generation when the choose-bases-randomly box is not checked.
(package private)  void start_action(Ov_demo_gui gui)
          Run on application startup.
(package private)  void toolbar_config_button(Ov_demo_gui gui)
          Method to run when the config button in the toolbar is pressed.
 void toolbar_progress_button()
          Action for the progress log button in the toolbar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

card_protocols

private final Card_protocols card_protocols
Card protocol instance.


config_actions

private final Config_actions config_actions
Actions for the config dialog.


bases_actions

private final Bases_actions bases_actions
Actions for the base selection dialog.


applet_list_actions

private final Applet_list_actions applet_list_actions
Actions for the applet list dialog.


terminal_thread

public Terminal_thread terminal_thread
Terminal thread instance.


progress_window

public Progress_messages progress_window
The progress window. Initialized from the outside from Ov_demo, because this class and Progress_messages are mutually dependent and an instance of this class is created first.


initialization_finished

private boolean initialization_finished
GUI initialization order seems to depend in some parts on the order in which the GUI elements have been created in the netbeans GUI. Further it works bottom-up, that is the applet-type combobox starts event processing before the PTLS-office-tabulator a component-shown event. The following boolean is used to disable some actions in some event processing routines that would otherwise run before GUI initialization is complete, see default_initialization.

Constructor Detail

Gui_actions

public Gui_actions(Card_protocols card_protocols)
Constructor. Remembers the card protocols instance locally. Does not start the terminal thread, because the GUI instance is not available here, see select_office.

Parameters:
card_protocols - instance with card and terminal actions
Method Detail

default_initialization

void default_initialization(Ov_demo_gui gui)
Default initialization of the internal state. Runs when the main window is first displayed. Some GUI elements might trigger event processing code before that point. Such code is therefore disabled via initialization_finished. This method sets Gui_state.card_terminal, starts the terminal thread and sets its first action and initializes the key size spinners acording to the default applet type. At the very end appropriate actions are executed to satisfy the command line options.

Parameters:
gui - the GUI window

start_action

void start_action(Ov_demo_gui gui)
Run on application startup. Organizes default initialization as far as necessary.

Parameters:
gui - the GUI window

gui_warning

public void gui_warning(Component parent_window,
                        String message,
                        String title)
Show a warning message to the user and wait until he acknowledges.

Parameters:
parent_window - the parent window of the warning
message - warning to show
title - title of the warning dialog

gui_error

public void gui_error(Component parent_window,
                      String message,
                      String title)
Show an error message to the user and wait until he acknoledges.

Parameters:
parent_window - the parent window of the warning
message - warning to show
title - title of the warning dialog

clear_message_pane

public void clear_message_pane(JTextPane pane)
Clear a message pane.

Parameters:
pane - the text pane to clear

apply_config

void apply_config(Config_window cw)
Change our state to match to the new configuration. Called when the config dialog is closed with the OK button.

Parameters:
cw - the just closed config window.

toolbar_config_button

void toolbar_config_button(Ov_demo_gui gui)
Method to run when the config button in the toolbar is pressed. Creates and displays the config dialog and changes the program state when the config window is closed.

Parameters:
gui - the GUI window

toolbar_progress_button

public void toolbar_progress_button()
Action for the progress log button in the toolbar. Makes the progress window visible.


progress_dismiss_button

public void progress_dismiss_button()
Action for the dismiss button of the progress window. Makes the progress window invisible.


select_office

void select_office(Ov_demo_gui gui)
Method to be executed when the PTLS office tab is selected. Interrupts the terminal thread to change accordingly.

Parameters:
gui - the GUI window

ptls_parameters_missing

void ptls_parameters_missing(Ov_demo_gui gui)
Method to be called when the user tries to select a different tab without having configured a set of PTLS parameters. Displays an error message and changes back to the PTLS office tab.

Parameters:
gui - the GUI window

select_automaton

void select_automaton(Ov_demo_gui gui)
Method to be called when the PTLS automaton tab is selected. Interrupts the terminal thread to change accordingly.

Parameters:
gui - the GUI window

select_entry_gate

void select_entry_gate(Ov_demo_gui gui)
Method to be called when the entry gate tab is selected. Interrupts the terminal thread to change accordingly.

Parameters:
gui - the GUI window

applet_selection_changed

public void applet_selection_changed(ItemEvent e,
                                     Ov_demo_gui gui)
Called when the applet type is changed in the applet type combobox. Checks and, if necessary, adjusts the key sizes and invalidates the PTLS parameters. The last point is necessary because the PTLS parameters contain data structures that depend on the number of Montgomery digits and therefore on the applet type.

Parameters:
e - item event of the combo box
gui - the GUI window

lenstra_exponent_box_changed

public void lenstra_exponent_box_changed(ItemEvent e,
                                         Ov_demo_gui gui)
Method to be called when the automatic exponent size check box in the PTLS office tab is selected. Adjusts the exponent size to match the security level of the RSA key size, using A. Lenstra's estimations.

Parameters:
e - event from the check box, telling us whether it got selected
gui - the GUI window

number_of_number_spinner

public Number number_of_number_spinner(JSpinner spinner)
Read out the value of a spinner. We have spinners holding int's and BigInteger's. Therefore this method returns some super class, which must be downcast appropriately.

Parameters:
spinner - the spinner to read out

int_of_number_spinner

public int int_of_number_spinner(JSpinner spinner)
Read the value of a spinner holding an integer.

Parameters:
spinner - the spinner to read out

bigint_of_number_spinner

public BigInteger bigint_of_number_spinner(JSpinner spinner)
Read the value of a spinner holding a BigInteger.

Parameters:
spinner - the spinner to read out

check_key_size

public int check_key_size(Ov_demo_gui gui,
                          int user_key_size)
Check whether the user selected user_key_size makes sense for the current applet type. If not warnings are displayed and, at the users options, the key size is adjusted.

Parameters:
gui - the GUI window
user_key_size - the key size the user selected
Returns:
adjusted key size or user_key_size if no adjustments were made

rsa_key_size_change

public void rsa_key_size_change(Ov_demo_gui gui)
Method to be called when the exponent length must be adjusted to the base langth. This happens when (1) the RSA key size is changed and (2) the automatic exponent size box is checked. If there is an invalid value in the RSA key size spinner it is reverted to last known valid one.

Parameters:
gui - the GUI window

ptls_params_ready_action

public void ptls_params_ready_action(Ov_demo_gui gui)
Method to be called when we obtained some PTLS parameters.

Parameters:
gui - the GUI window

ptls_params_invalidate_action

public void ptls_params_invalidate_action(Ov_demo_gui gui)
Method to be called when we lost our PTLS parameters.

Parameters:
gui - the GUI window

ptls_params_load_from_file

public void ptls_params_load_from_file(Ov_demo_gui gui,
                                       String file_name)
Read PTLS parameters from file file. Adapt the state of the GUI apropriately if successful. Displays an error message if reading fails.

Parameters:
gui - the GUI window
file_name - the file to read

ptls_params_load

public void ptls_params_load(Ov_demo_gui gui)
Method to be called when the Load-from-file button for loading PTLS parameters is pressed. Displays a file chooser and diverts to ptls_params_load_from_file for the real work.

Parameters:
gui - the GUI window

ptls_params_save

public void ptls_params_save(Ov_demo_gui gui)
Method to be called when Save-to-file button for saving the current PTLS parameters is pressed. Displays a file chooser, saves the parameters and displays an error if anything goes wrong.

Parameters:
gui - the GUI window

set_bases

public void set_bases(Ov_demo_gui gui)
               throws Gui_actions.Bases_selection_abort_exception
Method to be called at the end of PTLS parameter generation when the choose-bases-randomly box is not checked. Displays the bases selection dialog and changes the parameters acordingly afterwards.

Parameters:
gui - the GUI window
Throws:
Gui_actions.Bases_selection_abort_exception - if the base selection dialog is aborted
To Do:
fix the various bugs in this method that make the base selection dialog unusable

ptls_params_new_ex

public void ptls_params_new_ex(Ov_demo_gui gui)
                        throws NoSuchAlgorithmException,
                               Gui_actions.Bases_selection_abort_exception
Method to be called when the create-new button to generate new PTLS parameters is pressed. This method contains the functionality, exceptions are caught in the exception wrapper ptls_params_new method.

Parameters:
gui - the GUI window
Throws:
NoSuchAlgorithmException - if no provider for RSA key generation is present
Gui_actions.Bases_selection_abort_exception - if the base selection dialog is aborted.

report_exception_maybe

public void report_exception_maybe(Component parent_window,
                                   String title,
                                   Exception ex,
                                   String ex_name)
Possibly report an escaping exception as error message. To be called with ex being a null reference, if there is no exception.

Parameters:
parent_window - parent window for the error dialog
title - title of the error dialog
ex - the escaping exception or null
ex_name - the exception name

ptls_params_new

public void ptls_params_new(Ov_demo_gui gui)
Method to be called when the create-new button to generate new PTLS parameters is pressed. Exception wrapper of ptls_params_new_ex, which implements the functionality. This method only catches all possible exceptions and displays appropriate error messages.

Parameters:
gui - the GUI window

enable_card_maintenance

public void enable_card_maintenance(Ov_demo_gui gui)
Method to be called when a card is inserted and the PTLS office tab is selected. Enables all the buttons in the PTLS office tab.

Parameters:
gui - the GUI window

disable_card_maintenance

public void disable_card_maintenance(Ov_demo_gui gui)
Method to be called when a card is removed and the PTLS office tab is selected. Disables all the buttons in the PTLS office tab.

Parameters:
gui - the GUI window

get_applet_list_window

public Applet_list_window get_applet_list_window()
Return the applet list window or throw an assertion if no such window is registered.

Returns:
the applet list window instance

ptls_office_card_status

public void ptls_office_card_status(Ov_demo_gui gui)
Method to be called when the status-&-delete button in the PTLS office tab is pressed. Create a new applet list dialog register it with applet_list_actions and display it. When finished deregister the window with applet_list_actions.

Parameters:
gui - the GUI window

ptls_office_install_applet

public void ptls_office_install_applet(Ov_demo_gui gui)
Method to be called when the install button is pressed. Tell the terminal window to install the selected applet.

Parameters:
gui - the GUI window

ptls_office_reset_applet

public void ptls_office_reset_applet(Ov_demo_gui gui)
Method to be called when the applet reset button is pressed. Tell the terminal window to reset the applet.

Parameters:
gui - the GUI window

ptls_office_personalize

public void ptls_office_personalize(Ov_demo_gui gui)
Action method for the PTLS office "Personalize" button. Starts the personalize_action in the Terminal_thread, which does the job.


ptls_office_install_all

public void ptls_office_install_all(Ov_demo_gui gui)
Method to be called when the reinstall-and-personalize button is pressed. Tell the terminal thread to reinstall and personalize.

Parameters:
gui - the GUI window

ptls_automaton_resign_button

public void ptls_automaton_resign_button(Ov_demo_gui gui)
Method to be called when the obtain-new-signature button is pressed in the PTLS automaton tab. Tell the terminal thread about it.

Parameters:
gui - the GUI window

entry_run_button

public void entry_run_button(Ov_demo_gui gui)
Method to be called when the run-entry-protocol button is pressed in the entry gate tab. Tell the terminal thread about it.

Parameters:
gui - the GUI window

entry_automatic_changed

public void entry_automatic_changed(Ov_demo_gui gui)
Method to be called when the run-automatically check box changes state in the entry gate tab. Restart the entry gate waiting action of the terminal thread with the new setting.

Parameters:
gui - the GUI window