org.mailster.gui.crypto
Class CertificateDialog

java.lang.Object
  extended by org.eclipse.jface.window.Window
      extended by org.eclipse.jface.dialogs.Dialog
          extended by org.mailster.gui.crypto.CertificateDialog
All Implemented Interfaces:
org.eclipse.jface.window.IShellProvider

public class CertificateDialog
extends org.eclipse.jface.dialogs.Dialog

---
Mailster (C) 2007-2009 De Oliveira Edouard

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

See  Mailster Web Site
---

CertificateDialog.java - A dialog that shows informations about certificates.

Version:
$Revision: 1.4 $, $Date: 2008/12/06 13:57:17 $
Author:
Edouard De Oliveira

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jface.window.Window
org.eclipse.jface.window.Window.IExceptionHandler
 
Field Summary
private  java.security.cert.Certificate[] chain
          The certificate chain to display.
private  javax.mail.internet.MimeMessage message
          The message that contains the certificate to display.
private  boolean showValidationMessages
          true if validation messages should be shown.
 
Fields inherited from class org.eclipse.jface.dialogs.Dialog
blockedHandler, buttonBar, DIALOG_DEFAULT_BOUNDS, DIALOG_PERSISTLOCATION, DIALOG_PERSISTSIZE, dialogArea, DLG_IMG_ERROR, DLG_IMG_HELP, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING, ELLIPSIS
 
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK
 
Constructor Summary
CertificateDialog(org.eclipse.swt.widgets.Shell shell, java.security.cert.Certificate[] chain)
          Creates a new CertificateDialog instance.
CertificateDialog(org.eclipse.swt.widgets.Shell shell, javax.mail.internet.MimeMessage msg)
          Creates a new CertificateDialog instance.
 
Method Summary
private  void addCertificateFieldLabel(org.eclipse.swt.widgets.Composite composite, java.lang.String label, java.lang.String value)
           
protected  void configureShell(org.eclipse.swt.widgets.Shell shell)
          Configures the Shell representing this CertificateDialog.
protected  void createButtonsForButtonBar(org.eclipse.swt.widgets.Composite parent)
          Adds the buttons to this CertificateDialog's button bar.
protected  org.eclipse.swt.widgets.Control createContents(org.eclipse.swt.widgets.Composite parent)
          Creates the contents of this CertificateDialog.
private  void createDetailTabItem(org.eclipse.swt.custom.CTabFolder folder, org.eclipse.swt.custom.CTabItem item)
           
protected  org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
          Creates and returns the contents of the upper part of this CertificateDialog (above the button bar).
private  void createGeneralTabItem(org.eclipse.swt.custom.CTabFolder folder, org.eclipse.swt.custom.CTabItem item)
           
private  java.lang.String formatDate(java.util.Date d)
           
private  void generateCertificateChainTree(org.eclipse.swt.widgets.TreeItem root, java.security.cert.Certificate[] certs)
           
private  void generateCertificateChainTree(org.eclipse.swt.widgets.Tree tree, org.eclipse.swt.widgets.Tree details, org.eclipse.swt.widgets.Text valueText)
           
private  void generateCertificateStructureTree(org.eclipse.swt.widgets.Tree tree, org.eclipse.swt.widgets.Text valueText, java.security.cert.Certificate selected)
           
private  void generateExtensionNode(org.eclipse.swt.widgets.TreeItem parent, java.security.cert.X509Certificate cert, org.bouncycastle.asn1.x509.X509Extensions extensions, java.lang.String oid)
           
private  org.eclipse.swt.widgets.TreeItem generateNode(org.eclipse.swt.widgets.TreeItem parent, java.lang.String childName, java.lang.Object data)
           
private  java.security.cert.X509Certificate getSubjectCertificate()
           
private  void parseCertificateChains(org.eclipse.swt.widgets.TreeItem root)
           
private  java.lang.Object[] reverseArray(java.lang.Object[] array)
           
 
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, buttonPressed, cancelPressed, close, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, createButton, createButtonBar, dialogFontIsDefault, getBlockedHandler, getButton, getButtonBar, getCancelButton, getDialogArea, getDialogBoundsSettings, getDialogBoundsStrategy, getImage, getInitialLocation, getInitialSize, getOKButton, initializeBounds, initializeDialogUnits, isResizable, okPressed, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
 
