issrg.utils.gui
Class ACViewer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by issrg.utils.gui.ACViewer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.TreeSelectionListener
Direct Known Subclasses:
ACPolicyViewer

public class ACViewer
extends javax.swing.JPanel
implements javax.swing.event.TreeSelectionListener, java.beans.PropertyChangeListener

This component can be used to browse the contents of an array of X.509 Attribute Certificates. It displays them as a tree, where the user can select a field to view, and a special window displays the value of the selected field as a string.

Author:
A.Otenko
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static int CANCEL_OPTION
           
protected static int CLOSE_OPTION
           
static int HORIZONTAL_SPLIT
          This value is used to specify horizontal.
protected static int OK_OPTION
           
static int VERTICAL_SPLIT
          This value is used to specify vertical split.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ACViewer()
          This constructor builds ACViewer with the default split (VERTICAL_SPLIT).
ACViewer(AttributeCertificate[] acs)
          This constructor builds the component given an array of X.509 Attribute Certificates.
ACViewer(AttributeCertificate[] acs, int split)
          This constructor builds the component given an array of X.509 Attribute Certificates and the direction of the component split.
ACViewer(byte[][] acb)
          This constructor builds ACViewer given the array of BER-encoded X.509 Attribute Certificates.
ACViewer(byte[][] acb, int split)
          This constructor builds the component given an array of BER encoded ACs and the direction of the component split.
ACViewer(int split)
          This constructor builds the component with an empty list of ACs.
ACViewer(javax.swing.JFileChooser fc)
          This constructor builds an ACViewer attached to a JFileChooser, so it is possible to browse the file contents "on the fly".
ACViewer(javax.swing.JFileChooser fc, int split)
          This constructor builds an ACViewer attached to a JFileChooser, so it is possible to browse the file contents "on the fly".
 
Method Summary
protected static java.lang.String byteArrayToString(byte[] bytes)
          This is a utility method that converts a byte array into a hexadecimal representation.
 java.lang.String getACName(int i)
           
 AttributeCertificate[] getACs()
          This method returns all the ACs that have been displayed by this component.
 AttributeCertificate getSelectedAC()
           
 int getSelectedIndex()
          This method returns the index of the selected X.509 Attribute Certificate.
protected  void init(int splitOrientation)
          This method initialises the view of the component with the specified slit direction.
protected static java.lang.String issuerSerialToString(IssuerSerial issuerSerial)
          This is a utility method converting a complex IssuerSerial construct into a human-readable string.
protected static java.lang.String objectDigestInfoToString(ObjectDigestInfo odi)
          This is a utility method that converts the complex ObjectDigestInfo construct into a human-readable string.
 void propertyChange(java.beans.PropertyChangeEvent e)
          This method is invoked by the JFileChooser component on which this ACViewer is an accessory, when some property has changed.
protected static java.lang.String serialToString(java.math.BigInteger bi)
          This is a utility method converting a serial number into a human-readable string.
 void setACs(AttributeCertificate[] acs)
          This method sets the AttributeCertificates to display.
 void setACs(AttributeCertificate[] acs, java.lang.String[] acsName)
           
 void setACs(java.util.Vector acs)
          This method sets the ACs to be displayed using a Vector.
 AttributeCertificate showSelectionDialog(java.awt.Frame owner, java.lang.String title)
          This is a utility method that displays a dialog with ACViewer component in it and two control buttons, so that a user can browse and select one of the ACs currently loaded into the ACViewer.
static AttributeCertificate showSelectionDialog(java.awt.Frame owner, java.lang.String title, byte[][] acs)
          This is a utility method that shows the dialog where the user can browse and pick an AC from a list.
static AttributeCertificate showSelectionDialog(java.awt.Frame owner, java.lang.String title, java.lang.String[] acs)
          This is a utility method that shows the dialog, where the user can browse and select the ACs that are loaded from a list of files.
 void valueChanged(javax.swing.event.TreeSelectionEvent e)
          This method is invoked by JTree, when some field has been selected by user.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERTICAL_SPLIT

