issrg.acm
Class DefaultSavingUtility

java.lang.Object
  extended by issrg.acm.SavingUtility
      extended by issrg.acm.DefaultSavingUtility
All Implemented Interfaces:
Utility
Direct Known Subclasses:
DiskSavingUtility, LDAPSavingUtility, MultiChoiceSavingUtility, WebDAVSavingUtility

public abstract class DefaultSavingUtility
extends SavingUtility

This class defines the default behaviour of the Saving Utilities. It defines two specialised load/save methods, which are non-graphical anymore. Instead, it added an abstract getContentPanel method, which should return the panel with the graphical controls (apart from the load/save/cancel buttons). This panel will be displayed in a consistent manner, and if load/save button is pressed, the load/save method will be called. If cancel is pressed, no action is taken.

Author:
A.Otenko

Field Summary
protected static javax.swing.JDialog dialog
           
 int dialogMode
           
static int LOAD_MODE
           
protected static int[] modal_result
           
static int REVOKE_MODE
           
static int SAVE_MODE
           
 
Constructor Summary
DefaultSavingUtility()
           
 
Method Summary
 void approveSelection()
          This method should check, if the currently selected location is OK with the user (e.g.
 java.awt.Component attachControlButtons(java.awt.Component content, int dialogMode)
          This method allows to attach two control buttons at the bottom of the control panel, so the dialogs will have generic look.
 void cancelDialog()
           
abstract  java.awt.Component getContentPane(java.util.Map env, int dialogMode)
          This method returns the Component that displays all the controls for the load/saving dialog.
abstract  AttributeCertificate load()
          This method returns an Attribute Certificate loaded by the utility, as specified by its controls.
 AttributeCertificate load(java.awt.Frame frame, java.util.Map env)
          This is the default loading behaviour: this method gets the Content Pane of the concrete instance of the Saving Utility, then displays a dialog with this pane, and two buttons: Load and Cancel.
abstract  AttributeCertificate revoke()
          This method returns an Attribute Certificate loaded for revocation by the utility, as specified by its controls.
 AttributeCertificate revoke(java.awt.Frame frame, java.util.Map env)
          This is the default revocation behaviour: this method gets the Content Pane of the concrete instance of the Saving Utility, then displays a dialog with this pane, and two buttons: Revoke and Cancel.
abstract  void save(byte[] ac)
          This method saves the Attribute Certificate to the location, specified by the utility's controls.
 void save(java.awt.Frame frame, byte[] ac, java.util.Map env)
          This is the default saving behaviour: this method gets the Content Pane of the concrete instance of the Saving Utility, then displays a dialog with this pane, and two buttons: Save and Cancel.
 
Methods inherited from class issrg.acm.SavingUtility
delete, registerMe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOAD_MODE

public static final int LOAD_MODE
See Also:
Constant Field Values

SAVE_MODE

public static final int SAVE_MODE
See Also:
Constant Field Values

REVOKE_MODE

public static final int REVOKE_MODE
See Also:
Constant Field Values

dialog

protected static javax.swing.JDialog dialog

modal_result

protected static int[] modal_result

dialogMode

public int dialogMode
Constructor Detail

DefaultSavingUtility

public DefaultSavingUtility()
Method Detail

getContentPane

public abstract java.awt.Component getContentPane(java.util.Map env,
                                                  int dialogMode)
This method returns the Component that displays all the controls for the load/saving dialog. The boolean flag actually tells whether the operation is load or save.

Parameters:
env - - the environment that allows the component to initialise its fields and controls
dialogMode - - set to one of LOAD_MODE, SAVE_MODE or REVOKE_MODE, depending on the required content pane for the dialog
Returns:
java.awt.Component that contains all the necessary controls (without Load/Save/Cancel buttons)

load

public abstract AttributeCertificate load()
                                   throws ACCreationException
This method returns an Attribute Certificate loaded by the utility, as specified by its controls.

Returns:
issrg.ac.AttributeCertificate, loaded from the specified location; never null
Throws:
ACCreationException, - if loading or parsing the data failed
ACCreationException

revoke

public abstract AttributeCertificate revoke()
                                     throws ACCreationException
This method returns an Attribute Certificate loaded for revocation by the utility, as specified by its controls.

Returns:
issrg.ac.AttributeCertificate, loaded from the specified location; never null
Throws:
ACCreationException, - if loading or parsing the data failed
ACCreationException

save

public abstract void save(byte[] ac)
                   throws ACCreationException
This method saves the Attribute Certificate to the location, specified by the utility's controls.

Throws:
ACCreationException, - if saving the data failed
ACCreationException

approveSelection

public void approveSelection()
This method should check, if the currently selected location is OK with the user (e.g. he doesn't mind overwriting a file, etc)

Override to ask questions or display error messages.


cancelDialog

public void cancelDialog()

save

public void save(java.awt.Frame frame,
                 byte[] ac,
                 java.util.Map env)
          throws ACCreationException
This is the default saving behaviour: this method gets the Content Pane of the concrete instance of the Saving Utility, then displays a dialog with this pane, and two buttons: Save and Cancel. If Save is pressed, a splash window pops up with "Saving AC..." on it, and the save(byte [] ac) is called. If Cancel is pressed, the method exits.

Specified by:
save in class SavingUtility
Parameters:
frame - the java.awt.Frame, to which this utility can display a modal window
ac - a correctly encoded Attribute Certificate to save; the utility may want to check whether it is an AC (or get particular values from it, like Holder DN) by calling a BER decoder. For security reasons you should not assume you could save anything.
env - a java.util.Map with environmental variables there; the implementation is expected to get useful configuration information from there.
Throws:
ACCreationException

load

public AttributeCertificate load(java.awt.Frame frame,
                                 java.util.Map env)
                          throws ACCreationException
This is the default loading behaviour: this method gets the Content Pane of the concrete instance of the Saving Utility, then displays a dialog with this pane, and two buttons: Load and Cancel. If Load is pressed, a splash window pops up with "Loading AC..." on it, and the load() is called. If Cancel is pressed, the method exits and returns null.

Specified by:
load in class SavingUtility
Parameters:
frame - the java.awt.Frame, to which this utility can display a modal window
env - a java.util.Map with environmental variables there; the intention is to let the method know any configuration parameters it may want to know
Returns:
AttributeCertificate as loaded by the utility, or null, if Cancel is pressed
Throws:
ACCreationException

revoke

public AttributeCertificate revoke(java.awt.Frame frame,
                                   java.util.Map env)
                            throws ACCreationException
This is the default revocation behaviour: this method gets the Content Pane of the concrete instance of the Saving Utility, then displays a dialog with this pane, and two buttons: Revoke and Cancel. If Revoke is pressed, a splash window pops up with "Loading AC..." on it, and the revoke() is called. If Cancel is pressed, the method exits and returns null.

Specified by:
revoke in class SavingUtility
Parameters:
frame - the java.awt.Frame, to which this utility can display a modal window
env - a java.util.Map with environmental variables there; the intention is to let the method know any configuration parameters it may want to know
Returns:
AttributeCertificate as loaded by the utility, or null, if Cancel is pressed
Throws:
ACCreationException

attachControlButtons

public java.awt.Component attachControlButtons(java.awt.Component content,
                                               int dialogMode)
This method allows to attach two control buttons at the bottom of the control panel, so the dialogs will have generic look. However, you may return your own Content Pane, with all the controls there. Don't forget to call approveSelection, when the OK button is pressed, and cancelDialog, when Cancel button is pressed.

Parameters:
content - - the component with all the controls, but the OK/Cancel buttons
dialogMode - - the variable, specifying whether Load, Save or Revoke should be used to name the OK button