Methods inherited from class org.eclipse.jface.window.Window
canHandleShellCloseEvent, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

message

private javax.mail.internet.MimeMessage message
The message that contains the certificate to display.


chain

private java.security.cert.Certificate[] chain
The certificate chain to display.


showValidationMessages

private boolean showValidationMessages
true if validation messages should be shown.

Constructor Detail

CertificateDialog

public CertificateDialog(org.eclipse.swt.widgets.Shell shell,
                         javax.mail.internet.MimeMessage msg)
Creates a new CertificateDialog instance.

Parameters:
shell - the parent shell

CertificateDialog

public CertificateDialog(org.eclipse.swt.widgets.Shell shell,
                         java.security.cert.Certificate[] chain)
Creates a new CertificateDialog instance.

Parameters:
shell - the parent shell
Method Detail

configureShell

protected void configureShell(org.eclipse.swt.widgets.Shell shell)
Configures the Shell representing this CertificateDialog.

Overrides:
configureShell in class org.eclipse.jface.window.Window
Parameters:
shell - theShell to configure

createContents

protected org.eclipse.swt.widgets.Control createContents(org.eclipse.swt.widgets.Composite parent)
Creates the contents of this CertificateDialog.

Overrides:
createContents in class org.eclipse.jface.dialogs.Dialog
Parameters:
parent - the parent Composite in which to embed the created contents

createButtonsForButtonBar

protected void createButtonsForButtonBar(org.eclipse.swt.widgets.Composite parent)
Adds the buttons to this CertificateDialog's button bar.

Overrides:
createButtonsForButtonBar in class org.eclipse.jface.dialogs.Dialog
Parameters:
parent - the button bar Composite
See Also:
Dialog.createButtonsForButtonBar(Composite)

createDialogArea

protected org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
Creates and returns the contents of the upper part of this CertificateDialog (above the button bar).

Overrides:
createDialogArea in class org.eclipse.jface.dialogs.Dialog
Parameters:
parent - the parent Composite to contain the dialog area
Returns:
the dialog area control

addCertificateFieldLabel

private void addCertificateFieldLabel(org.eclipse.swt.widgets.Composite composite,
                                      java.lang.String label,
                                      java.lang.String value)

getSubjectCertificate

private java.security.cert.X509Certificate getSubjectCertificate()

reverseArray

private java.lang.Object[] reverseArray(java.lang.Object[] array)

parseCertificateChains

private void parseCertificateChains(org.eclipse.swt.widgets.TreeItem root)

createGeneralTabItem

private void createGeneralTabItem(org.eclipse.swt.custom.CTabFolder folder,
                                  org.eclipse.swt.custom.CTabItem item)

createDetailTabItem

private void createDetailTabItem(org.eclipse.swt.custom.CTabFolder folder,
                                 org.eclipse.swt.custom.CTabItem item)

generateCertificateChainTree

private void generateCertificateChainTree(org.eclipse.swt.widgets.TreeItem root,
                                          java.security.cert.Certificate[] certs)

generateCertificateChainTree

private void generateCertificateChainTree(org.eclipse.swt.widgets.Tree tree,
                                          org.eclipse.swt.widgets.Tree details,
                                          org.eclipse.swt.widgets.Text valueText)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

generateNode

private org.eclipse.swt.widgets.TreeItem generateNode(org.eclipse.swt.widgets.TreeItem parent,
                                                      java.lang.String childName,
                                                      java.lang.Object data)

generateExtensionNode

private void generateExtensionNode(org.eclipse.swt.widgets.TreeItem parent,
                                   java.security.cert.X509Certificate cert,
                                   org.bouncycastle.asn1.x509.X509Extensions extensions,
                                   java.lang.String oid)

formatDate

private java.lang.String formatDate(java.util.Date d)

generateCertificateStructureTree

private void generateCertificateStructureTree(org.eclipse.swt.widgets.Tree tree,
                                              org.eclipse.swt.widgets.Text valueText,
                                              java.security.cert.Certificate selected)