public static final int VERTICAL_SPLIT
This value is used to specify vertical split. It has the same effect as JSplitPane.VERTICAL_SPLIT.

See Also:
Constant Field Values

HORIZONTAL_SPLIT

public static final int HORIZONTAL_SPLIT
This value is used to specify horizontal. It has the same effect as JSplitPane.HORIZONTAL_SPLIT.

See Also:
Constant Field Values

CLOSE_OPTION

protected static final int CLOSE_OPTION
See Also:
Constant Field Values

CANCEL_OPTION

protected static final int CANCEL_OPTION
See Also:
Constant Field Values

OK_OPTION

protected static final int OK_OPTION
See Also:
Constant Field Values
Constructor Detail

ACViewer

public ACViewer()
This constructor builds ACViewer with the default split (VERTICAL_SPLIT). The meaning of VERTICAL_SPLIT is the same as in JSplitPane.VERTICAL_SPLIT.


ACViewer

public ACViewer(int split)
This constructor builds the component with an empty list of ACs.

Parameters:
split - - the split orientation; see VERTICAL_SPLIT and HORIZONTAL_SPLIT
See Also:
VERTICAL_SPLIT, HORIZONTAL_SPLIT

ACViewer

public ACViewer(byte[][] acb,
                int split)
This constructor builds the component given an array of BER encoded ACs and the direction of the component split.

Parameters:
acb - - the array of BER-encoded X.509 Attribute Certificates; malformed ACs are ignored
split - - the split orientation; see VERTICAL_SPLIT and HORIZONTAL_SPLIT
Throws:
CodingException - if any of the ACs could not be decoded
See Also:
VERTICAL_SPLIT, HORIZONTAL_SPLIT

ACViewer

public ACViewer(byte[][] acb)
This constructor builds ACViewer given the array of BER-encoded X.509 Attribute Certificates. The component will be split in the default direction (VERTICAL_SPLIT).

Parameters:
acb - - the array of BER-encoded X.509 Attribute Certificates; malformed ACs are ignored

ACViewer

public ACViewer(AttributeCertificate[] acs)
This constructor builds the component given an array of X.509 Attribute Certificates. The split of the component is the default (VERTICAL_SPLIT).

Parameters:
acs - - the array of ACs to display

ACViewer

public ACViewer(AttributeCertificate[] acs,
                int split)
This constructor builds the component given an array of X.509 Attribute Certificates and the direction of the component split.

Parameters:
acs - - the array of ACs to display
split - - the orientation of the split; see VERTICAL_SPLIT and HORIZONTAL_SPLIT
See Also:
VERTICAL_SPLIT, HORIZONTAL_SPLIT

ACViewer

public ACViewer(javax.swing.JFileChooser fc,
                int split)
This constructor builds an ACViewer attached to a JFileChooser, so it is possible to browse the file contents "on the fly".

Parameters:
fc - - the JFileChooser to attach to
split - - the component split direction

ACViewer

public ACViewer(javax.swing.JFileChooser fc)
This constructor builds an ACViewer attached to a JFileChooser, so it is possible to browse the file contents "on the fly". It uses the default split: VERTICAL_SPLIT

Parameters:
fc - - the JFileChooser to attach to
Method Detail

getSelectedIndex

public int getSelectedIndex()
This method returns the index of the selected X.509 Attribute Certificate.

Returns:
the index of the selected X.509 Attribute Certificate in the array of ACs being browsed, or "-1" if none is selected

getSelectedAC

public AttributeCertificate getSelectedAC()
Returns:
the selected AttributeCertificate, or null, if none is selected

setACs

public void setACs(AttributeCertificate[] acs)
This method sets the AttributeCertificates to display. The selected index is reset (no ACs selected).

Parameters:
acs - - the array of AttributeCertificates that will be displayed by the component; if null, no ACs are displayed and the view is cleared

getACName

