Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 94611 Details for
Bug 220805
[sec] Need API for showing certificates to a UI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Adds certificate API to provisional package
patch_220805.txt (text/plain), 53.24 KB, created by
Matt Flaherty
on 2008-04-02 15:53:48 EDT
(
hide
)
Description:
Adds certificate API to provisional package
Filename:
MIME Type:
Creator:
Matt Flaherty
Created:
2008-04-02 15:53:48 EDT
Size:
53.24 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.security.ui >Index: src/org/eclipse/equinox/internal/provisional/security/ui/services/package.html >=================================================================== >RCS file: src/org/eclipse/equinox/internal/provisional/security/ui/services/package.html >diff -N src/org/eclipse/equinox/internal/provisional/security/ui/services/package.html >--- src/org/eclipse/equinox/internal/provisional/security/ui/services/package.html 26 Mar 2008 14:11:40 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,14 +0,0 @@ >-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> >-<html> >-<head> >- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> >- <title>Package-level Javadoc</title> >-</head> >-<body> >-Equinox security UI-related services >-<h2> >-Package Specification</h2> >-<p>This package provides an infrastructure and helper utilities for the Equinox security UI services. >-</p> >-</body> >-</html> >Index: src/org/eclipse/equinox/internal/provisional/security/ui/services/AuthorizationManager.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/provisional/security/ui/services/AuthorizationManager.java >diff -N src/org/eclipse/equinox/internal/provisional/security/ui/services/AuthorizationManager.java >--- src/org/eclipse/equinox/internal/provisional/security/ui/services/AuthorizationManager.java 26 Mar 2008 14:11:40 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,59 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.equinox.internal.provisional.security.ui.services; >- >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.ui.IWorkbenchWindow; >- >-/** >- * The AuthorizationManager is the facility by which the end user >- * is informed of the current state of the system with respect to >- * bundle authorization based security. >- */ >-public abstract class AuthorizationManager { >- >- public AuthorizationManager() { >- //no content >- } >- >- /** >- * Query whether the authorization system is enabled for the system. >- * >- * @return <code>true</code> if and only if authorization is enabled >- */ >- abstract public boolean isEnabled(); >- >- /** >- * Returns true when the system is in need of attention from the end >- * user. This means that some unauthorized content has been encountered, and the >- * user has not yet inspected the situation. >- * >- * @return <code>true</code> if user attention is required >- */ >- abstract public boolean needsAttention(); >- >- /** >- * Return an Eclipse IStatus object representing the current state of the >- * authorization system. >- * >- * @return IStatus code representing the system status >- */ >- abstract public IStatus getStatus(); >- >- /** >- * Open the authorization manager user interface so that the end >- * user can view and edit the system's authorization state. >- * >- * @param workbenchWindow the workbench window >- */ >- abstract public void displayManager(IWorkbenchWindow workbenchWindow); >- >-} >Index: src/org/eclipse/equinox/internal/security/ui/preferences/CertificatesPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/preferences/CertificatesPage.java,v >retrieving revision 1.1 >diff -u -r1.1 CertificatesPage.java >--- src/org/eclipse/equinox/internal/security/ui/preferences/CertificatesPage.java 28 Feb 2008 18:03:27 -0000 1.1 >+++ src/org/eclipse/equinox/internal/security/ui/preferences/CertificatesPage.java 2 Apr 2008 19:50:20 -0000 >@@ -13,6 +13,8 @@ > import java.security.cert.Certificate; > import java.security.cert.X509Certificate; > import java.util.*; >+import org.eclipse.equinox.internal.provisional.security.ui.X500PrincipalHelper; >+import org.eclipse.equinox.internal.provisional.security.ui.X509CertificateViewDialog; > import org.eclipse.equinox.internal.security.ui.*; > import org.eclipse.equinox.internal.security.ui.wizard.CertificateImportWizard; > import org.eclipse.jface.preference.PreferencePage; >Index: src/org/eclipse/equinox/internal/security/ui/DefaultAuthorizationManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/DefaultAuthorizationManager.java,v >retrieving revision 1.2 >diff -u -r1.2 DefaultAuthorizationManager.java >--- src/org/eclipse/equinox/internal/security/ui/DefaultAuthorizationManager.java 26 Mar 2008 14:11:41 -0000 1.2 >+++ src/org/eclipse/equinox/internal/security/ui/DefaultAuthorizationManager.java 2 Apr 2008 19:50:20 -0000 >@@ -12,7 +12,7 @@ > > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; >-import org.eclipse.equinox.internal.provisional.security.ui.services.AuthorizationManager; >+import org.eclipse.equinox.internal.provisional.security.ui.AuthorizationManager; > import org.eclipse.osgi.internal.provisional.service.security.AuthorizationStatus; > import org.eclipse.ui.IWorkbenchWindow; > >Index: src/org/eclipse/equinox/internal/security/ui/Activator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/Activator.java,v >retrieving revision 1.3 >diff -u -r1.3 Activator.java >--- src/org/eclipse/equinox/internal/security/ui/Activator.java 26 Mar 2008 14:11:41 -0000 1.3 >+++ src/org/eclipse/equinox/internal/security/ui/Activator.java 2 Apr 2008 19:50:20 -0000 >@@ -15,7 +15,7 @@ > import java.util.Hashtable; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; >-import org.eclipse.equinox.internal.provisional.security.ui.services.AuthorizationManager; >+import org.eclipse.equinox.internal.provisional.security.ui.AuthorizationManager; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.osgi.internal.provisional.service.security.AuthorizationEngine; > import org.eclipse.osgi.service.resolver.PlatformAdmin; >Index: src/org/eclipse/equinox/internal/security/ui/X509CertificateViewDialog.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/security/ui/X509CertificateViewDialog.java >diff -N src/org/eclipse/equinox/internal/security/ui/X509CertificateViewDialog.java >--- src/org/eclipse/equinox/internal/security/ui/X509CertificateViewDialog.java 28 Feb 2008 18:03:28 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,217 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008, Jay Rosenthal >- * >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Jay Rosenthal - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.equinox.internal.security.ui; >- >-import java.security.cert.X509Certificate; >-import java.text.DateFormat; >-import org.eclipse.equinox.internal.security.ui.wizard.CertificateViewer; >-import org.eclipse.jface.dialogs.IDialogConstants; >-import org.eclipse.jface.dialogs.TitleAreaDialog; >-import org.eclipse.jface.resource.JFaceResources; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.graphics.Font; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.layout.*; >-import org.eclipse.swt.widgets.*; >- >-public class X509CertificateViewDialog extends TitleAreaDialog { >- private final static String titleImageName = "/titleAreaCert.gif"; //$NON-NLS-1$ >- private X509Certificate theCert; >- private static final DateFormat _df = DateFormat.getDateInstance(DateFormat.LONG); >- private X500PrincipalHelper nameHelper = new X500PrincipalHelper(); >- >- // We use the "bannerFont" for our bold font >- private static Font boldFont = JFaceResources.getBannerFont(); >- private Image titleImage; >- >- public X509CertificateViewDialog(Shell parentShell, X509Certificate cert) { >- super(parentShell); >- this.theCert = cert; >- } >- >- protected Control createContents(Composite parent) { >- return super.createContents(parent); >- } >- >- protected Control createDialogArea(Composite parent) { >- nameHelper.setPrincipal(theCert.getSubjectX500Principal()); >- >- setTitle((nameHelper.getCN() != null ? nameHelper.getCN() : nameHelper.getOU())); >- >- titleImage = Activator.getImageDescriptor(titleImageName).createImage(); >- >- if (titleImage != null) >- setTitleImage(titleImage); >- >- Composite composite = (Composite) super.createDialogArea(parent); >- >- TabFolder tabFolder = new TabFolder(composite, SWT.BORDER); >- GridData bdata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL); >- tabFolder.setLayoutData(bdata); >- >- createBasicTab(tabFolder); >- >- createAdvancedTab(tabFolder); >- >- return composite; >- } >- >- private void createBasicTab(TabFolder tabFolder) { >- String displayName = null; >- int labelIndent = 10; >- int dataIdent = 10; >- >- TabItem basicTab = new TabItem(tabFolder, SWT.NULL); >- basicTab.setText(SecurityUIMsg.CERTVIEW_LABEL_BASIC); >- Composite basicTabComposite = new Composite(tabFolder, SWT.NONE); >- >- GridLayout tabLayout = new GridLayout(); >- tabLayout.numColumns = 2; >- basicTabComposite.setLayout(tabLayout); >- >- Label issueToLabel = new Label(basicTabComposite, SWT.NONE); >- issueToLabel.setText(SecurityUIMsg.CERTPROP_X509_ISSUED_TO); >- issueToLabel.setFont(boldFont); >- configureLayout(issueToLabel, 2, 0, 0, 0); >- >- // Display the RDNs of the Subject >- nameHelper.setPrincipal(theCert.getSubjectX500Principal()); >- >- Label CNLabel = new Label(basicTabComposite, SWT.NONE); >- CNLabel.setText(SecurityUIMsg.X500_LABEL_CN); >- configureLayout(CNLabel, 0, 0, labelIndent, 0); >- >- Label subjectCN = new Label(basicTabComposite, SWT.NONE); >- displayName = nameHelper.getCN(); >- subjectCN.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >- configureLayout(subjectCN, 0, 0, dataIdent, 0); >- >- Label OLabel = new Label(basicTabComposite, SWT.NONE); >- OLabel.setText(SecurityUIMsg.X500_LABEL_O); >- configureLayout(OLabel, 0, 0, labelIndent, 0); >- >- Label subjectO = new Label(basicTabComposite, SWT.NONE); >- displayName = nameHelper.getO(); >- subjectO.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >- configureLayout(subjectO, 0, 0, dataIdent, 0); >- >- Label OULabel = new Label(basicTabComposite, SWT.NONE); >- OULabel.setText(SecurityUIMsg.X500_LABEL_OU); >- configureLayout(OULabel, 0, 0, labelIndent, 0); >- >- Label subjectOU = new Label(basicTabComposite, SWT.NONE); >- displayName = nameHelper.getOU(); >- subjectOU.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >- configureLayout(subjectOU, 0, 0, dataIdent, 0); >- >- Label issueByLabel = new Label(basicTabComposite, SWT.NONE); >- issueByLabel.setText(SecurityUIMsg.CERTPROP_X509_ISSUED_BY); >- configureLayout(issueByLabel, 2, 0, 0, 0); >- issueByLabel.setFont(boldFont); >- >- // Display the RDNs of the Issuer >- nameHelper.setPrincipal(theCert.getIssuerX500Principal()); >- >- Label CNLabel2 = new Label(basicTabComposite, SWT.NONE); >- CNLabel2.setText(SecurityUIMsg.X500_LABEL_CN); >- configureLayout(CNLabel2, 0, 0, labelIndent, 0); >- >- Label issuerCN = new Label(basicTabComposite, SWT.NONE); >- displayName = nameHelper.getCN(); >- issuerCN.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >- configureLayout(issuerCN, 0, 0, dataIdent, 0); >- >- Label OLabel2 = new Label(basicTabComposite, SWT.NONE); >- OLabel2.setText(SecurityUIMsg.X500_LABEL_O); >- configureLayout(OLabel2, 0, 0, labelIndent, 0); >- >- Label issuerO = new Label(basicTabComposite, SWT.NONE); >- displayName = nameHelper.getO(); >- issuerO.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >- configureLayout(issuerO, 0, 0, dataIdent, 0); >- >- Label OULabel2 = new Label(basicTabComposite, SWT.NONE); >- OULabel2.setText(SecurityUIMsg.X500_LABEL_OU); >- configureLayout(OULabel2, 0, 0, labelIndent, 0); >- >- Label issuerOU = new Label(basicTabComposite, SWT.NONE); >- displayName = nameHelper.getOU(); >- issuerOU.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >- configureLayout(issuerOU, 0, 0, dataIdent, 0); >- >- Label datesLabel = new Label(basicTabComposite, SWT.NONE); >- datesLabel.setText(SecurityUIMsg.CERTVIEW_LABEL_VALIDITY_DATES); >- configureLayout(datesLabel, 2, 0, 0, 0); >- datesLabel.setFont(boldFont); >- >- Label validFrom = new Label(basicTabComposite, SWT.NONE); >- validFrom.setText(SecurityUIMsg.CERTPROP_X509_VALID_FROM); >- configureLayout(validFrom, 0, 0, labelIndent, 0); >- >- Label fromDate = new Label(basicTabComposite, SWT.NONE); >- fromDate.setText(_df.format(theCert.getNotBefore())); >- configureLayout(fromDate, 0, 0, dataIdent, 0); >- >- Label validTo = new Label(basicTabComposite, SWT.NONE); >- validTo.setText(SecurityUIMsg.CERTPROP_X509_VALID_TO); >- configureLayout(validTo, 0, 0, labelIndent, 0); >- >- Label toDate = new Label(basicTabComposite, SWT.NONE); >- toDate.setText(_df.format(theCert.getNotAfter())); >- configureLayout(toDate, 0, 0, dataIdent, 0); >- >- basicTab.setControl(basicTabComposite); >- } >- >- protected static void configureLayout(Control c, int horizontalSpan, int verticalSpan, int horizontalIndent, int vertIndent) { >- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER); >- >- gd.horizontalSpan = horizontalSpan; >- gd.verticalSpan = verticalSpan; >- gd.horizontalIndent = horizontalIndent; >- gd.verticalIndent = vertIndent; >- >- c.setLayoutData(gd); >- >- } >- >- private void createAdvancedTab(final TabFolder tabFolder) { >- TabItem advancedTab = new TabItem(tabFolder, SWT.NULL); >- advancedTab.setText(SecurityUIMsg.CERTVIEW_LABEL_DETAILS); >- Composite advTabComposite = new Composite(tabFolder, SWT.NONE); >- advTabComposite.setLayout(new FillLayout(SWT.VERTICAL)); >- >- CertificateViewer certViewer = new CertificateViewer(advTabComposite); >- certViewer.setCertificate(theCert); >- advancedTab.setControl(advTabComposite); >- } >- >- protected void setShellStyle(int newShellStyle) { >- >- super.setShellStyle(newShellStyle | SWT.RESIZE | SWT.DIALOG_TRIM); >- } >- >- protected void createButtonsForButtonBar(Composite parent) { >- // The default has only a "Close" button, but it returns the CANCEL Id >- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, true); >- >- } >- >- public boolean close() { >- if (titleImage != null) { >- titleImage.dispose(); >- } >- return super.close(); >- } >- >-} >Index: src/org/eclipse/equinox/internal/security/ui/X500PrincipalHelper.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/security/ui/X500PrincipalHelper.java >diff -N src/org/eclipse/equinox/internal/security/ui/X500PrincipalHelper.java >--- src/org/eclipse/equinox/internal/security/ui/X500PrincipalHelper.java 28 Feb 2008 18:03:28 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,276 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008, Jay Rosenthal >- * >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Jay Rosenthal - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.equinox.internal.security.ui; >- >-import java.util.ArrayList; >-import java.util.Iterator; >-import javax.security.auth.x500.X500Principal; >- >-/** >- * X500PrincipalHelper >- * <p> >- * Helper class to extract pieces (attributes) of an X500Principal object for display >- * in the UI. >- * <p> >- * This helper uses the X500Principal.RFC2253 format of X500Principal.getname() to parse an X500Principal name >- * into it's component parts. >- * <p> >- * In principals which contain multiple occurrences of the same attribute,the default for all the methods >- * is to return the most significant (first) attribute found. >- * >- */ >- >-public class X500PrincipalHelper { >- public static int LEASTSIGNIFICANT = 0; >- public static int MOSTSIGNIFICANT = 1; >- >- public final static String attrCN = "CN"; //$NON-NLS-1$ >- public final static String attrOU = "OU"; //$NON-NLS-1$ >- public final static String attrO = "O"; //$NON-NLS-1$ >- public final static String attrC = "C"; //$NON-NLS-1$ >- public final static String attrL = "L"; //$NON-NLS-1$ >- public final static String attrST = "ST"; //$NON-NLS-1$ >- public final static String attrSTREET = "STREET";//$NON-NLS-1$ >- public final static String attrEMAIL = "EMAILADDRESS"; //$NON-NLS-1$ >- public final static String attrUID = "UID"; //$NON-NLS-1$ >- >- ArrayList rdnNameArray = new ArrayList(); >- >- private final static String attrTerminator = "="; //$NON-NLS-1$ >- >- public X500PrincipalHelper() { >- // Do nothing constructor.. >- // Wont be useful unless setPrincipal is called... >- } >- >- public X500PrincipalHelper(X500Principal principal) { >- parseDN(principal.getName(X500Principal.RFC2253)); >- } >- >- /** >- * Set the X500Principal name object to be parsed. >- * <p> >- * @param principal - X500Principal >- */ >- public void setPrincipal(X500Principal principal) { >- parseDN(principal.getName(X500Principal.RFC2253)); >- } >- >- /** >- * Gets the most significant common name (CN) attribute from the given >- * X500Principal object. >- * For names that contains multiple attributes of this type. The first >- * (most significant) one will be returned >- * <p> >- * @return the Most significant common name attribute. >- * >- */ >- public String getCN() { >- return findPart(attrCN); >- } >- >- /** >- * Gets the most significant Organizational Unit (OU) attribute from the given >- * X500Principal object. >- * For names that contains multiple attributes of this type. The first >- * (most significant) one will be returned >- * <p> >- * >- * @return the Most significant OU attribute. >- * >- */ >- >- public String getOU() { >- return findPart(attrOU); >- >- } >- >- /** >- * Gets the most significant Organization (O) attribute from the given >- * X500Principal object. >- * For names that contains multiple attributes of this type. The first >- * (most significant) one will be returned >- * <p> >- * >- * @return the Most significant O attribute. >- * >- */ >- >- public String getO() { >- return findPart(attrO); >- >- } >- >- /** >- * Gets the Country (C) attribute from the given >- * X500Principal object. >- * <p> >- * >- * @return the C attribute. >- * >- */ >- public String getC() { >- return findPart(attrC); >- } >- >- /** >- * Gets the Locale (L) attribute from the given >- * X500Principal object. >- * <p> >- * >- * @return the L attribute. >- * >- */ >- public String getL() { >- return findPart(attrL); >- } >- >- /** >- * Gets the State (ST) attribute from the given >- * X500Principal object. >- * <p> >- * >- * @return the ST attribute. >- * >- */ >- public String getST() { >- return findPart(attrST); >- } >- >- /** >- * Gets the Street (STREET) attribute from the given >- * X500Principal object. >- * <p> >- * >- * @return the STREET attribute. >- * >- */ >- public String getSTREET() { >- return findPart(attrSTREET); >- } >- >- /** >- * Gets the Email Address (EMAILADDRESS) attribute from the given >- * X500Principal object. >- * <p> >- * >- * @return the EMAILADDRESS attribute. >- * >- */ >- public String getEMAILDDRESS() { >- return findPart(attrEMAIL); >- } >- >- public String getUID() { >- return findPart(attrUID); >- } >- >- /** >- * Derived From: org.eclipse.osgi.internal.verifier - DNChainMatching.java >- * >- * Takes a distinguished name in canonical form and fills in the rdnArray >- * with the extracted RDNs. >- * >- * @param dn the distinguished name in canonical form. >- * @throws IllegalArgumentException if a formatting error is found. >- */ >- private void parseDN(String dn) throws IllegalArgumentException { >- int startIndex = 0; >- char c = '\0'; >- ArrayList nameValues = new ArrayList(); >- >- // Clear the existing array, in case this instance is being re-used >- rdnNameArray.clear(); >- >- while (startIndex < dn.length()) { >- int endIndex; >- for (endIndex = startIndex; endIndex < dn.length(); endIndex++) { >- c = dn.charAt(endIndex); >- if (c == ',' || c == '+') >- break; >- if (c == '\\') { >- endIndex++; // skip the escaped char >- } >- } >- >- if (endIndex > dn.length()) >- throw new IllegalArgumentException("unterminated escape " + dn); //$NON-NLS-1$ >- >- nameValues.add(dn.substring(startIndex, endIndex)); >- >- if (c != '+') { >- rdnNameArray.add(nameValues); >- if (endIndex != dn.length()) >- nameValues = new ArrayList(); >- else >- nameValues = null; >- } >- startIndex = endIndex + 1; >- } >- if (nameValues != null) { >- throw new IllegalArgumentException("improperly terminated DN " + dn); //$NON-NLS-1$ >- } >- } >- >- /** >- * Returns an ArrayList containing all the values for the given attribute identifier. >- * <p> >- * @param attributeID String containing the X500 name attribute whose values are to be >- * returned >- * @return ArrayList containing the string values of the requested attribute. Values are in >- * the order they occur. May be empty. >- * >- */ >- public ArrayList getAllValues(String attributeID) { >- ArrayList retList = new ArrayList(); >- String searchPart = attributeID + attrTerminator; >- >- for (Iterator iter = rdnNameArray.iterator(); iter.hasNext();) { >- ArrayList nameList = (ArrayList) iter.next(); >- String namePart = (String) nameList.get(0); >- >- if (namePart.startsWith(searchPart)) { >- // Return the string starting after the ID string and the = sign that follows it. >- retList.add(namePart.toString().substring(searchPart.length())); >- } >- } >- >- return retList; >- >- } >- >- private String findPart(String attributeID) { >- return findSignificantPart(attributeID, MOSTSIGNIFICANT); >- } >- >- private String findSignificantPart(String attributeID, int significance) { >- String retNamePart = null; >- String searchPart = attributeID + attrTerminator; >- >- for (Iterator iter = rdnNameArray.iterator(); iter.hasNext();) { >- ArrayList nameList = (ArrayList) iter.next(); >- String namePart = (String) nameList.get(0); >- >- if (namePart.startsWith(searchPart)) { >- // Return the string starting after the ID string and the = sign that follows it. >- retNamePart = namePart.toString().substring(searchPart.length()); >- // By definition the first one is most significant >- if (significance == MOSTSIGNIFICANT) >- break; >- } >- } >- >- return retNamePart; >- } >- >-} >Index: src/org/eclipse/equinox/internal/security/ui/SecurityStatusControl.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/SecurityStatusControl.java,v >retrieving revision 1.2 >diff -u -r1.2 SecurityStatusControl.java >--- src/org/eclipse/equinox/internal/security/ui/SecurityStatusControl.java 26 Mar 2008 14:11:41 -0000 1.2 >+++ src/org/eclipse/equinox/internal/security/ui/SecurityStatusControl.java 2 Apr 2008 19:50:20 -0000 >@@ -12,7 +12,7 @@ > > import org.eclipse.core.runtime.*; > import org.eclipse.core.runtime.jobs.Job; >-import org.eclipse.equinox.internal.provisional.security.ui.services.AuthorizationManager; >+import org.eclipse.equinox.internal.provisional.security.ui.AuthorizationManager; > import org.eclipse.jface.action.ControlContribution; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.swt.SWT; >Index: src/org/eclipse/equinox/internal/provisional/security/ui/actions/package.html >=================================================================== >RCS file: src/org/eclipse/equinox/internal/provisional/security/ui/actions/package.html >diff -N src/org/eclipse/equinox/internal/provisional/security/ui/actions/package.html >--- src/org/eclipse/equinox/internal/provisional/security/ui/actions/package.html 26 Mar 2008 14:11:39 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,14 +0,0 @@ >-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> >-<html> >-<head> >- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> >- <title>Package-level Javadoc</title> >-</head> >-<body> >-Equinox security UI contributions >-<h2> >-Package Specification</h2> >-<p>This package provides access to the Equinox security UI contributions. >-</p> >-</body> >-</html> >Index: src/org/eclipse/equinox/internal/provisional/security/ui/actions/SecurityContributionItemFactory.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/provisional/security/ui/actions/SecurityContributionItemFactory.java >diff -N src/org/eclipse/equinox/internal/provisional/security/ui/actions/SecurityContributionItemFactory.java >--- src/org/eclipse/equinox/internal/provisional/security/ui/actions/SecurityContributionItemFactory.java 26 Mar 2008 14:11:40 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,59 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.equinox.internal.provisional.security.ui.actions; >- >-import org.eclipse.equinox.internal.security.ui.SecurityStatusControl; >-import org.eclipse.jface.action.IContributionItem; >-import org.eclipse.ui.IWorkbenchWindow; >-import org.eclipse.ui.actions.ContributionItemFactory; >- >-/** >- * Access to security related contribution items for the workbench. >- * <p> >- * Clients may declare subclasses that provide additional application-specific >- * contribution item factories. >- * </p> >- */ >-public abstract class SecurityContributionItemFactory { >- >- /** >- * Id of contribution items created by this factory. >- */ >- private final String contributionItemId; >- >- /** >- * Creates a new contribution item factory with the given id. >- * @param contributionItemId the id of contribution items created by this factory >- */ >- protected SecurityContributionItemFactory(String contributionItemId) { >- this.contributionItemId = contributionItemId; >- } >- >- /** >- * Returns the id of this contribution item factory. >- * @return the id of contribution items created by this factory >- */ >- public String getId() { >- return contributionItemId; >- } >- >- /** >- * Workbench contribution item (id "securityStatus"): An icon for >- * evaluating and inspecting the security status of the system. >- */ >- public static final ContributionItemFactory SECURITY_STATUS = new ContributionItemFactory("securityStatus") {//$NON-NLS-1$ >- public IContributionItem create(IWorkbenchWindow window) { >- if (window == null) >- throw new IllegalArgumentException(); >- return new SecurityStatusControl(window, getId()); >- } >- }; >-} >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.6 >diff -u -r1.6 MANIFEST.MF >--- META-INF/MANIFEST.MF 26 Mar 2008 14:11:41 -0000 1.6 >+++ META-INF/MANIFEST.MF 2 Apr 2008 19:50:20 -0000 >@@ -22,8 +22,7 @@ > org.eclipse.equinox.preferences;bundle-version="[3.2.200,4.0.0)", > org.eclipse.ui;bundle-version="[3.4.0,4.0.0)" > Bundle-Activator: org.eclipse.equinox.internal.security.ui.Activator >-Export-Package: org.eclipse.equinox.internal.provisional.security.ui.actions;version="1.0.0";x-internal:=true, >- org.eclipse.equinox.internal.provisional.security.ui.services;version="1.0.0";x-internal:=true, >+Export-Package: org.eclipse.equinox.internal.provisional.security.ui;version="1.0.0";x-internal:=true, > org.eclipse.equinox.internal.security.ui;x-internal:=true, > org.eclipse.equinox.internal.security.ui.nls;x-internal:=true, > org.eclipse.equinox.internal.security.ui.preferences;x-internal:=true, >Index: src/org/eclipse/equinox/internal/provisional/security/ui/SecurityContributionItemFactory.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/provisional/security/ui/SecurityContributionItemFactory.java >diff -N src/org/eclipse/equinox/internal/provisional/security/ui/SecurityContributionItemFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/provisional/security/ui/SecurityContributionItemFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+ * Copyright (c) 2007, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.provisional.security.ui; >+ >+import org.eclipse.equinox.internal.security.ui.SecurityStatusControl; >+import org.eclipse.jface.action.IContributionItem; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.actions.ContributionItemFactory; >+ >+/** >+ * Access to security related contribution items for the workbench. >+ * <p> >+ * Clients may declare subclasses that provide additional application-specific >+ * contribution item factories. >+ * </p> >+ */ >+public abstract class SecurityContributionItemFactory { >+ >+ /** >+ * Id of contribution items created by this factory. >+ */ >+ private final String contributionItemId; >+ >+ /** >+ * Creates a new contribution item factory with the given id. >+ * @param contributionItemId the id of contribution items created by this factory >+ */ >+ protected SecurityContributionItemFactory(String contributionItemId) { >+ this.contributionItemId = contributionItemId; >+ } >+ >+ /** >+ * Returns the id of this contribution item factory. >+ * @return the id of contribution items created by this factory >+ */ >+ public String getId() { >+ return contributionItemId; >+ } >+ >+ /** >+ * Workbench contribution item (id "securityStatus"): An icon for >+ * evaluating and inspecting the security status of the system. >+ */ >+ public static final ContributionItemFactory SECURITY_STATUS = new ContributionItemFactory("securityStatus") {//$NON-NLS-1$ >+ public IContributionItem create(IWorkbenchWindow window) { >+ if (window == null) >+ throw new IllegalArgumentException(); >+ return new SecurityStatusControl(window, getId()); >+ } >+ }; >+} >Index: src/org/eclipse/equinox/internal/provisional/security/ui/X500PrincipalHelper.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/provisional/security/ui/X500PrincipalHelper.java >diff -N src/org/eclipse/equinox/internal/provisional/security/ui/X500PrincipalHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/provisional/security/ui/X500PrincipalHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,276 @@ >+/******************************************************************************* >+ * Copyright (c) 2008, Jay Rosenthal >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Jay Rosenthal - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.equinox.internal.provisional.security.ui; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import javax.security.auth.x500.X500Principal; >+ >+/** >+ * X500PrincipalHelper >+ * <p> >+ * Helper class to extract pieces (attributes) of an X500Principal object for display >+ * in the UI. >+ * <p> >+ * This helper uses the X500Principal.RFC2253 format of X500Principal.getname() to parse an X500Principal name >+ * into it's component parts. >+ * <p> >+ * In principals which contain multiple occurrences of the same attribute,the default for all the methods >+ * is to return the most significant (first) attribute found. >+ * >+ */ >+ >+public class X500PrincipalHelper { >+ public static int LEASTSIGNIFICANT = 0; >+ public static int MOSTSIGNIFICANT = 1; >+ >+ public final static String attrCN = "CN"; //$NON-NLS-1$ >+ public final static String attrOU = "OU"; //$NON-NLS-1$ >+ public final static String attrO = "O"; //$NON-NLS-1$ >+ public final static String attrC = "C"; //$NON-NLS-1$ >+ public final static String attrL = "L"; //$NON-NLS-1$ >+ public final static String attrST = "ST"; //$NON-NLS-1$ >+ public final static String attrSTREET = "STREET";//$NON-NLS-1$ >+ public final static String attrEMAIL = "EMAILADDRESS"; //$NON-NLS-1$ >+ public final static String attrUID = "UID"; //$NON-NLS-1$ >+ >+ ArrayList rdnNameArray = new ArrayList(); >+ >+ private final static String attrTerminator = "="; //$NON-NLS-1$ >+ >+ public X500PrincipalHelper() { >+ // Do nothing constructor.. >+ // Wont be useful unless setPrincipal is called... >+ } >+ >+ public X500PrincipalHelper(X500Principal principal) { >+ parseDN(principal.getName(X500Principal.RFC2253)); >+ } >+ >+ /** >+ * Set the X500Principal name object to be parsed. >+ * <p> >+ * @param principal - X500Principal >+ */ >+ public void setPrincipal(X500Principal principal) { >+ parseDN(principal.getName(X500Principal.RFC2253)); >+ } >+ >+ /** >+ * Gets the most significant common name (CN) attribute from the given >+ * X500Principal object. >+ * For names that contains multiple attributes of this type. The first >+ * (most significant) one will be returned >+ * <p> >+ * @return the Most significant common name attribute. >+ * >+ */ >+ public String getCN() { >+ return findPart(attrCN); >+ } >+ >+ /** >+ * Gets the most significant Organizational Unit (OU) attribute from the given >+ * X500Principal object. >+ * For names that contains multiple attributes of this type. The first >+ * (most significant) one will be returned >+ * <p> >+ * >+ * @return the Most significant OU attribute. >+ * >+ */ >+ >+ public String getOU() { >+ return findPart(attrOU); >+ >+ } >+ >+ /** >+ * Gets the most significant Organization (O) attribute from the given >+ * X500Principal object. >+ * For names that contains multiple attributes of this type. The first >+ * (most significant) one will be returned >+ * <p> >+ * >+ * @return the Most significant O attribute. >+ * >+ */ >+ >+ public String getO() { >+ return findPart(attrO); >+ >+ } >+ >+ /** >+ * Gets the Country (C) attribute from the given >+ * X500Principal object. >+ * <p> >+ * >+ * @return the C attribute. >+ * >+ */ >+ public String getC() { >+ return findPart(attrC); >+ } >+ >+ /** >+ * Gets the Locale (L) attribute from the given >+ * X500Principal object. >+ * <p> >+ * >+ * @return the L attribute. >+ * >+ */ >+ public String getL() { >+ return findPart(attrL); >+ } >+ >+ /** >+ * Gets the State (ST) attribute from the given >+ * X500Principal object. >+ * <p> >+ * >+ * @return the ST attribute. >+ * >+ */ >+ public String getST() { >+ return findPart(attrST); >+ } >+ >+ /** >+ * Gets the Street (STREET) attribute from the given >+ * X500Principal object. >+ * <p> >+ * >+ * @return the STREET attribute. >+ * >+ */ >+ public String getSTREET() { >+ return findPart(attrSTREET); >+ } >+ >+ /** >+ * Gets the Email Address (EMAILADDRESS) attribute from the given >+ * X500Principal object. >+ * <p> >+ * >+ * @return the EMAILADDRESS attribute. >+ * >+ */ >+ public String getEMAILDDRESS() { >+ return findPart(attrEMAIL); >+ } >+ >+ public String getUID() { >+ return findPart(attrUID); >+ } >+ >+ /** >+ * Derived From: org.eclipse.osgi.internal.verifier - DNChainMatching.java >+ * >+ * Takes a distinguished name in canonical form and fills in the rdnArray >+ * with the extracted RDNs. >+ * >+ * @param dn the distinguished name in canonical form. >+ * @throws IllegalArgumentException if a formatting error is found. >+ */ >+ private void parseDN(String dn) throws IllegalArgumentException { >+ int startIndex = 0; >+ char c = '\0'; >+ ArrayList nameValues = new ArrayList(); >+ >+ // Clear the existing array, in case this instance is being re-used >+ rdnNameArray.clear(); >+ >+ while (startIndex < dn.length()) { >+ int endIndex; >+ for (endIndex = startIndex; endIndex < dn.length(); endIndex++) { >+ c = dn.charAt(endIndex); >+ if (c == ',' || c == '+') >+ break; >+ if (c == '\\') { >+ endIndex++; // skip the escaped char >+ } >+ } >+ >+ if (endIndex > dn.length()) >+ throw new IllegalArgumentException("unterminated escape " + dn); //$NON-NLS-1$ >+ >+ nameValues.add(dn.substring(startIndex, endIndex)); >+ >+ if (c != '+') { >+ rdnNameArray.add(nameValues); >+ if (endIndex != dn.length()) >+ nameValues = new ArrayList(); >+ else >+ nameValues = null; >+ } >+ startIndex = endIndex + 1; >+ } >+ if (nameValues != null) { >+ throw new IllegalArgumentException("improperly terminated DN " + dn); //$NON-NLS-1$ >+ } >+ } >+ >+ /** >+ * Returns an ArrayList containing all the values for the given attribute identifier. >+ * <p> >+ * @param attributeID String containing the X500 name attribute whose values are to be >+ * returned >+ * @return ArrayList containing the string values of the requested attribute. Values are in >+ * the order they occur. May be empty. >+ * >+ */ >+ public ArrayList getAllValues(String attributeID) { >+ ArrayList retList = new ArrayList(); >+ String searchPart = attributeID + attrTerminator; >+ >+ for (Iterator iter = rdnNameArray.iterator(); iter.hasNext();) { >+ ArrayList nameList = (ArrayList) iter.next(); >+ String namePart = (String) nameList.get(0); >+ >+ if (namePart.startsWith(searchPart)) { >+ // Return the string starting after the ID string and the = sign that follows it. >+ retList.add(namePart.toString().substring(searchPart.length())); >+ } >+ } >+ >+ return retList; >+ >+ } >+ >+ private String findPart(String attributeID) { >+ return findSignificantPart(attributeID, MOSTSIGNIFICANT); >+ } >+ >+ private String findSignificantPart(String attributeID, int significance) { >+ String retNamePart = null; >+ String searchPart = attributeID + attrTerminator; >+ >+ for (Iterator iter = rdnNameArray.iterator(); iter.hasNext();) { >+ ArrayList nameList = (ArrayList) iter.next(); >+ String namePart = (String) nameList.get(0); >+ >+ if (namePart.startsWith(searchPart)) { >+ // Return the string starting after the ID string and the = sign that follows it. >+ retNamePart = namePart.toString().substring(searchPart.length()); >+ // By definition the first one is most significant >+ if (significance == MOSTSIGNIFICANT) >+ break; >+ } >+ } >+ >+ return retNamePart; >+ } >+ >+} >Index: src/org/eclipse/equinox/internal/provisional/security/ui/package.html >=================================================================== >RCS file: src/org/eclipse/equinox/internal/provisional/security/ui/package.html >diff -N src/org/eclipse/equinox/internal/provisional/security/ui/package.html >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/provisional/security/ui/package.html 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,14 @@ >+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> >+<html> >+<head> >+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> >+ <title>Package-level Javadoc</title> >+</head> >+<body> >+Equinox security UI contributions >+<h2> >+Package Specification</h2> >+<p>This package provides access to the Equinox security UI contributions. >+</p> >+</body> >+</html> >Index: src/org/eclipse/equinox/internal/provisional/security/ui/AuthorizationManager.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/provisional/security/ui/AuthorizationManager.java >diff -N src/org/eclipse/equinox/internal/provisional/security/ui/AuthorizationManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/provisional/security/ui/AuthorizationManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.provisional.security.ui; >+ >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.ui.IWorkbenchWindow; >+ >+/** >+ * The AuthorizationManager is the facility by which the end user >+ * is informed of the current state of the system with respect to >+ * bundle authorization based security. >+ */ >+public abstract class AuthorizationManager { >+ >+ public AuthorizationManager() { >+ //no content >+ } >+ >+ /** >+ * Query whether the authorization system is enabled for the system. >+ * >+ * @return <code>true</code> if and only if authorization is enabled >+ */ >+ abstract public boolean isEnabled(); >+ >+ /** >+ * Returns true when the system is in need of attention from the end >+ * user. This means that some unauthorized content has been encountered, and the >+ * user has not yet inspected the situation. >+ * >+ * @return <code>true</code> if user attention is required >+ */ >+ abstract public boolean needsAttention(); >+ >+ /** >+ * Return an Eclipse IStatus object representing the current state of the >+ * authorization system. >+ * >+ * @return IStatus code representing the system status >+ */ >+ abstract public IStatus getStatus(); >+ >+ /** >+ * Open the authorization manager user interface so that the end >+ * user can view and edit the system's authorization state. >+ * >+ * @param workbenchWindow the workbench window >+ */ >+ abstract public void displayManager(IWorkbenchWindow workbenchWindow); >+ >+} >Index: src/org/eclipse/equinox/internal/provisional/security/ui/X509CertificateViewDialog.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/provisional/security/ui/X509CertificateViewDialog.java >diff -N src/org/eclipse/equinox/internal/provisional/security/ui/X509CertificateViewDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/provisional/security/ui/X509CertificateViewDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,219 @@ >+/******************************************************************************* >+ * Copyright (c) 2008, Jay Rosenthal >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Jay Rosenthal - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.equinox.internal.provisional.security.ui; >+ >+import java.security.cert.X509Certificate; >+import java.text.DateFormat; >+import org.eclipse.equinox.internal.security.ui.Activator; >+import org.eclipse.equinox.internal.security.ui.SecurityUIMsg; >+import org.eclipse.equinox.internal.security.ui.wizard.CertificateViewer; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.dialogs.TitleAreaDialog; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+ >+public class X509CertificateViewDialog extends TitleAreaDialog { >+ private final static String titleImageName = "/titleAreaCert.gif"; //$NON-NLS-1$ >+ private X509Certificate theCert; >+ private static final DateFormat _df = DateFormat.getDateInstance(DateFormat.LONG); >+ private X500PrincipalHelper nameHelper = new X500PrincipalHelper(); >+ >+ // We use the "bannerFont" for our bold font >+ private static Font boldFont = JFaceResources.getBannerFont(); >+ private Image titleImage; >+ >+ public X509CertificateViewDialog(Shell parentShell, X509Certificate cert) { >+ super(parentShell); >+ this.theCert = cert; >+ } >+ >+ protected Control createContents(Composite parent) { >+ return super.createContents(parent); >+ } >+ >+ protected Control createDialogArea(Composite parent) { >+ nameHelper.setPrincipal(theCert.getSubjectX500Principal()); >+ >+ setTitle((nameHelper.getCN() != null ? nameHelper.getCN() : nameHelper.getOU())); >+ >+ titleImage = Activator.getImageDescriptor(titleImageName).createImage(); >+ >+ if (titleImage != null) >+ setTitleImage(titleImage); >+ >+ Composite composite = (Composite) super.createDialogArea(parent); >+ >+ TabFolder tabFolder = new TabFolder(composite, SWT.BORDER); >+ GridData bdata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL); >+ tabFolder.setLayoutData(bdata); >+ >+ createBasicTab(tabFolder); >+ >+ createAdvancedTab(tabFolder); >+ >+ return composite; >+ } >+ >+ private void createBasicTab(TabFolder tabFolder) { >+ String displayName = null; >+ int labelIndent = 10; >+ int dataIdent = 10; >+ >+ TabItem basicTab = new TabItem(tabFolder, SWT.NULL); >+ basicTab.setText(SecurityUIMsg.CERTVIEW_LABEL_BASIC); >+ Composite basicTabComposite = new Composite(tabFolder, SWT.NONE); >+ >+ GridLayout tabLayout = new GridLayout(); >+ tabLayout.numColumns = 2; >+ basicTabComposite.setLayout(tabLayout); >+ >+ Label issueToLabel = new Label(basicTabComposite, SWT.NONE); >+ issueToLabel.setText(SecurityUIMsg.CERTPROP_X509_ISSUED_TO); >+ issueToLabel.setFont(boldFont); >+ configureLayout(issueToLabel, 2, 0, 0, 0); >+ >+ // Display the RDNs of the Subject >+ nameHelper.setPrincipal(theCert.getSubjectX500Principal()); >+ >+ Label CNLabel = new Label(basicTabComposite, SWT.NONE); >+ CNLabel.setText(SecurityUIMsg.X500_LABEL_CN); >+ configureLayout(CNLabel, 0, 0, labelIndent, 0); >+ >+ Label subjectCN = new Label(basicTabComposite, SWT.NONE); >+ displayName = nameHelper.getCN(); >+ subjectCN.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >+ configureLayout(subjectCN, 0, 0, dataIdent, 0); >+ >+ Label OLabel = new Label(basicTabComposite, SWT.NONE); >+ OLabel.setText(SecurityUIMsg.X500_LABEL_O); >+ configureLayout(OLabel, 0, 0, labelIndent, 0); >+ >+ Label subjectO = new Label(basicTabComposite, SWT.NONE); >+ displayName = nameHelper.getO(); >+ subjectO.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >+ configureLayout(subjectO, 0, 0, dataIdent, 0); >+ >+ Label OULabel = new Label(basicTabComposite, SWT.NONE); >+ OULabel.setText(SecurityUIMsg.X500_LABEL_OU); >+ configureLayout(OULabel, 0, 0, labelIndent, 0); >+ >+ Label subjectOU = new Label(basicTabComposite, SWT.NONE); >+ displayName = nameHelper.getOU(); >+ subjectOU.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >+ configureLayout(subjectOU, 0, 0, dataIdent, 0); >+ >+ Label issueByLabel = new Label(basicTabComposite, SWT.NONE); >+ issueByLabel.setText(SecurityUIMsg.CERTPROP_X509_ISSUED_BY); >+ configureLayout(issueByLabel, 2, 0, 0, 0); >+ issueByLabel.setFont(boldFont); >+ >+ // Display the RDNs of the Issuer >+ nameHelper.setPrincipal(theCert.getIssuerX500Principal()); >+ >+ Label CNLabel2 = new Label(basicTabComposite, SWT.NONE); >+ CNLabel2.setText(SecurityUIMsg.X500_LABEL_CN); >+ configureLayout(CNLabel2, 0, 0, labelIndent, 0); >+ >+ Label issuerCN = new Label(basicTabComposite, SWT.NONE); >+ displayName = nameHelper.getCN(); >+ issuerCN.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >+ configureLayout(issuerCN, 0, 0, dataIdent, 0); >+ >+ Label OLabel2 = new Label(basicTabComposite, SWT.NONE); >+ OLabel2.setText(SecurityUIMsg.X500_LABEL_O); >+ configureLayout(OLabel2, 0, 0, labelIndent, 0); >+ >+ Label issuerO = new Label(basicTabComposite, SWT.NONE); >+ displayName = nameHelper.getO(); >+ issuerO.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >+ configureLayout(issuerO, 0, 0, dataIdent, 0); >+ >+ Label OULabel2 = new Label(basicTabComposite, SWT.NONE); >+ OULabel2.setText(SecurityUIMsg.X500_LABEL_OU); >+ configureLayout(OULabel2, 0, 0, labelIndent, 0); >+ >+ Label issuerOU = new Label(basicTabComposite, SWT.NONE); >+ displayName = nameHelper.getOU(); >+ issuerOU.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED)); >+ configureLayout(issuerOU, 0, 0, dataIdent, 0); >+ >+ Label datesLabel = new Label(basicTabComposite, SWT.NONE); >+ datesLabel.setText(SecurityUIMsg.CERTVIEW_LABEL_VALIDITY_DATES); >+ configureLayout(datesLabel, 2, 0, 0, 0); >+ datesLabel.setFont(boldFont); >+ >+ Label validFrom = new Label(basicTabComposite, SWT.NONE); >+ validFrom.setText(SecurityUIMsg.CERTPROP_X509_VALID_FROM); >+ configureLayout(validFrom, 0, 0, labelIndent, 0); >+ >+ Label fromDate = new Label(basicTabComposite, SWT.NONE); >+ fromDate.setText(_df.format(theCert.getNotBefore())); >+ configureLayout(fromDate, 0, 0, dataIdent, 0); >+ >+ Label validTo = new Label(basicTabComposite, SWT.NONE); >+ validTo.setText(SecurityUIMsg.CERTPROP_X509_VALID_TO); >+ configureLayout(validTo, 0, 0, labelIndent, 0); >+ >+ Label toDate = new Label(basicTabComposite, SWT.NONE); >+ toDate.setText(_df.format(theCert.getNotAfter())); >+ configureLayout(toDate, 0, 0, dataIdent, 0); >+ >+ basicTab.setControl(basicTabComposite); >+ } >+ >+ protected static void configureLayout(Control c, int horizontalSpan, int verticalSpan, int horizontalIndent, int vertIndent) { >+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER); >+ >+ gd.horizontalSpan = horizontalSpan; >+ gd.verticalSpan = verticalSpan; >+ gd.horizontalIndent = horizontalIndent; >+ gd.verticalIndent = vertIndent; >+ >+ c.setLayoutData(gd); >+ >+ } >+ >+ private void createAdvancedTab(final TabFolder tabFolder) { >+ TabItem advancedTab = new TabItem(tabFolder, SWT.NULL); >+ advancedTab.setText(SecurityUIMsg.CERTVIEW_LABEL_DETAILS); >+ Composite advTabComposite = new Composite(tabFolder, SWT.NONE); >+ advTabComposite.setLayout(new FillLayout(SWT.VERTICAL)); >+ >+ CertificateViewer certViewer = new CertificateViewer(advTabComposite); >+ certViewer.setCertificate(theCert); >+ advancedTab.setControl(advTabComposite); >+ } >+ >+ protected void setShellStyle(int newShellStyle) { >+ >+ super.setShellStyle(newShellStyle | SWT.RESIZE | SWT.DIALOG_TRIM); >+ } >+ >+ protected void createButtonsForButtonBar(Composite parent) { >+ // The default has only a "Close" button, but it returns the CANCEL Id >+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, true); >+ >+ } >+ >+ public boolean close() { >+ if (titleImage != null) { >+ titleImage.dispose(); >+ } >+ return super.close(); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 220805
:
94423
| 94611