com.clearfield.security
Class KeyStorePanel

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 com.clearfield.security.KeyStorePanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ListSelectionListener

public class KeyStorePanel
extends javax.swing.JPanel
implements javax.swing.event.ListSelectionListener

A panel which manages the handling of a key store. This is where the majority of the processing is handled.

Copyright © 2006 Clearfield Ltd. This software is distributed under the BSD license. See the accompanying license.txt for details.

Version:
1.0.0
Author:
Dr. David J. Knowles
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  java.lang.String filename
           
protected  java.security.KeyStore keyStore
           
protected  java.lang.String keyStorePassword
           
protected  javax.swing.JPanel left
           
protected  javax.swing.JList lstCertificates
           
protected  javax.swing.DefaultListModel lstCertificatesModel
           
protected  CertificateDetailPanel pnlDetails
           
protected  javax.swing.JSplitPane splitPane
           
 
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
KeyStorePanel()
          Constructor for the panel.
 
Method Summary
 void exportPemFile(java.lang.String filename)
          This function exports the selected certificate to a PEM formatted certificate file.
 void exportPkcs12File(java.lang.String filename)
          This function exports the selected certificate to a PKCS-12 formatted certificate file.
 java.lang.String getFilename()
          Returns the filename of the key store.
 void importPemFile(java.lang.String filename)
          This function imports a PEM formatted certificate file into the key store.
 void importPkcs12File(java.lang.String filename)
          This function imports a PKCS-12 formatted certificate file into the key store.
protected  void init()
          Sets up the panel for use.
 boolean isActiveKeyStore()
          This function returns if the key store is active and available for use.
protected  void openKeyStore()
          Opens a key store.
 void removeAllCertificates()
          Removes all the certificates from the key store.
 void removeSelectedCertificate()
          Removes the selected certificate from the key store.
 void renameSelectedCertificate()
          Renames the selected certificate.
protected  void resetPanel()
          Resets the panel back to defaults.
 boolean sanityCheck()
          Sanity check function which ensures that everything is ready for an operation.
 void saveKeyStore()
          Saves the key store to disk.
 void savekeyStoreAs(java.lang.String filename)
          Saves the key store using the specified filename.
 void setFilename(java.lang.String filename)
          Sets the filename of the key store.
protected  void setUpFromKeyStore(java.lang.String password)
          Sets up the panel using the information in the key store.
 void valueChanged(javax.swing.event.ListSelectionEvent e)
          If the list selection is changed the newly selected certificate information is used in the details view.
 
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

splitPane

protected javax.swing.JSplitPane splitPane

left

protected javax.swing.JPanel left

lstCertificatesModel

protected javax.swing.DefaultListModel lstCertificatesModel

lstCertificates

protected javax.swing.JList lstCertificates

pnlDetails

protected CertificateDetailPanel pnlDetails

filename

protected java.lang.String filename

keyStore

protected java.security.KeyStore keyStore

keyStorePassword

protected java.lang.String keyStorePassword
Constructor Detail

KeyStorePanel

public KeyStorePanel()
Constructor for the panel.

Method Detail

init

protected void init()
Sets up the panel for use.


saveKeyStore

public void saveKeyStore()
                  throws java.io.IOException
Saves the key store to disk.

Throws:
java.io.IOException - with any errors saving.

savekeyStoreAs

public void savekeyStoreAs(java.lang.String filename)
                    throws java.io.IOException
Saves the key store using the specified filename.

Parameters:
filename - String filename of the file to use.
Throws:
java.io.IOException - with any errors saving.

importPkcs12File

public void importPkcs12File(java.lang.String filename)
This function imports a PKCS-12 formatted certificate file into the key store.

Parameters:
filename - String filename of the certificate to load.

sanityCheck

public boolean sanityCheck()
Sanity check function which ensures that everything is ready for an operation.

Returns:
boolean true if the system can perform the operation.

importPemFile

public void importPemFile(java.lang.String filename)
This function imports a PEM formatted certificate file into the key store.

Parameters:
filename - String filename of the certificate to load.

exportPkcs12File

public void exportPkcs12File(java.lang.String filename)
This function exports the selected certificate to a PKCS-12 formatted certificate file.

Parameters:
filename - String filename of the certificate to save.

exportPemFile

public void exportPemFile(java.lang.String filename)
This function exports the selected certificate to a PEM formatted certificate file.

Parameters:
filename - String filename of the certificate to save.

getFilename

public java.lang.String getFilename()
Returns the filename of the key store.

Returns:
Returns the filename.

setFilename

public void setFilename(java.lang.String filename)
Sets the filename of the key store.

Parameters:
filename - The filename to set.

isActiveKeyStore

public boolean isActiveKeyStore()
This function returns if the key store is active and available for use.

Returns:
boolean true if the key store is ready for use.

renameSelectedCertificate

public void renameSelectedCertificate()
Renames the selected certificate. This function requests the name to use.


removeSelectedCertificate

public void removeSelectedCertificate()
Removes the selected certificate from the key store.


removeAllCertificates

public void removeAllCertificates()
Removes all the certificates from the key store.


resetPanel

protected void resetPanel()
Resets the panel back to defaults.


openKeyStore

protected void openKeyStore()
Opens a key store. This function requests the password to unlock the key store. If the file name is known the corresponding file is opened else a new key store is created.


setUpFromKeyStore

protected void setUpFromKeyStore(java.lang.String password)
Sets up the panel using the information in the key store.

Parameters:
password - String password to use when unlocking the key store.

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
If the list selection is changed the newly selected certificate information is used in the details view.

Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener
Parameters:
e - ListSelectionEvent which contains information on the list selection change.