public java.lang.String getACName(int i)

setACs

public void setACs(AttributeCertificate[] acs,
                   java.lang.String[] acsName)

issuerSerialToString

protected static java.lang.String issuerSerialToString(IssuerSerial issuerSerial)
This is a utility method converting a complex IssuerSerial construct into a human-readable string.

Parameters:
issuerSerial - - the IssuerSerial to display
Returns:
a string of a form "PKC issuer:\n...\nPKC Serial Number:\n..."

serialToString

protected static java.lang.String serialToString(java.math.BigInteger bi)
This is a utility method converting a serial number into a human-readable string.

Parameters:
bi - - the serial number to display
Returns:
a hexadecimal string of the serial number

byteArrayToString

protected static java.lang.String byteArrayToString(byte[] bytes)
This is a utility method that converts a byte array into a hexadecimal representation. The lowest byte (index 0) of the array goes first.

Parameters:
bytes - - the byte array to convert into a String
Returns:
a hexadecimal string representation of the byte array with the lowest byte going first

objectDigestInfoToString

protected static java.lang.String objectDigestInfoToString(ObjectDigestInfo odi)
This is a utility method that converts the complex ObjectDigestInfo construct into a human-readable string.

Parameters:
odi - - the ObjectDigestInfo to display
Returns:
a human-readable string of a form "Object Type: ...\nDigest Algorithm: ...\nObject Digest:\n..."

setACs

public void setACs(java.util.Vector acs)
This method sets the ACs to be displayed using a Vector.

Parameters:
acs - - the Vector of ACs to be displayed; if null, the view is cleared; each element of the Vector must be of issrg.ac.AttributeCertificate class

init

protected void init(int splitOrientation)
This method initialises the view of the component with the specified slit direction.

Parameters:
splitOrientation - - the direction of the component split; must be either VERTICAL_SPLIT or HORIZONTAL_SPLIT
See Also:
VERTICAL_SPLIT, HORIZONTAL_SPLIT

valueChanged

public void valueChanged(javax.swing.event.TreeSelectionEvent e)
This method is invoked by JTree, when some field has been selected by user.

Specified by:
valueChanged in interface javax.swing.event.TreeSelectionListener

showSelectionDialog

public static AttributeCertificate showSelectionDialog(java.awt.Frame owner,
                                                       java.lang.String title,
                                                       byte[][] acs)
This is a utility method that shows the dialog where the user can browse and pick an AC from a list. If the ACs are malformed, or no selection was made, null is returned.

Parameters:
owner - - the Frame to which the dialog will be modal
title - - the title of the dialog
acs - - the array of BER-encoded ACs
Returns:
AttributeCertificate that was selected, or null, if no selection was made

showSelectionDialog

public static AttributeCertificate showSelectionDialog(java.awt.Frame owner,
                                                       java.lang.String title,
                                                       java.lang.String[] acs)
This is a utility method that shows the dialog, where the user can browse and select the ACs that are loaded from a list of files. Malformed ACs are ignored.

Parameters:
owner - - the Frame to which the dialog will be modal
title - - the title of the dialog
acs - - the list of filenames with ACs
Returns:
AttributeCertificate that was selected, or null, if no selection was made

showSelectionDialog

public AttributeCertificate showSelectionDialog(java.awt.Frame owner,
                                                java.lang.String title)
This is a utility method that displays a dialog with ACViewer component in it and two control buttons, so that a user can browse and select one of the ACs currently loaded into the ACViewer.

Parameters:
owner - - the Frame to which the dialog will be modal
title - - the title of the dialog
Returns:
AttributeCertificate that was selected, or null, if no selection was made

getACs

public AttributeCertificate[] getACs()
This method returns all the ACs that have been displayed by this component.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
This method is invoked by the JFileChooser component on which this ACViewer is an accessory, when some property has changed. ACViewer checks if a new file has been selected, and if so, attempts to display it as an AC. If it is not an AC, or a malformed AC, the view is simply cleared.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener